Usage:
snippet 345 snippet 1268 snippet 1281
# $ cat $HOME/.bash_login function snippet() { mkdir -p $HOME/Desktop/Snippets OPWD="$PWD" cd $HOME/Desktop/Snippets curl -L -O -s --max-time 25 http://textsnippets.com/posts/show/"$1" || exit 1 file="$HOME/Desktop/Snippets/$(basename $_)" textutil -convert txt "$file" rm "$file" new_file="$file.txt" sed -i "" -e '1,5d' -e 's/.See related posts.//' "$new_file" # delete first 5 lines of file sed -i "" -e :a -e '1,6!{P;N;D;};N;ba' "$new_file" # delete last 6 lines of file cd "$OPWD" return 0 }