2016-08-30 13:20:12 +02:00
|
|
|
# http://ranger.nongnu.org
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-11-03 08:34:41 +01:00
|
|
|
define-command ranger-open-on-edit-directory \
|
2016-10-11 09:03:41 +02:00
|
|
|
-docstring 'Start the ranger file system explorer when trying to edit a directory' %{
|
2016-09-28 20:34:16 +02:00
|
|
|
hook global RuntimeError "\d+:\d+: '\w+' (.*): is a directory" %{ %sh{
|
2017-04-01 22:46:31 +02:00
|
|
|
directory=$kak_hook_param_capture_1
|
2016-09-28 20:34:16 +02:00
|
|
|
echo ranger $directory
|
|
|
|
}}
|
|
|
|
}
|
2016-08-30 13:20:12 +02:00
|
|
|
|
2017-11-03 08:34:41 +01:00
|
|
|
define-command \
|
2016-10-11 09:03:41 +02:00
|
|
|
-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 13:20:12 +02:00
|
|
|
if [ -n "$TMUX" ]; then
|
2016-09-26 11:51:53 +02:00
|
|
|
tmux split-window -h \
|
|
|
|
ranger $@ --cmd " \
|
|
|
|
map <return> eval \
|
|
|
|
fm.execute_console('shell \
|
2017-11-03 09:09:45 +01:00
|
|
|
echo evaluate-commands -client $kak_client edit {file} | \
|
2016-09-26 11:51:53 +02:00
|
|
|
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 13:20:12 +02:00
|
|
|
elif [ -n "$WINDOWID" ]; then
|
2016-09-26 11:51:53 +02:00
|
|
|
setsid $kak_opt_termcmd " \
|
|
|
|
ranger $@ --cmd "'"'" \
|
|
|
|
map <return> eval \
|
|
|
|
fm.execute_console('shell \
|
2017-11-03 09:09:45 +01:00
|
|
|
echo evaluate-commands -client $kak_client edit {file} | \
|
2016-09-26 11:51:53 +02:00
|
|
|
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 13:20:12 +02:00
|
|
|
fi
|
|
|
|
}}
|