tmux: gnome-style app-shortcuts for switching panes
This commit is contained in:
parent
0afb5698dd
commit
7ad9868c20
3 changed files with 54 additions and 41 deletions
30
.tmux.conf
30
.tmux.conf
|
@ -39,16 +39,17 @@ bind -n M-k copy-mode \; send-keys -X previous-prompt -o \; send-keys -X cursor-
|
||||||
bind -n M-j copy-mode \; send-keys -X previous-prompt -o \; send-keys -X cursor-up
|
bind -n M-j copy-mode \; send-keys -X previous-prompt -o \; send-keys -X cursor-up
|
||||||
bind -n M-Up select-pane -U
|
bind -n M-Up select-pane -U
|
||||||
bind -n M-Down select-pane -D
|
bind -n M-Down select-pane -D
|
||||||
bind -n M-1 select-window -t 42
|
bind -n M-1 run-shell -b "tmux-shortcut 1 helix"
|
||||||
bind -n M-2 select-window -t 2
|
bind -n M-2 run-shell -b "tmux-shortcut 2"
|
||||||
bind -n M-3 select-window -t 3
|
bind -n M-3 run-shell -b "tmux-shortcut 3"
|
||||||
bind -n M-4 select-window -t 4
|
bind -n M-4 run-shell -b "tmux-shortcut 4"
|
||||||
bind -n M-5 select-window -t 5
|
bind -n M-5 run-shell -b "tmux-shortcut 5"
|
||||||
bind -n M-6 select-window -t 6
|
bind -n M-6 run-shell -b "tmux-shortcut 6"
|
||||||
bind -n M-7 select-window -t 7
|
bind -n M-7 run-shell -b "tmux-shortcut 7"
|
||||||
bind -n M-8 select-window -t 8
|
bind -n M-8 run-shell -b "tmux-shortcut 8"
|
||||||
bind -n M-9 select-window -t 9
|
bind -n M-9 run-shell -b "tmux-shortcut 9"
|
||||||
bind -n M-0 select-window -t 10
|
bind -n M-0 run-shell -b "tmux-shortcut 10"
|
||||||
|
|
||||||
bind -n M-m send-keys -t 9 q C-u "clear; tmux clear-history -t 9" C-m C-p C-p C-p C-m
|
bind -n M-m send-keys -t 9 q C-u "clear; tmux clear-history -t 9" C-m C-p C-p C-p C-m
|
||||||
bind C-o send-keys C-o
|
bind C-o send-keys C-o
|
||||||
bind r source-file ~/.tmux.conf
|
bind r source-file ~/.tmux.conf
|
||||||
|
@ -85,14 +86,5 @@ set -g set-titles on
|
||||||
set -g set-titles-string "#H - #T"
|
set -g set-titles-string "#H - #T"
|
||||||
|
|
||||||
new -s0 -n 1
|
new -s0 -n 1
|
||||||
new-window -n 2
|
|
||||||
new-window -n 3
|
|
||||||
new-window -n 4
|
|
||||||
new-window -n 5
|
|
||||||
new-window -n 6
|
|
||||||
new-window -n 7
|
|
||||||
new-window -n 8
|
|
||||||
new-window -n 9
|
|
||||||
new-window -n 0
|
|
||||||
|
|
||||||
# vim:set ft=tmux:
|
# vim:set ft=tmux:
|
||||||
|
|
|
@ -18,26 +18,27 @@ fi
|
||||||
|
|
||||||
fre --store_name "edit-history" --add "$_file"
|
fre --store_name "edit-history" --add "$_file"
|
||||||
|
|
||||||
(tmux select-window -t helix &&
|
tmux-shortcut 1 env \
|
||||||
tmux send-keys -t helix Escape &&
|
"AR=$AR" \
|
||||||
tmux send-keys -t helix ":open ${_file}" Enter) || tmux new-window -t 42 -n helix \
|
"AS=$AS" \
|
||||||
-e "AR=$AR" \
|
"BUILD_COMMAND=$BUILD_COMMAND" \
|
||||||
-e "AS=$AS" \
|
"CC=$CC" \
|
||||||
-e "BUILD_COMMAND=$BUILD_COMMAND" \
|
"CXX=$CXX" \
|
||||||
-e "CC=$CC" \
|
"GOFLAGS=$GOFLAGS" \
|
||||||
-e "CXX=$CXX" \
|
"GOPACKAGESDRIVER=$GOPACKAGESDRIVER" \
|
||||||
-e "GOFLAGS=$GOFLAGS" \
|
"LC_ALL=$LC_ALL" \
|
||||||
-e "GOPACKAGESDRIVER=$GOPACKAGESDRIVER" \
|
"LD=$LD" \
|
||||||
-e "LC_ALL=$LC_ALL" \
|
"NM=$NM" \
|
||||||
-e "LD=$LD" \
|
"NM=$NM" \
|
||||||
-e "NM=$NM" \
|
"OBJCOPY=$OBJCOPY" \
|
||||||
-e "NM=$NM" \
|
"OBJDUMP=$OBJDUMP" \
|
||||||
-e "OBJCOPY=$OBJCOPY" \
|
"PATH=$PATH" \
|
||||||
-e "OBJDUMP=$OBJDUMP" \
|
"RANLIB=$RANLIB" \
|
||||||
-e "PATH=$PATH" \
|
"READELF=$READELF" \
|
||||||
-e "RANLIB=$RANLIB" \
|
"RUST_SRC_PATH=$RUST_SRC_PATH" \
|
||||||
-e "READELF=$READELF" \
|
"SIZE=$SIZE" \
|
||||||
-e "RUST_SRC_PATH=$RUST_SRC_PATH" \
|
"STRIP=$STRIP" \
|
||||||
-e "SIZE=$SIZE" \
|
|
||||||
-e "STRIP=$STRIP" \
|
|
||||||
helix "${_file}"
|
helix "${_file}"
|
||||||
|
sleep 0.1
|
||||||
|
tmux send-keys Escape &&
|
||||||
|
tmux send-keys ":open ${_file}" Enter
|
||||||
|
|
20
bin/tmux-shortcut
Executable file
20
bin/tmux-shortcut
Executable file
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
nr="@app-${1}"
|
||||||
|
shift
|
||||||
|
|
||||||
|
pane="$(tmux show -vg ${nr} || true)"
|
||||||
|
if [[ -n "${pane}" ]] && tmux has-session -t "${pane}" ; then
|
||||||
|
if tmux list-panes -F "#{pane_id}" | grep "^${pane}\$" >>/dev/null ; then
|
||||||
|
# Pane is on this window. Focus it and exit.
|
||||||
|
exec tmux select-pane -t "${pane}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# App pane does not exist, so create a new window.
|
||||||
|
pane=$(tmux new-window -d -P -F '#{pane_id}' "$@")
|
||||||
|
tmux set -g "${nr}" "${pane}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Swap active pane for app
|
||||||
|
tmux swap-pane -s "${pane}"
|
Loading…
Reference in a new issue