reorganisation
This commit is contained in:
parent
ab8a2808bb
commit
06eee481fb
2 changed files with 17 additions and 20 deletions
|
@ -39,12 +39,12 @@ define-command -hidden fzf-sk-interactive-grep %{ evaluate-commands %sh{
|
||||||
printf "%s\n" "info -title '${title}' '${message}${tmux_keybindings}'"
|
printf "%s\n" "info -title '${title}' '${message}${tmux_keybindings}'"
|
||||||
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
|
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
|
||||||
impl=$kak_opt_fzf_implementation
|
impl=$kak_opt_fzf_implementation
|
||||||
printf "%s\n" "set-option global fzf_implementation \"sk -i -c '$kak_opt_fzf_sk_grep_command {}'\"
|
printf "%s\n" "set-option global fzf_implementation %{sk -i -c '$kak_opt_fzf_sk_grep_command {}'}
|
||||||
fzf -kak-cmd %{fzf-sk-grep-handler} -items-cmd %{echo >/dev/null 2>&1} -fzf-args %{--expect ctrl-w $additional_flags}
|
fzf -kak-cmd %{fzf-sk-grep-handler} -items-cmd %{echo >/dev/null 2>&1} -fzf-args %{--expect ctrl-w $additional_flags}
|
||||||
set-option global fzf_implementation $impl"
|
set-option global fzf_implementation %{${impl}}"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
define-command fzf-sk-grep-handler -params 1 %{ evaluate-commands %sh{
|
define-command -hidden fzf-sk-grep-handler -params 1 %{ evaluate-commands %sh{
|
||||||
printf "%s\n" "$1" | awk '{
|
printf "%s\n" "$1" | awk '{
|
||||||
file = $0; sub(/:.*/, "", file); gsub("&", "&&", file);
|
file = $0; sub(/:.*/, "", file); gsub("&", "&&", file);
|
||||||
line = $0; sub(/[^:]+:/, "", line); sub(/:.*/, "", line)
|
line = $0; sub(/[^:]+:/, "", line); sub(/:.*/, "", line)
|
||||||
|
|
31
rc/fzf.kak
31
rc/fzf.kak
|
@ -119,14 +119,14 @@ fzf -shell-script-candidates %{echo "-kak-cmd\n-items-cmd\n-fzf-args\n-post-acti
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$preview" = "true" ]; then
|
if [ "${preview}" = "true" ]; then
|
||||||
if [ -n "${kak_client_env_TMUX}" ]; then
|
if [ -n "${kak_client_env_TMUX}" ]; then
|
||||||
[ -z "${kakoune_cmd##edit*}" ] && tmux_height="$kak_opt_fzf_file_preview_tmux_height"
|
[ -z "${kakoune_cmd##edit*}" ] && tmux_height="${kak_opt_fzf_file_preview_tmux_height}"
|
||||||
preview_position="pos=right:${kak_opt_fzf_preview_width};"
|
preview_position="pos=right:${kak_opt_fzf_preview_width};"
|
||||||
else
|
else
|
||||||
preview_position="sleep 0.1; [ \$(tput cols) -gt \$(expr \$(tput lines) \* 2) ] && pos=right:${kak_opt_fzf_preview_width} || pos=top:${kak_opt_fzf_preview_height};"
|
preview_position="sleep 0.1; [ \$(tput cols) -gt \$(expr \$(tput lines) \* 2) ] && pos=right:${kak_opt_fzf_preview_width} || pos=top:${kak_opt_fzf_preview_height};"
|
||||||
fi
|
fi
|
||||||
if [ ${kak_opt_fzf_preview} = "true" ] && [ -z "$preview_cmd" ]; then
|
if [ ${kak_opt_fzf_preview} = "true" ] && [ -z "${preview_cmd}" ]; then
|
||||||
case ${kak_opt_fzf_highlight_cmd} in
|
case ${kak_opt_fzf_highlight_cmd} in
|
||||||
bat) highlight_cmd="bat --color=always --style=plain {}" ;;
|
bat) highlight_cmd="bat --color=always --style=plain {}" ;;
|
||||||
coderay) highlight_cmd="coderay {}" ;;
|
coderay) highlight_cmd="coderay {}" ;;
|
||||||
|
@ -145,7 +145,7 @@ fzf -shell-script-candidates %{echo "-kak-cmd\n-items-cmd\n-fzf-args\n-post-acti
|
||||||
chmod 755 ${fzfcmd}
|
chmod 755 ${fzfcmd}
|
||||||
|
|
||||||
if [ -n "${kak_client_env_TMUX}" ]; then
|
if [ -n "${kak_client_env_TMUX}" ]; then
|
||||||
[ -z "$tmux_height" ] && tmux_height=$kak_opt_fzf_tmux_height
|
[ -z "${tmux_height}" ] && tmux_height=${kak_opt_fzf_tmux_height}
|
||||||
[ -n "${tmux_height%%*%}" ] && measure="-l" || measure="-p"
|
[ -n "${tmux_height%%*%}" ] && measure="-l" || measure="-p"
|
||||||
cmd="nop %sh{ command tmux split-window ${measure} ${tmux_height%%%*} 'sh -c ${fzfcmd}' }"
|
cmd="nop %sh{ command tmux split-window ${measure} ${tmux_height%%%*} 'sh -c ${fzfcmd}' }"
|
||||||
else
|
else
|
||||||
|
@ -154,31 +154,28 @@ fzf -shell-script-candidates %{echo "-kak-cmd\n-items-cmd\n-fzf-args\n-post-acti
|
||||||
|
|
||||||
(
|
(
|
||||||
printf "%s\n" "${cmd}" | kak -p ${kak_session}
|
printf "%s\n" "${cmd}" | kak -p ${kak_session}
|
||||||
while [ -e $fzfcmd ]; do
|
while [ -e ${fzfcmd} ]; do
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
done
|
done
|
||||||
if [ -s $result ]; then
|
if [ -s ${result} ]; then
|
||||||
(
|
(
|
||||||
read action
|
read action
|
||||||
case $action in
|
case ${action} in
|
||||||
ctrl-w) wincmd="fzf-window" ;;
|
ctrl-w) wincmd="fzf-window" ;;
|
||||||
ctrl-s) wincmd="fzf-vertical" ;;
|
ctrl-s) wincmd="fzf-vertical" ;;
|
||||||
ctrl-v) wincmd="fzf-horizontal" ;;
|
ctrl-v) wincmd="fzf-horizontal" ;;
|
||||||
*)
|
*)
|
||||||
if [ -n "$action" ]; then
|
if [ -n "${action}" ]; then
|
||||||
printf "%s\n" "evaluate-commands -client $kak_client '$kakoune_cmd' '$action'" | kak -p $kak_session
|
printf "%s\n" "evaluate-commands -client ${kak_client} '${kakoune_cmd}' '${action}'" | kak -p ${kak_session}
|
||||||
[ -n "$post_action" ] && printf "%s\n" "evaluate-commands -client $kak_client $post_action" | kak -p $kak_session
|
[ -n "${post_action}" ] && printf "%s\n" "evaluate-commands -client ${kak_client} ${post_action}" | kak -p ${kak_session}
|
||||||
fi ;;
|
fi ;;
|
||||||
esac
|
esac
|
||||||
kakoune_command() {
|
|
||||||
printf "%s\n" "evaluate-commands -client $kak_client $wincmd %{$kakoune_cmd %{$1}}"
|
|
||||||
[ -n "$post_action" ] && printf "%s\n" "evaluate-commands -client $kak_client $post_action"
|
|
||||||
}
|
|
||||||
while read item; do
|
while read item; do
|
||||||
kakoune_command "$item" | kak -p $kak_session
|
printf "%s\n" "evaluate-commands -client ${kak_client} ${wincmd} %{${kakoune_cmd} %{${item}}}" | kak -p ${kak_session}
|
||||||
|
[ -n "${post_action}" ] && printf "%s\n" "evaluate-commands -client ${kak_client} ${post_action}" | kak -p ${kak_session}
|
||||||
done
|
done
|
||||||
) < $result
|
) < ${result}
|
||||||
fi
|
fi
|
||||||
rm $fzf_tmp
|
rm ${fzf_tmp}
|
||||||
) > /dev/null 2>&1 < /dev/null &
|
) > /dev/null 2>&1 < /dev/null &
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Reference in a new issue