1
0
Fork 0

refactor main script to use function instead of chmodding file. Rework other files accordingly

This commit is contained in:
Andrey Orst 2018-11-22 08:54:42 +03:00
parent ffd12b303e
commit d8ad0f7e00
9 changed files with 20 additions and 19 deletions

View file

@ -27,6 +27,6 @@ define-command -hidden fzf-bzr %{ evaluate-commands %sh{
cmd=$kak_opt_fzf_bzr_command ;;
esac
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
echo "fzf %{edit \$1} %{$cmd} %{-m --expect ctrl-w $additional_flags}"
echo "fzf %{edit} %{$cmd} %{-m --expect ctrl-w $additional_flags}"
}}

View file

@ -27,6 +27,6 @@ define-command -hidden fzf-git %{ evaluate-commands %sh{
cmd=$kak_opt_fzf_git_command ;;
esac
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
echo "fzf %{edit \$1} %{$cmd} %{-m --expect ctrl-w $additional_flags}"
echo "fzf %{edit} %{$cmd} %{-m --expect ctrl-w $additional_flags}"
}}

View file

@ -27,6 +27,6 @@ define-command -hidden fzf-hg %{ evaluate-commands %sh{
cmd=$kak_opt_fzf_hg_command ;;
esac
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
echo "fzf %{edit \$1} %{$cmd} %{-m --expect ctrl-w $additional_flags}"
echo "fzf %{edit} %{$cmd} %{-m --expect ctrl-w $additional_flags}"
}}

View file

@ -27,6 +27,6 @@ define-command -hidden fzf-svn %{ evaluate-commands %sh{
cmd=$kak_opt_fzf_svn_command ;;
esac
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
echo "fzf %{edit \$1} %{$cmd} %{-m --expect ctrl-w $additional_flags}"
echo "fzf %{edit} %{$cmd} %{-m --expect ctrl-w $additional_flags}"
}}

View file

@ -26,6 +26,6 @@ define-command -hidden fzf-cd %{ evaluate-commands %sh{
*)
cmd=$kak_opt_fzf_cd_command ;;
esac
echo "fzf %{change-directory \$1} %{$cmd}"
echo "fzf %{change-directory} %{$cmd}"
}}

View file

@ -885,7 +885,7 @@ declare-option -hidden -docstring "A set of mappings for AnsiblePlaybook filetyp
str fzf_tag_ansibleplaybook "
<a-p>: plays"
define-command -hidden fzf-tag -params ..1 %{ evaluate-commands %sh{
define-command -hidden fzf-tag -params ..2 %{ evaluate-commands %sh{
case $kak_opt_filetype in
ada)
additional_keybindings="--expect ctrl-alt-p --expect alt-p --expect ctrl-alt-t --expect alt-t --expect ctrl-alt-u --expect alt-u --expect alt-c --expect alt-l --expect ctrl-alt-v --expect alt-v --expect alt-f --expect alt-n --expect alt-x --expect ctrl-alt-r --expect alt-r --expect ctrl-alt-k --expect alt-k --expect ctrl-alt-o --expect alt-o --expect ctrl-alt-e --expect alt-e --expect alt-b --expect alt-i --expect alt-a --expect alt-y --expect ctrl-alt-s"
@ -1234,5 +1234,5 @@ Additional filters for $kak_opt_filetype filetype: $additional_message"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
echo "set-option window ctagsfiles %{$path/${kak_opt_tagfile:-tags}}"
echo "fzf %{ctags-search \$1} %{$cmd | awk '!a[\$0]++'} %{--expect ctrl-w $additional_flags $additional_keybindings}"
echo "fzf %{ctags-search} %{$cmd | awk '!a[\$0]++'} %{--expect ctrl-w $additional_flags $additional_keybindings}"
}}

View file

@ -27,7 +27,7 @@ str fzf_file_command "find"
map global fzf -docstring "open file" 'f' '<esc>: fzf-file<ret>'
define-command -hidden fzf-file %{ evaluate-commands %sh{
if [ -z $(command -v $kak_opt_fzf_file_command) ]; then
if [ -z "$(command -v $kak_opt_fzf_file_command)" ]; then
echo "echo -markup '{Information}''$kak_opt_fzf_file_command'' is not installed. Falling back to ''find'''"
kak_opt_fzf_file_command="find"
fi
@ -56,6 +56,6 @@ define-command -hidden fzf-file %{ evaluate-commands %sh{
<c-w>: open file in new window $additional_keybindings"
echo "info -title '$title' '$message'"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
echo "fzf %{edit \$1} %{$cmd} %{-m --expect ctrl-w $additional_flags}"
echo "fzf %{edit} %{$cmd} %{-m --expect ctrl-w $additional_flags}"
}}

View file

@ -19,6 +19,6 @@ define-command -hidden fzf-buffer-search %{ evaluate-commands %sh{
buffer_content=$(mktemp ${TMPDIR:-/tmp}/kak-curr-buff.XXXXXX)
echo "execute-keys %{%<a-|>cat<space>><space>$buffer_content<ret>;}"
echo "execute-keys $line g $char l"
echo "fzf %{execute-keys \$1 gx} %{(nl -b a -n ln $buffer_content} %{--reverse | cut -f 1; rm $buffer_content)}"
echo "fzf %{execute-keys} %{(nl -b a -n ln $buffer_content} %{--reverse | cut -f 1; rm $buffer_content; echo 'gx')}"
}}

View file

@ -55,7 +55,6 @@ declare-option -docstring "height of preview window.
Default value: 60%%" \
str fzf_preview_height '60%'
# Commands
define-command -docstring "Enter fzf-mode.
fzf-mode contains mnemonic key bindings for every fzf.kak command
@ -77,7 +76,6 @@ define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{
fi
tmp=$(mktemp $(eval echo ${TMPDIR:-/tmp}/kak-fzf.XXXXXX))
exec=$(mktemp $(eval echo ${TMPDIR:-/tmp}/kak-exec.XXXXXX))
if [ "$(echo $callback | grep -o -E '[[:alpha:]]+' | head -1)" = "edit" ] && [ $kak_opt_fzf_preview = "true" ]; then
case $kak_opt_fzf_highlighter in
@ -138,19 +136,22 @@ define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{
wincmd= ;;
esac
callback="$wincmd$callback"
echo "echo evaluate-commands -client $kak_client \"$callback\" | kak -p $kak_session" > $exec
kakoune_command () {
echo "evaluate-commands -client $kak_client '$callback' '$1'"
}
else
echo "echo evaluate-commands -client $kak_client \"$callback\" | kak -p $kak_session" > $exec
echo "echo evaluate-commands -client $kak_client \"fzf-cd\" | kak -p $kak_session" >> $exec
kakoune_command() {
echo "evaluate-commands -client $kak_client '$callback' '$1'"
echo "evaluate-commands -client $kak_client fzf-cd"
}
fi
chmod 755 $exec
while read file; do
$exec "\'$file'"
while read item; do
kakoune_command "$item" | kak -p $kak_session
done
) < $tmp
fi
rm $tmp
rm $exec
rm $kakoune_command
[ -z "$fzfcmd" ] && rm $fzfcmd
) > /dev/null 2>&1 < /dev/null &
}}