Skip to content

Instantly share code, notes, and snippets.

@wcauchois
Created November 8, 2016 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wcauchois/041e52e8dbc6862b38a5f96713a39793 to your computer and use it in GitHub Desktop.
Save wcauchois/041e52e8dbc6862b38a5f96713a39793 to your computer and use it in GitHub Desktop.

t is a small wrapper around tmux. Its usage is as follows.

  • t list: List available tmux sessions (equiv to tmux list-sessions).
  • t new NAME: Create a new session with the specified name (equiv to tmux new-session -s NAME).
  • t NAME: Attach to the named session (equiv to tmux attach -t NAME); t attach NAME also works.
  • t (no arguments): Runs tmux attach || tmux which will either attach to the last session or start a new tmux instance.
# add this to your ~/.bashrc or whatever
function t() {
if [ -n "$1" ]; then
if [ "$1" = "list" ]; then
tmux list-sessions
elif [ "$1" = "new" ]; then
if [ -n "$2" ]; then
tmux new-session -s $2
else
tmux
fi
elif [ "$1" = "attach" ]; then
tmux attach -t $2
else
tmux attach -t $1
fi
else
tmux attach || tmux
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment