disast.rs :: now :: notes

For when you need to chop text, and chop it fast

Awk

My dear friend awk:

# split on multi-char delimiters, e.g. print the second field after " :: "
cat file.txt | awk -F ' :: ' '{ print $2 }'

JQ

Git

Prune tracking branches not on the remote -- e.g. those branches that have been merged in to remote.

I use git branch -D <branch name> because I tend to squash-commit pull requests. This means that git will usually not detect that a branch has been merged.

git remote prune origin # --dry-run
git checkout master \
  && git fetch -p \
  && git remote prune origin \
  && git branch -vv \
  | grep ': gone]' \
  | grep -v '\*' \
  | awk '{ print $1 }' \
  | xargs -I{} git branch -D {}