Created
March 20, 2015 15:23
-
-
Save ernesto-jimenez/dea41dbd4cb877a1df70 to your computer and use it in GitHub Desktop.
When entering a dir with a git repository, start a new tmux session for that repository or attach to the existing one if it has already been started.
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
# Always use the same tmux session in directories with git | |
attach_tmux_for_dirs_with_repos() { | |
if [ "$TERM" != "screen-256color" ]; then | |
if [ -d .git ]; then | |
SESSION_NAME=$(echo -n ${PWD//*\//}-tmux | tr . -) | |
tmux attach -t $SESSION_NAME || tmux new -s $SESSION_NAME | |
fi | |
fi | |
} | |
add-zsh-hook precmd attach_tmux_for_dirs_with_repos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment