Skip to content

Instantly share code, notes, and snippets.

@JesseHerrick
Created May 23, 2015 20:50
Show Gist options
  • Save JesseHerrick/1078218979327b373919 to your computer and use it in GitHub Desktop.
Save JesseHerrick/1078218979327b373919 to your computer and use it in GitHub Desktop.
write() function for writing articles
#!/usr/bin/env bash
write() {
command="$@"
# run the command
$@
# special command exec stuff
case $command in
# git commit
*commit*)
commit_message=`git log -1 --pretty=%B`
git_diff=`git diff @~..@`
echo "\nCOMMIT: $commit_message\n$git_diff\nENDCOMMIT\n" >> $HOME/Desktop/history.txt
;;
# any other command
*)
echo "\$ $command" >> $HOME/Desktop/history.txt
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment