replace awk with grep, change redirection in second command
This commit is contained in:
parent
f4d059ff78
commit
f4136d7a74
1 changed files with 8 additions and 7 deletions
15
rc/fzf.kak
15
rc/fzf.kak
|
@ -70,7 +70,7 @@ define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{
|
||||||
additional_flags=$3
|
additional_flags=$3
|
||||||
tmux_height=$kak_opt_fzf_tmux_height
|
tmux_height=$kak_opt_fzf_tmux_height
|
||||||
|
|
||||||
items_executable=$(echo $items_command | awk '{print $1}' | tr '(' ' ' | cut -d " " -f 2)
|
items_executable=$(echo $items_command | grep -o -E "[[:alpha:]]+" | head -1)
|
||||||
if [ -z $(command -v $items_executable) ]; then
|
if [ -z $(command -v $items_executable) ]; then
|
||||||
echo "fail %{'$items_executable' executable not found}"
|
echo "fail %{'$items_executable' executable not found}"
|
||||||
exit
|
exit
|
||||||
|
@ -79,7 +79,7 @@ define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{
|
||||||
tmp=$(mktemp $(eval echo ${TMPDIR:-/tmp}/kak-fzf.XXXXXX))
|
tmp=$(mktemp $(eval echo ${TMPDIR:-/tmp}/kak-fzf.XXXXXX))
|
||||||
exec=$(mktemp $(eval echo ${TMPDIR:-/tmp}/kak-exec.XXXXXX))
|
exec=$(mktemp $(eval echo ${TMPDIR:-/tmp}/kak-exec.XXXXXX))
|
||||||
|
|
||||||
if [ "$(echo $callback | awk '{print $1}')" = "edit" ] && [ $kak_opt_fzf_preview = "true" ]; then
|
if [ "$(echo $callback | grep -o -E '[[:alpha:]]+' | head -1)" = "edit" ] && [ $kak_opt_fzf_preview = "true" ]; then
|
||||||
case $kak_opt_fzf_highlighter in
|
case $kak_opt_fzf_highlighter in
|
||||||
bat)
|
bat)
|
||||||
highlighter="bat --color=always --style=header,grid,numbers {}" ;;
|
highlighter="bat --color=always --style=header,grid,numbers {}" ;;
|
||||||
|
@ -92,7 +92,7 @@ define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{
|
||||||
bat*|coderay*|highlight*|rougify*)
|
bat*|coderay*|highlight*|rougify*)
|
||||||
highlighter=$kak_opt_fzf_highlighter ;;
|
highlighter=$kak_opt_fzf_highlighter ;;
|
||||||
*)
|
*)
|
||||||
executable=$(echo $kak_opt_fzf_highlighter | awk '{print $1}'| tr '(' ' ' | cut -d " " -f 2)
|
executable=$(echo $kak_opt_fzf_highlighter | grep -o -E '[[:alpha:]]+' | head -1)
|
||||||
echo "echo -markup %{{Information}'$executable' highlighter is not supported by the script. fzf.kak may not work as you expect.}"
|
echo "echo -markup %{{Information}'$executable' highlighter is not supported by the script. fzf.kak may not work as you expect.}"
|
||||||
highlighter=$kak_opt_fzf_highlighter ;;
|
highlighter=$kak_opt_fzf_highlighter ;;
|
||||||
esac
|
esac
|
||||||
|
@ -108,10 +108,10 @@ define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{
|
||||||
if [ ! -z "${kak_client_env_TMUX}" ]; then
|
if [ ! -z "${kak_client_env_TMUX}" ]; then
|
||||||
cmd="$preview_pos $items_command | fzf-tmux -d $tmux_height --expect ctrl-q $additional_flags > $tmp"
|
cmd="$preview_pos $items_command | fzf-tmux -d $tmux_height --expect ctrl-q $additional_flags > $tmp"
|
||||||
elif [ ! -z "${kak_opt_termcmd}" ]; then
|
elif [ ! -z "${kak_opt_termcmd}" ]; then
|
||||||
tmp2=$(mktemp $(eval echo ${TMPDIR:-/tmp}/kak-tmp2.XXXXXX))
|
fzfcmd=$(mktemp $(eval echo ${TMPDIR:-/tmp}/kak-fzfcmd.XXXXXX))
|
||||||
chmod 755 $tmp2
|
chmod 755 $fzfcmd
|
||||||
echo "cd $PWD && $preview_pos $items_command | fzf --expect ctrl-q $additional_flags" > $tmp2
|
echo "cd $PWD && $preview_pos $items_command | fzf --expect ctrl-q $additional_flags > $tmp" > $fzfcmd
|
||||||
cmd="$kak_opt_termcmd \"sh -c $tmp2\" > $tmp"
|
cmd="$kak_opt_termcmd 'sh -c $fzfcmd'"
|
||||||
else
|
else
|
||||||
echo "fail termcmd option is not set"
|
echo "fail termcmd option is not set"
|
||||||
exit
|
exit
|
||||||
|
@ -151,6 +151,7 @@ define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{
|
||||||
fi
|
fi
|
||||||
rm $tmp
|
rm $tmp
|
||||||
rm $exec
|
rm $exec
|
||||||
|
[ -z "$fzfcmd" ] && rm $fzfcmd
|
||||||
) > /dev/null 2>&1 < /dev/null &
|
) > /dev/null 2>&1 < /dev/null &
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue