Created
January 15, 2013 19:02
-
-
Save DanThiffault/4541064 to your computer and use it in GitHub Desktop.
Tmux attach/create session from current directory
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
#!/bin/sh | |
# tmux attach directory | |
# inspired by https://github.com/croaky/dotfiles/commit/df3dd5129bfa941ac0bdf2885da92f822042ee5b | |
SESSION=$(basename $PWD) | |
# credit from http://stackoverflow.com/questions/3432536/create-session-if-none-exists | |
function hassession { | |
tmux has-session -t $SESSION 2>/dev/null | |
} | |
if hassession | |
then | |
tmux attach -t $SESSION | |
else | |
tmux new-session -s $SESSION | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment