Created
May 21, 2011 13:49
-
-
Save mattjmorrison/984537 to your computer and use it in GitHub Desktop.
Add current virtualenv and git branch to shell prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Take your boring old prompt from this: | |
# matthew-morrisons-macbook:~$ | |
# and cd into a git repo and add the current branch to the prompt for a more glorious experience: | |
# matthew-morrisons-macbook:django-media-masher(master)$ | |
# then use `workon` to select a virtualenv and it will be added your prompt for additional glory: | |
# (media-masher)matthew-morrisons-macbook:django-media-masher(master)$ | |
# then freely switch branches and virtualenvs and have your prompt always reflect what you're | |
# currently working with | |
# | |
# make sure you do this first: | |
# copy git-completion.bash from git's source in contrib/completion into your home directory | |
# install the virtualenv and virtualenvwrapper python packages | |
# add the following to your bashrc | |
# source ~/.git_and_virtualenv.bash | |
#Setup virtualenvwrapper | |
export WORKON_HOME=$HOME/.virtualenvs | |
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python | |
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv | |
export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME" | |
export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME" | |
source /usr/local/bin/virtualenvwrapper.sh | |
#Setup git completion | |
source ~/.git-completion.bash | |
#Hijack cd and modify PS1 to include the current git branch | |
function cd(){ | |
builtin cd $@ | |
export PS1='\h:\W$(__git_ps1 "(%s)")\$ ' | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment