Last active
November 9, 2021 14:22
-
-
Save TauPan/1b3f9d70c74f16e1b1a0b86e7787af77 to your computer and use it in GitHub Desktop.
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 characters
#!/usr/bin/env bash | |
name="$1" | |
shift | |
args="$*" | |
tmux-select-window-globally "$name" || tmux -2 new-window -n "$name" "$args" | |
# exit status 1 if window does not exist afterwards | |
sleep 0.1 | |
tmux select-window -t "$name" |
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 characters
#!/usr/bin/env bash | |
name="$1" | |
switched="false" | |
current_session=$(tmux display-message -p "#{session_name}") | |
tmux list-panes -a -F 'session_name="#{session_name}" window_index="#{window_index}" pane_index="#{pane_index}" window_name="#{window_name}" 'pane_title="'#{pane_title}'" | sort | { | |
while read line | |
do | |
eval $line | |
if [ "$window_name" = "$name" ] | |
then | |
if [ "$session_name" != "$current_session" ] | |
then | |
tmux -2 switch-client -t $session_name | |
fi | |
tmux -2 select-window -t $session_name:$window_name | |
tmux select-pane -t $session_name:$window_index.${pane_index} | |
switched="true" | |
break | |
fi | |
done | |
if [ "$switched" = "false" ] | |
then | |
exit 1 | |
else | |
exit 0 | |
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 characters
bind-key m run-shell "tmux-select-or-new-window mutt mutt ; tmux-move-or-swap-window -t 2" | |
bind-key M-c run-shell "tmux-select-or-new-window mc mc -x" # M-c, haha, get it? ;) | |
bind-key e run-shell "tmux-select-or-new-window emacs 'emacsclient -t || emacs'" | |
bind-key C-e run-shell "tmux-select-or-new-window emacs 'emacsclient -t || emacs'" | |
bind-key t run-shell "tmux-select-or-new-window htop htop" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment