tmux.nvim icon indicating copy to clipboard operation
tmux.nvim copied to clipboard

Window switching stops working in python virtual environment

Open aareman opened this issue 3 years ago • 1 comments

Hi @aserowy thanks for this great plugin!

I'm running into some unexpected behavior currently. If I have a tmux session and open nvim, <c-j> et all. works. However, if I first run poetry shell it no longer works. The mapping is set, but now nothing happens.

It must have something to do with poetry since if I activate the environment manually with source .venv/bin/activate it does work.

Any ideas? I believe poetry shell spawns a subshell, (though $TMUX remains set) and that might have something to do with it.

aareman avatar Aug 16 '22 13:08 aareman

Hmmm, sounds weirdo. I am not working with python anymore (stopped at 2.7.^^). Maybe file a pr, if you'll find whats causing it.

Regards Alexander

aserowy avatar Sep 05 '22 08:09 aserowy

i had the same problem. maybe there is an error in the line: is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

duongapollo avatar Oct 07 '22 05:10 duongapollo

i found a solution here: https://github.com/christoomey/vim-tmux-navigator/issues/295

this work for me:

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)?$'"

duongapollo avatar Oct 07 '22 05:10 duongapollo

@duongapollo

Heho,

nice finding. Can you push a pr, thus we can get the fix upstream?

Regards Alexander

aserowy avatar Oct 10 '22 05:10 aserowy

@aserowy i have updated the "is_vim" script in ~/.tmux.conf from:

is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

to

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)?$'"

it worked well in nested shell (in this case is pipenv shell)

duongapollo avatar Oct 13 '22 01:10 duongapollo