Created
November 30, 2023 23:05
-
-
Save dehidehidehi/ff0c506079344698402e2bae32886633 to your computer and use it in GitHub Desktop.
Enable navigating between Tmux panes within zsh using vim-like navigation bindings.
This file contains 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
# Unbind ZSH keys occupying VIM-like navigation shortcuts. | |
bindkey -r '^H' # Unbind Ctrl-h | |
bindkey -r '^J' # Unbind Ctrl-j | |
bindkey -r '^K' # Unbind Ctrl-k | |
bindkey -r '^L' # Unbind Ctrl-l | |
# Define functions calling Tmux pane navigation. | |
function tmux-navigate-left() { | |
tmux select-pane -L | |
} | |
function tmux-navigate-down() { | |
tmux select-pane -D | |
} | |
function tmux-navigate-up() { | |
tmux select-pane -U | |
} | |
function tmux-navigate-right() { | |
tmux select-pane -R | |
} | |
# Tell Zsh to use these functions as widgets | |
zle -N tmux-navigate-left | |
zle -N tmux-navigate-down | |
zle -N tmux-navigate-up | |
zle -N tmux-navigate-right | |
# Bind CTRL+hjkl to navigate panes | |
bindkey '^H' tmux-navigate-left | |
bindkey '^J' tmux-navigate-down | |
bindkey '^K' tmux-navigate-up | |
bindkey '^L' tmux-navigate-right |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment