Over the year I have collected a lot of gists of things that I constantly am looking up. If you’re not familiar with what a gist is start here. Basically it’s like pastebin but for code and other snippets that might be useful for saving for later or sharing with other coders.

At any rate though here are a few of the ones that I cobbled together to save myself some googleing.

How to add your ssh keys in one line

cat ~/.ssh/id_rsa.pub | ssh user@hostname "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"

Cygwin ctrl+arrow key fix

Add the following lines to ~/.inputrc (C:\cygwin\home<username>.inputrc):

"\e[1;5C": forward-word   # ctrl + right
"\e[1;5D": backward-word  # ctrl + left 

Set execution mode of a script using git

Change execution mode of a shell script so that it doesn’t get changed after git pull

git update-index --chmod=+x foo.sh

git ls-files --stage

Convert all files in a directory to Unix format

  1. Set up dos2unix

  2. Run the following in the directory

find . -type f -exec dos2unix {} \;

Parse json in one line shell script

echo "$foo" | awk -F"[,:]" '{for(i=1;i<=NF;i++){if($i~/bar\042/){print $(i+1)} } }'