2016-08-30 14:20:12 +03:00
|
|
|
# http://ranger.nongnu.org
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2016-09-28 21:34:16 +03:00
|
|
|
def ranger-open-on-edit-directory \
|
2016-10-11 10:03:41 +03:00
|
|
|
-docstring 'Start the ranger file system explorer when trying to edit a directory' %{
|
2016-09-28 21:34:16 +03:00
|
|
|
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
|
|
|
|
}}
|
|
|
|
}
|
2016-08-30 14:20:12 +03:00
|
|
|
|
2016-10-11 10:03:41 +03:00
|
|
|
def \
|
|
|
|
-params .. -file-completion \
|
|
|
|
-docstring %{ranger [<arguments>]: open the file system explorer to select buffers to open
|
|
|
|
All the optional arguments are forwarded to the ranger utility} \
|
|
|
|
ranger %{ %sh{
|
2016-08-30 14:20:12 +03:00
|
|
|
if [ -n "$TMUX" ]; then
|
2016-09-26 12:51:53 +03:00
|
|
|
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')"
|
2016-08-30 14:20:12 +03:00
|
|
|
elif [ -n "$WINDOWID" ]; then
|
2016-09-26 12:51:53 +03:00
|
|
|
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 &
|
2016-08-30 14:20:12 +03:00
|
|
|
fi
|
|
|
|
}}
|