Skip to content

Instantly share code, notes, and snippets.

@bomatson
Created December 20, 2016 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bomatson/7a172c1013c1ff917f06b683bd986f34 to your computer and use it in GitHub Desktop.
Save bomatson/7a172c1013c1ff917f06b683bd986f34 to your computer and use it in GitHub Desktop.
function parse_git_dirty() {
[[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && echo "*"
}
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
function this() { # obtain git branch
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
function blam() {
git push origin $(this)
}
function kablam() {
git push origin $(this) -f
}
function repeat() {
n=$1
shift
while [ $(( n -= 1 )) -ge 0 ]
do
"$@"
done
}
function sherlock() {
ack -l $1 | xargs perl -pi -E "s/$1/$2/gc" && echo 'Elementary, my dear Watson'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment