commit 111430d83d70eb28102f3f4ba61b54407032d0dc
parent 12145dff28af5842f1941eb766062ac3fa5779a1
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Thu, 10 May 2018 09:42:44 -0400
Use FZF for switching windows (M-Space) and sessions (M-Q)
Diffstat:
M | links/.tmux.conf | | | 97 | +++++++++++++++++++++++++++++++++++++++++-------------------------------------- |
1 file changed, 50 insertions(+), 47 deletions(-)
diff --git a/links/.tmux.conf b/links/.tmux.conf
@@ -1,10 +1,10 @@
### GENERAL
set-option -g prefix C-a # Set prefix to <C-a>
-bind-key a send-prefix # Send <C-a> with <C-a>a
+bind a send-prefix # Send <C-a> with <C-a>a
bind R source-file ~/.tmux.conf \; display "~/.tmux.conf reloaded"
-bind-key -n M-R source-file ~/.tmux.conf \; display "~/.tmux.conf reloaded"
+bind -n M-R source-file ~/.tmux.conf \; display "~/.tmux.conf reloaded"
set -g history-limit 10000 # lines to keep in hisoty
set-option -g display-panes-time 3000 # Timeout for pane-numbering in ms
@@ -94,44 +94,47 @@ bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-l) || tmux select-pane -R"
-bind-key C-s last-window # go to last window with <C-a><C-s>
-bind-key C-a last-pane # go to last pane with <C-a><C-a>
-bind-key -r n next-window # next window with <C-a>n
+bind C-s last-window # go to last window with <C-a><C-s>
+bind C-a last-pane # go to last pane with <C-a><C-a>
+bind -r n next-window # next window with <C-a>n
+
+bind -n -r M-n next-window # next window with <M-n>
+bind -n -r M-b previous-window # previous window with <M-n>
+bind -n C-Space run-shell "tmux list-windows -F \"##I:##W\" | fzf-tmux | cut -d \":\" -f 1 | xargs tmux select-window -t"
+bind -n C-Q run-shell "tmux list-sessions -F \"##S\" | fzf-tmux | xargs tmux switch -t"
-#bind-key -n -r M-k next-window # next window with <M-n>
-#bind-key -n -r M-j previous-window # previous window with <M-n>
#### LAYOUT CHANGING BINDINGS
# create panes in same directory
-bind-key '"' split-window -c "#{pane_current_path}"
-bind-key '%' split-window -h -c "#{pane_current_path}"
-
-bind-key -n M-k split-window -b -c "#{pane_current_path}" # new split up
-bind-key -n M-j split-window -c "#{pane_current_path}" # new split down
-bind-key -n M-l split-window -h -c "#{pane_current_path}" # new split right
-bind-key -n M-h split-window -b -h -c "#{pane_current_path}" # new split left
-bind-key C-k split-window -b -c "#{pane_current_path}" # new split up
-bind-key C-j split-window -c "#{pane_current_path}" # new split down
-bind-key C-l split-window -h -c "#{pane_current_path}" # new split right
-bind-key C-h split-window -b -h -c "#{pane_current_path}" # new split left
+bind '"' split-window -c "#{pane_current_path}"
+bind '%' split-window -h -c "#{pane_current_path}"
+
+bind -n M-k split-window -b -c "#{pane_current_path}" # new split up
+bind -n M-j split-window -c "#{pane_current_path}" # new split down
+bind -n M-l split-window -h -c "#{pane_current_path}" # new split right
+bind -n M-h split-window -b -h -c "#{pane_current_path}" # new split left
+bind C-k split-window -b -c "#{pane_current_path}" # new split up
+bind C-j split-window -c "#{pane_current_path}" # new split down
+bind C-l split-window -h -c "#{pane_current_path}" # new split right
+bind C-h split-window -b -h -c "#{pane_current_path}" # new split left
bind -r z resize-pane -Z # toggle pane zoom with <C-a>z
bind -r y next-layout # cycle to next pane layout with <C-a>y
bind -r Y previous-layout # cycle to previous pane layout with <C-a>Y
bind -r r rotate-window # rotate panes with <C-a>r
-bind-key -n M-z resize-pane -Z # toggle pane zoom with <M-z>
-bind-key -n -r M-y next-layout # cycle to next pane layout with <M-y>
-bind-key -n -r M-Y previous-layout # cycle to previous pane layout with <M-Y>
-bind-key -n -r M-r rotate-window # rotate panes with <M-r>
+bind -n M-z resize-pane -Z # toggle pane zoom with <M-z>
+bind -n -r M-y next-layout # cycle to next pane layout with <M-y>
+bind -n -r M-Y previous-layout # cycle to previous pane layout with <M-Y>
+bind -n -r M-r rotate-window # rotate panes with <M-r>
bind -r Left swap-window -t -1 # Swap window left
bind -r Right swap-window -t +1 # Swap window right
-bind-key -n -r M-B swap-window -t -1 # Swap window left
-bind-key -n -r M-N swap-window -t +1 # Swap window right
+bind -n -r M-B swap-window -t -1 # Swap window left
+bind -n -r M-N swap-window -t +1 # Swap window right
#### CLIPBOARD
@@ -141,8 +144,8 @@ bind -n M-Space copy-mode # enter copy mode with <M-Space>
bind -T copy-mode-vi v send -X begin-selection # start "visual" with v
# Copy (yank) with y
-if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "DISPLAY=:0 xclip -i -sel clipboard"'
-if-shell 'uname | grep -qi Darwin' 'bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"'
+if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "DISPLAY=:0 xclip -i -sel clipboard"'
+if-shell 'uname | grep -qi Darwin' 'bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"'
# Paste with C-a p or M-p
if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind p run "DISPLAY=:0 xclip -o | tmux load-buffer - ; tmux paste-buffer"'
@@ -153,35 +156,35 @@ if-shell 'uname | grep -qi Darwin' 'bind -n M-p run "pbpaste | tmux load-buffer
#### LAUNCH PROCESSES
# use urlview to follow URLs in current pane
-bind-key u capture-pane -J \; \
+bind u capture-pane -J \; \
save-buffer "/tmp/active_tmux_buffer" \; \
delete-buffer \; \
split-window -l 10 "urlview '/tmp/active_tmux_buffer' && rm /tmp/active_tmux_buffer"
# Launch offlineimap in inactive splits
-bind-key o split-window -p 25 '$SHELL -c "offlineimap -qf INBOX"' \; select-pane -l
-bind-key O split-window -p 25 '$SHELL -c "offlineimap"' \; select-pane -l
+bind o split-window -p 25 '$SHELL -c "offlineimap -qf INBOX"' \; select-pane -l
+bind O split-window -p 25 '$SHELL -c "offlineimap"' \; select-pane -l
# Use nested bindings (<C-a>l) for grouping process launch bindings
-bind-key -n C-M-m new-window -n mutt "mutt"
-bind-key -n C-M-v new-window -n vim "vim"
-bind-key -n C-M-r new-window -n rss "feednix"
-bind-key -n C-M-w new-window -n weather \
+bind -n C-M-m new-window -n mutt "mutt"
+bind -n C-M-v new-window -n vim "vim"
+bind -n C-M-r new-window -n rss "feednix"
+bind -n C-M-w new-window -n weather \
"curl 'wttr.in/?m'; echo -e '\nPress <enter> to quit'; read -n 1 -s"
-#bind-key C-M-s split-window -l 2 \; send-keys "susan "
-#bind-key C-M-h split-window -l 8 "htop"
+#bind C-M-s split-window -l 2 \; send-keys "susan "
+#bind C-M-h split-window -l 8 "htop"
# Open new window and resize status accordingly (should be a hook instead)
-#bind-key Enter new-window
-#bind-key Enter new-window \
+#bind Enter new-window
+#bind Enter new-window \
#"tmux set status-right-length `echo $(tput cols)/2|bc|tr -d '\n'`; zsh"
-bind-key Enter new-window "$SHELL"
-bind-key -n M-Enter new-window \
+bind Enter new-window "$SHELL"
+bind -n M-Enter new-window \
"tmux set status-right-length `echo $(tput cols)/2|bc|tr -d '\n'`; zsh"
# Use nested bindings (<C-a>m) for grouping music-control bindings
bind m switchc -Tmpd
-bind-key -n M-m switchc -Tmpd
+bind -n M-m switchc -Tmpd
bind -Tmpd v new-window -n vimpc "vimpc"
bind -Tmpd p display "#(mpc toggle | tr '\n' ' ')"
bind -Tmpd s display "#(mpc stop | tr '\n' ' ')"
@@ -190,12 +193,12 @@ bind -Tmpd b display "#(mpc prev | tr '\n' ' ')"
bind -Tmpd r display "#(mpc clear && mpc ls | mpc add && mpc random on && mpc play | tr '\n' ' ')"
#bind -Tmpd r new-window -n mpc "mpc clear && mpc ls | mpc add && mpc shuffle && mpc play"
-bind-key -n C-M-p display "#(mpc toggle | tr '\n' ' ')"
-bind-key -n C-M-s display "#(mpc stop | tr '\n' ' ')"
-bind-key -n C-M-n display "#(mpc next | tr '\n' ' ')"
-bind-key -n C-M-b display "#(mpc prev | tr '\n' ' ')"
-#bind-key -n C-M-r display "#(mpc clear && mpc ls | mpc add && mpc random on && mpc play | tr '\n' ' ')"
-bind-key -n C-M-a split-window -p 50 "source ~/code/fzf-mpd/fzf-mpd.zsh fzf && fm"
+bind -n C-M-p display "#(mpc toggle | tr '\n' ' ')"
+bind -n C-M-s display "#(mpc stop | tr '\n' ' ')"
+bind -n C-M-n display "#(mpc next | tr '\n' ' ')"
+bind -n C-M-b display "#(mpc prev | tr '\n' ' ')"
+#bind -n C-M-r display "#(mpc clear && mpc ls | mpc add && mpc random on && mpc play | tr '\n' ' ')"
+bind -n C-M-a split-window -p 50 "source ~/code/fzf-mpd/fzf-mpd.zsh fzf && fm"
# Use alternate prefix (C-b) for grouping music-control bindings
#bind -n C-b switchc -Tmoreprefix
@@ -206,4 +209,4 @@ bind-key -n C-M-a split-window -p 50 "source ~/code/fzf-mpd/fzf-mpd.zsh fzf && f
#bind -n -Tmoreprefix b new-window -n mpc "mpc prev"
# fzf-locate from entire file system and insert result in current pane (Alt-`)
-bind-key -n 'M-`' run "tmux split-window -p 40 'tmux send-keys -t #{pane_id} \"$(locate / | fzf -m | paste -sd\\ -)\"'"
+bind -n 'M-`' run "tmux split-window -p 40 'tmux send-keys -t #{pane_id} \"$(locate / | fzf -m | paste -sd\\ -)\"'"