Skip to content

Instantly share code, notes, and snippets.

@DanThiffault
Created January 15, 2013 19:02
Show Gist options
  • Save DanThiffault/4541064 to your computer and use it in GitHub Desktop.
Save DanThiffault/4541064 to your computer and use it in GitHub Desktop.
Tmux attach/create session from current directory
#!/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