Created
February 26, 2016 17:35
-
-
Save hersonls/5177e2adf07405b7239f to your computer and use it in GitHub Desktop.
Auto load python virtual env and rename tmux window using zsh
This file contains 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
# 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