Skip to content

Instantly share code, notes, and snippets.

@mislav
Created January 13, 2013 17:26
Show Gist options
  • Save mislav/4525198 to your computer and use it in GitHub Desktop.
Save mislav/4525198 to your computer and use it in GitHub Desktop.
A jump-to-session tmux shortcut. With `<prefix> S` a prompt is shown to enter a session name. If no name is given, switches back to the previously attached session. Session name can be a partial string that the session starts with, as long as it's unique.
#!/usr/bin/env bash
set -e
if [[ -z $1 ]]; then
tmux switch-client -l
else
tmux switch-client -t "$1"
fi
# switch to a session that start with the given name
bind S command-prompt -p session: "run-shell 'tmux-switch-session \"%%\"'"
@faceleg
Copy link

faceleg commented May 3, 2013

Thanks for posting this, I incorporated the idea into a script that allows one to switch to / attach / create a given session easily: https://github.com/faceleg/dotfiles/blob/master/addons/tmux/scripts/switch-create-attach.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment