Skip to content

Instantly share code, notes, and snippets.

@zshihang
Created June 8, 2018 05:51
Show Gist options
  • Save zshihang/ecae746156620b44f7dcfc668ecf71c3 to your computer and use it in GitHub Desktop.
Save zshihang/ecae746156620b44f7dcfc668ecf71c3 to your computer and use it in GitHub Desktop.
tm() {
[[ -n "$TMUX" ]] && change="switch-client" || change="attach-session"
if [ $1 ]; then
tmux $change -t "$1" 2>/dev/null || (tmux new-session -d -s $1 && tmux $change -t "$1"); return
fi
session=$(tmux list-sessions -F "#{session_name}" 2>/dev/null | fzf --exit-0) && tmux $change -t "$session" || echo "No sessions found."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment