Navigate seamlessly between system windows, vim splits and tmux panes by only using awesomewm navigation keybindings.
Go to file
BZ f54a4d502c apparently it does work for xterm (#1) 2021-03-18 21:05:08 +01:00
plugin vim option to enable keybinds in insert mode 2021-03-09 14:05:27 +01:00
README.md apparently it does work for xterm (#1) 2021-03-18 21:05:08 +01:00
dynamictitles.bash provide minimal shell configurations 2021-02-18 20:52:05 +01:00
dynamictitles.zsh provide minimal shell configurations 2021-02-18 20:52:05 +01:00
init.lua use local capi instead of global 2021-03-09 12:14:14 +01:00
tmux_focus.sh initial commit 2020-03-22 23:19:52 +01:00

README.md

AwesomeWM - Vim - Tmux Navigator

awesomewm-vim-tmux-navigator lets you navigate seamlessly between system windows, vim splits and tmux panes using a consisent set of hotkeys. Every vim split and tmux pane is treated like a standalone system window and you can forget your (n)vim/tmux specific navigation hotkeys. It also works for complex scenarios like embedded vim splits inside tmux panes.

The plugin is based on christoomey/vim-tmux-navigator and fogine/vim-i3wm-tmux-navigator.

How does it work

The plugin sends the correct keypresses based on the focused appplication. In order to differentitate between (n)vim and tmux clients, the title of your terminal is changed. Therefore your shell/terminal stack has to support dynamic titles (see Troubleshooting section).

Installation

AwesomeWM

Clone the repo.

git clone https://github.com/intrntbrn/awesomewm-vim-tmux-navigator ~/.config/awesome/awesomewm-vim-tmux-navigator

It's not recommended to change the path since it's hardcoded in other configuration files.

Add your preferred navigation (focus) keybinds to rc.lua (e.g. Mod4+arrow or Mod4+hjkl)

require("awesomewm-vim-tmux-navigator"){
        up    = {"Up", "k"},
        down  = {"Down", "j"},
        left  = {"Left", "h"},
        right = {"Right", "l"},
    }

Remove conflicting keybinds from your rc.lua.

Vim

Plug 'intrntbrn/awesomewm-vim-tmux-navigator'

Remove similar plugins (like christoomey/vim-tmux-navigator).

Options:

let g:tmux_navigator_insert_mode = 1 to enable navigator keybinds in insert mode

Tmux

Add the following to your tmux.conf.

# Set Terminal titles where possible
set-option -g set-titles on
set-option -g set-titles-string '#S: #W - TMUX'

# Smart pane switching with awareness of vim splits and system windows
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
	| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind -n C-Left if-shell "$is_vim" "send-keys C-h" "run-shell 'sh ~/.config/awesome/awesomewm-vim-tmux-navigator/tmux_focus.sh left'"
bind -n C-Down if-shell "$is_vim" "send-keys C-j" "run-shell 'sh ~/.config/awesome/awesomewm-vim-tmux-navigator/tmux_focus.sh down'"
bind -n C-Up if-shell "$is_vim" "send-keys C-k" "run-shell 'sh ~/.config/awesome/awesomewm-vim-tmux-navigator/tmux_focus.sh up'"
bind -n C-Right if-shell "$is_vim" "send-keys C-l" "run-shell 'sh ~/.config/awesome/awesomewm-vim-tmux-navigator/tmux_focus.sh right'"

Troubleshooting

After a correct installation the title of a tmux session should end with "- TMUX" and "- VIM" or "- NVIM" for vim or nvim sessions respectively. Check the title of the terminal client in your wm tasklist or by using xprop (title is property WM_NAME).

In case your title does not change, your terminal and/or shell do not support dynamic titles or are not configured.

Try minimal configurations provided for zsh or bash:

echo "source ~/.config/awesome/awesomewm-vim-tmux-navigator/dynamictitles.zsh" >> ~/.zshrc

or

echo "source ~/.config/awesome/awesomewm-vim-tmux-navigator/dynamictitles.bash" >> ~/.bashrc

I recommended to use alacritty with zsh.