Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by

Hello again,

I am stuck with this:
Default mapping to s calls :shell command and that's fine.

nnoremap s :shell<cr>

I'd like to make it a bit smarter so that if running from under tmux, it starts shell in a new pane below. The approach looks reasonable:

    nnoremap s :if  $TMUX  != ''  
\| !tmux splitw -v -p20<cr>
\| :shell<cr>

and indeed it creates a new pane with shell when I am under tmux.
However otherwise it shows no shell anymore. It shows nothing at all.
What could be a reason and how to make it work usual, non-tmux way when there's no tmux behind? I guess i am somehow wrong with syntax, but no clue.

1 Answer

+1 vote

I've managed to get it work by refactoring of tmux pane creation into separate command:

command! tpane :!tmux splitw -v -p20

and then using that command in conditional block:

nnoremap s :if  $TMUX  != ''
                \| :tpane
                \| :shell

That's one way of doing this, another one is to use :execute command. There are more commands like :! (which don't end at |) where this is needed and they are listed here along with :execute workaround.

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here is acceptable, but this is not a perfect place for them.

Support Ukraine