Skip to content

Commit

Permalink
home: tmux-vim pane navigator works with poetry shell
Browse files Browse the repository at this point in the history
  • Loading branch information
adfaure committed Jul 16, 2024
1 parent c102395 commit 22cbbae
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions homes/modules/vim-tmux-panes/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@ in {
programs.tmux.extraConfig = ''
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
# is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
# | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
# https://github.com/christoomey/vim-tmux-navigator/issues/295#issuecomment-1369954705
# Enable tmux pan in subshell (such as poetry shell)
is_vim="children=(); i=0; pids=( $(ps -o pid= -t '#{pane_tty}') ); \
while read -r c p; do [[ -n c && c -ne p && p -ne 0 ]] && children[p]+=\" $\{c\}\"; done <<< \"$(ps -Ao pid=,ppid=)\"; \
while (( $\{#pids[@]\} > i )); do pid=$\{pids[i++]\}; pids+=( $\{children[pid]-\} ); done; \
ps -o state=,comm= -p \"$\{pids[@]\}\" | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
Expand Down

0 comments on commit 22cbbae

Please sign in to comment.