From c2dab181185101070b0ad6c33451f4e2f56a446a Mon Sep 17 00:00:00 2001 From: Robert Buonpastore Date: Sat, 12 Nov 2022 12:24:08 -0500 Subject: [PATCH] Add troubleshooting note for interaction with docker containers --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 76b963d..d25c974 100644 --- a/README.md +++ b/README.md @@ -332,6 +332,27 @@ detail. [tmate]: http://tmate.io/ +### Switching between host panes doesn't work when docker is running + +Replace the `is_vim` variable in your `~/.tmux.conf` file with: +```tmux +if-shell '[ -f /.dockerenv ]' \ + "is_vim=\"ps -o state=,comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'\"" + # Filter out docker instances of nvim from the host system to prevent + # host from thinking nvim is running in a pseudoterminal when its not. + "is_vim=\"ps -o state=,comm=,cgroup= -t '#{pane_tty}' \ + | grep -ivE '^.+ +.+ +.+\\/docker\\/.+$' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)? +'\"" +``` + +Details: The output of the ps command on the host system includes processes +running within containers, but containers have their own instances of +/dev/pts/\*. vim-tmux-navigator relies on /dev/pts/\* to determine if vim is +running, so if vim is running in say /dev/pts/ in a container and there is a +tmux pane (not running vim) in /dev/pts/ on the host system, then without +the patch above vim-tmux-navigator will think vim is running when its not. + ### It Still Doesn't Work!!! The tmux configuration uses an inlined grep pattern match to help determine if