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 ;; cmd=$kak_opt_fzf_bzr_command ;;
esac esac
[ ! -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"
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 ;; cmd=$kak_opt_fzf_git_command ;;
esac esac
[ ! -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"
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 ;; cmd=$kak_opt_fzf_hg_command ;;
esac esac
[ ! -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"
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 ;; cmd=$kak_opt_fzf_svn_command ;;
esac esac
[ ! -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"
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 ;; cmd=$kak_opt_fzf_cd_command ;;
esac 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 " str fzf_tag_ansibleplaybook "
<a-p>: plays" <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 case $kak_opt_filetype in
ada) 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" 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" [ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
echo "set-option window ctagsfiles %{$path/${kak_opt_tagfile:-tags}}" 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>' map global fzf -docstring "open file" 'f' '<esc>: fzf-file<ret>'
define-command -hidden fzf-file %{ evaluate-commands %sh{ 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'''" echo "echo -markup '{Information}''$kak_opt_fzf_file_command'' is not installed. Falling back to ''find'''"
kak_opt_fzf_file_command="find" kak_opt_fzf_file_command="find"
fi fi
@ -56,6 +56,6 @@ define-command -hidden fzf-file %{ evaluate-commands %sh{
<c-w>: open file in new window $additional_keybindings" <c-w>: open file in new window $additional_keybindings"
echo "info -title '$title' '$message'" echo "info -title '$title' '$message'"
[ ! -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"
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) buffer_content=$(mktemp ${TMPDIR:-/tmp}/kak-curr-buff.XXXXXX)
echo "execute-keys %{%<a-|>cat<space>><space>$buffer_content<ret>;}" echo "execute-keys %{%<a-|>cat<space>><space>$buffer_content<ret>;}"
echo "execute-keys $line g $char l" 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%%" \ Default value: 60%%" \
str fzf_preview_height '60%' str fzf_preview_height '60%'
# Commands
define-command -docstring "Enter fzf-mode. define-command -docstring "Enter fzf-mode.
fzf-mode contains mnemonic key bindings for every fzf.kak command 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 fi
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))
if [ "$(echo $callback | grep -o -E '[[:alpha:]]+' | head -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
@ -138,19 +136,22 @@ define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{
wincmd= ;; wincmd= ;;
esac esac
callback="$wincmd$callback" 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 else
echo "echo evaluate-commands -client $kak_client \"$callback\" | kak -p $kak_session" > $exec kakoune_command() {
echo "echo evaluate-commands -client $kak_client \"fzf-cd\" | kak -p $kak_session" >> $exec echo "evaluate-commands -client $kak_client '$callback' '$1'"
echo "evaluate-commands -client $kak_client fzf-cd"
}
fi fi
chmod 755 $exec while read item; do
while read file; do kakoune_command "$item" | kak -p $kak_session
$exec "\'$file'"
done done
) < $tmp ) < $tmp
fi fi
rm $tmp rm $tmp
rm $exec rm $kakoune_command
[ -z "$fzfcmd" ] && rm $fzfcmd [ -z "$fzfcmd" ] && rm $fzfcmd
) > /dev/null 2>&1 < /dev/null & ) > /dev/null 2>&1 < /dev/null &
}} }}