kakoune/rc/extra/ranger.kak
Maxime Coste 098c94b878 Do not automatically enable ranger on directory open errors
Use an explicit command that does that 'ranger-open-on-edit-directory'
and remove the file_manager option that is not needed anymore.
2016-09-28 19:34:29 +01:00

35 lines
1.4 KiB
Plaintext

# http://ranger.nongnu.org
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
def ranger-open-on-edit-directory \
-docstring 'fallback on ranger when trying to open a directory' %{
hook global RuntimeError "\d+:\d+: '\w+' (.*): is a directory" %{ %sh{
directory=$(expr $kak_hook_param : "[0-9]*:[0-9]*: '[a-z]*' \\(.*\\): is a directory")
echo ranger $directory
}}
}
def ranger -docstring 'ranger file manager' \
-params .. \
-file-completion %{ %sh{
if [ -n "$TMUX" ]; then
tmux split-window -h \
ranger $@ --cmd " \
map <return> eval \
fm.execute_console('shell \
echo eval -client $kak_client edit {file} | \
kak -p $kak_session; \
tmux select-pane -t $kak_client_env_TMUX_PANE'.format(file=fm.thisfile.path)) \
if fm.thisfile.is_file else fm.execute_console('move right=1')"
elif [ -n "$WINDOWID" ]; then
setsid $kak_opt_termcmd " \
ranger $@ --cmd "'"'" \
map <return> eval \
fm.execute_console('shell \
echo eval -client $kak_client edit {file} | \
kak -p $kak_session; \
xdotool windowactivate $kak_client_env_WINDOWID'.format(file=fm.thisfile.path)) \
if fm.thisfile.is_file else fm.execute_console('move right=1')"'"' < /dev/null > /dev/null 2>&1 &
fi
}}