- Fix: proper escaping of kak_{session, client}
This commit is contained in:
parent
494d046fb2
commit
e5742fd6b1
|
@ -4,31 +4,31 @@
|
||||||
define-command ranger-open-on-edit-directory \
|
define-command ranger-open-on-edit-directory \
|
||||||
-docstring 'Start the ranger file system explorer when trying to edit a directory' %{
|
-docstring 'Start the ranger file system explorer when trying to edit a directory' %{
|
||||||
hook global RuntimeError "\d+:\d+: '\w+' (.*): is a directory" %{ %sh{
|
hook global RuntimeError "\d+:\d+: '\w+' (.*): is a directory" %{ %sh{
|
||||||
directory=$kak_hook_param_capture_1
|
directory=$kak_hook_param_capture_1
|
||||||
echo ranger $directory
|
echo ranger $directory
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
define-command \
|
define-command \
|
||||||
-params .. -file-completion \
|
-params .. -file-completion \
|
||||||
-docstring %{ranger [<arguments>]: open the file system explorer to select buffers to open
|
-docstring %{ranger [<arguments>]: open the file system explorer to select buffers to open
|
||||||
All the optional arguments are forwarded to the ranger utility} \
|
All the optional arguments are forwarded to the ranger utility} \
|
||||||
ranger %{ %sh{
|
ranger %{ %sh{
|
||||||
if [ -n "$TMUX" ]; then
|
if [ -n "${TMUX}" ]; then
|
||||||
tmux split-window -h \
|
tmux split-window -h \
|
||||||
ranger $@ --cmd " \
|
ranger $@ --cmd " \
|
||||||
map <return> eval \
|
map <return> eval \
|
||||||
fm.execute_console('shell \
|
fm.execute_console('shell \
|
||||||
echo evaluate-commands -client $kak_client edit {file} | \
|
echo evaluate-commands -client ' + ranger.ext.shell_escape.shell_escape('$kak_client') + ' edit {file} | \
|
||||||
kak -p $kak_session; \
|
kak -p '.format(file=fm.thisfile.path) + ranger.ext.shell_escape.shell_escape('$kak_session') + '; \
|
||||||
tmux select-pane -t $kak_client_env_TMUX_PANE'.format(file=fm.thisfile.path)) \
|
tmux select-pane -t $kak_client_env_TMUX_PANE') \
|
||||||
if fm.thisfile.is_file else fm.execute_console('move right=1')"
|
if fm.thisfile.is_file else fm.execute_console('move right=1')"
|
||||||
|
|
||||||
elif [ -n "${STY}" ]; then
|
elif [ -n "${STY}" ]; then
|
||||||
|
|
||||||
script="/tmp/kak-ranger-${kak_client}-${kak_session}.sh"
|
script="/tmp/kak-ranger-${kak_client}-${kak_session}.sh"
|
||||||
selections="/tmp/kak-ranger-${kak_client}-${kak_session}.txt"
|
selections="/tmp/kak-ranger-${kak_client}-${kak_session}.txt"
|
||||||
cat > "$script" << EOF
|
cat > "$script" << EOF
|
||||||
#! /usr/bin/env sh
|
#! /usr/bin/env sh
|
||||||
cd "$PWD"
|
cd "$PWD"
|
||||||
ranger --choosefiles="$selections" $@
|
ranger --choosefiles="$selections" $@
|
||||||
|
@ -46,14 +46,14 @@ EOF
|
||||||
"screen sh '$script'" \
|
"screen sh '$script'" \
|
||||||
< "/dev/$tty"
|
< "/dev/$tty"
|
||||||
|
|
||||||
elif [ -n "$WINDOWID" ]; then
|
elif [ -n "$WINDOWID" ]; then
|
||||||
setsid $kak_opt_termcmd " \
|
setsid $kak_opt_termcmd " \
|
||||||
ranger $@ --cmd "'"'" \
|
ranger $@ --cmd "'"'" \
|
||||||
map <return> eval \
|
map <return> eval \
|
||||||
fm.execute_console('shell \
|
fm.execute_console('shell \
|
||||||
echo evaluate-commands -client $kak_client edit {file} | \
|
echo evaluate-commands -client ' + ranger.ext.shell_escape.shell_escape('$kak_client') + ' edit {file} | \
|
||||||
kak -p $kak_session; \
|
kak -p '.format(file=fm.thisfile.path) + ranger.ext.shell_escape.shell_escape('$kak_session') + '; \
|
||||||
xdotool windowactivate $kak_client_env_WINDOWID'.format(file=fm.thisfile.path)) \
|
xdotool windowactivate $kak_client_env_WINDOWID') \
|
||||||
if fm.thisfile.is_file else fm.execute_console('move right=1')"'"' < /dev/null > /dev/null 2>&1 &
|
if fm.thisfile.is_file else fm.execute_console('move right=1')"'"' < /dev/null > /dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user