Last active
April 25, 2025 04:13
-
-
Save jyurek/7be666a88e06f68d45cf to your computer and use it in GitHub Desktop.
Revisions
-
Jon Yurek revised this gist
May 30, 2014 . 2 changed files with 2 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,11 @@ #!/bin/sh tm() { if [ -z $1 ]; then tmux switch-client -l else if [ -z "$TMUX" ]; then tmux new-session -As $1 else if ! tmux has-session -t $1 2>/dev/null; then TMUX= tmux new-session -ds $1 fi @@ -16,9 +14,4 @@ tm() { fi } tm $1 This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,3 @@ # Toggle between the last two sessions bind m switch-client -l bind M command-prompt -p 'switch session:' "run \"tm '%%'\"" -
Jon Yurek revised this gist
May 30, 2014 . 2 changed files with 22 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,24 @@ #!/bin/sh tm() { if [ -z $1 ]; then target_session=$(cat /tmp/previous-tmux-session) tm $target_session else if [ -z "$TMUX" ]; then tmux new-session -As $1 else record_previous_session if ! tmux has-session -t $1 2>/dev/null; then TMUX= tmux new-session -ds $1 fi tmux switch-client -t $1 fi fi } record_previous_session() { current_session=$(tmux list-sessions | grep '(attached)$' | cut -d: -f 1) echo $current_session > /tmp/previous-tmux-session } tm $1 This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ # Toggle between the last two sessions bind m run "tm" bind M command-prompt -p 'switch session:' "run \"tm '%%'\"" -
Jon Yurek revised this gist
May 22, 2014 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
Jon Yurek created this gist
May 22, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ tm() { if [ -z "$TMUX" ]; then # not in tmux tmux new-session -As $1 else # inside tmux if [ tmux has-session $1 ]; then tmux switch-client -t $1 else TMUX= tmux new-session -ds $1 tmux switch-client -t $1 fi fi } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ # tmux session tab complete function _tmux_complete_session() { local IFS=$'\n' local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-sessions | cut -f 1 -d ':')" -- "${cur}") ) } complete -F _tmux_complete_session tm