Skip to content

Instantly share code, notes, and snippets.

@juliantcook
juliantcook / npr
Created July 24, 2023 12:43
fzf npm scripts
#! /bin/bash
npm run $(cat package.json | jq '.scripts | keys[]' | fzf | sed 's/"//g')
@juliantcook
juliantcook / git-fch
Created April 27, 2023 11:29
checkout git branch with fuzzy find
#! /bin/bash
git checkout $(git branch -a | fzf | sed 's/.* //')
@juliantcook
juliantcook / git-grep-revert-all
Created January 19, 2023 10:54
Revert all commits matching a grep.
git log --grep "${1}" --no-merges --oneline | cut -d ' ' -f1 | xargs git revert --no-edit
#! /bin/bash
git checkout $(git branch | grep $1 | head -n1)
# control character a instead of b
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# set window name to current dir
set-option -g status-interval 5
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{b:pane_current_path}'
@juliantcook
juliantcook / .zshrc
Last active April 13, 2022 14:42
Shell aliases
alias ll="ls -laG"
alias l="ls -G"
alias g=git
alias d=docker
# stop ^ being interpreted by zsh
setopt NO_NOMATCH
# format user on prompt
# source: https://stackoverflow.com/questions/689765/how-can-i-change-the-color-of-my-prompt-in-zsh-different-from-normal-text
@juliantcook
juliantcook / .gitconfig
Last active November 6, 2023 12:19
Global git config aliases
[alias]
l = log
s = status
c = commit
a = add
d = diff
dc = "diff --cached"
chb = "checkout -b"
@juliantcook
juliantcook / remove-space.js
Created October 1, 2021 11:05
Remove consecutive spaces. Usage to oneline formatted json: `pbpaste | oneline.js | remove-space.js | pbcopy`
#!/usr/bin/env node
/**
* remove more than one consecutive space
*/
const readable = process.stdin;
readable.on('readable', () => {
let chunk;
let prevCharSpace = false;
@juliantcook
juliantcook / oneline.js
Created May 19, 2021 13:02
Remove tabs and newlines from text.
/**
* remove tabs / newlines
*/
const readable = process.stdin;
readable.on('readable', () => {
let chunk;
while (null !== (chunk = readable.read())) {
for (const char of `${chunk}`) {
if (char === '\t' || char === '\n') {
@juliantcook
juliantcook / indent.js
Last active June 15, 2021 11:21
Indent string by parenthesis
/**
* indent string by parenthesis.
*/
const readable = process.stdin;
let depth = 0;
readable.on('readable', () => {
let chunk;
while (null !== (chunk = readable.read())) {
for (const char of `${chunk}`) {