Skip to content

Instantly share code, notes, and snippets.

@hersonls
Created February 26, 2016 17:35
Show Gist options
  • Save hersonls/5177e2adf07405b7239f to your computer and use it in GitHub Desktop.
Save hersonls/5177e2adf07405b7239f to your computer and use it in GitHub Desktop.
Auto load python virtual env and rename tmux window using zsh
# chpwd is a zsh hook, wich is executed after change directory
# More info: http://zsh.sourceforge.net/Doc/Release/Functions.html
function chpwd() {
if [ -z "$VIRTUAL_ENV" ]; then
# If exists a virtualenv with name of directory, load it!
workon ${PWD##*/} 2> /dev/null
else
# If a virtual env are loaded, rename window with they name
TMUX_WINDOW_NAME=$(tmux display-message -p '#W')
if [ $TMUX_WINDOW_NAME != ${VIRTUAL_ENV##*/} ]; then
tmux rename-window ${VIRTUAL_ENV##*/} ;
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment