I am trying to implement a feature of opening files in vim using ranger in separate tmux pane. It works if define commands directly in .tmux.conf. But having much code there doesn't look good, so I am trying to move it into functions and source them in .bashrc, but this yelds 'tmux__ranger_to_vim' returned 127
. Why tmux run-shell
doesn't see functions defined in .bashrc
and is it possible to make them available for it?
.bashrc
function tmux__current_pane_has_process {
test -n "$1" || { echo "No process name" >&2; return 1; }
pattern='^[^TXZ ]+ +'"${1}"'$'
ps -o state= -o comm= | grep -iqE "$pattern"
}
function tmux__ranger_to_vim {
tmux__current_pane_has_process 'ranger' || return 0
tmux send-keys 'y'
sleep .01
tmux send-keys 'p'
tmux select-pane -L
tmux__current_pane_has_process 'n?vim' || return 0
tmux send-keys ':tabe ' C-r * C-m
}
.tmux.conf
bind-key t run-shell "tmux__ranger_to_vim"