Skip to content

Instantly share code, notes, and snippets.

@eliangcs
Last active January 18, 2016 06:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliangcs/96d47ba0540221164576 to your computer and use it in GitHub Desktop.
Save eliangcs/96d47ba0540221164576 to your computer and use it in GitHub Desktop.
Shell shortcuts
# Clear local merged branches
function clearbranches(){
cur_branch=`git rev-parse --abbrev-ref HEAD`
if [[ "$cur_branch" == "master" ]]; then
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
else
echo "Not on master branch!"
fi
}
# Delete *.pyc
alias clearpyc="find . -name '*.pyc' -delete"
# Start a static web server (Twisted required)
function httpserver(){
if [[ "$1" != "" ]]; then
twistd -n web --path "$1"
else
twistd -n web --path .
fi
}
# World time
# Put timezones in ~/.worldclock.zones. Example:
# US/Pacific
# UTC
# Europe/Moscow
# Asia/Taipei
function wt(){
while read zone
do echo $(TZ=$zone date "+%Y-%m-%d %H:%M:%S %z %Z") "($zone)"
done < "$HOME/.worldclock.zones"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment