From 1652f92b720ebc88fed5b4f2cf8c9fe77612628e Mon Sep 17 00:00:00 2001 From: Andrey Orst Date: Thu, 22 Nov 2018 15:36:11 +0300 Subject: [PATCH] use print instead of echo --- rc/fzf-modules/VCS/fzf-bzr.kak | 2 +- rc/fzf-modules/VCS/fzf-git.kak | 2 +- rc/fzf-modules/VCS/fzf-hg.kak | 2 +- rc/fzf-modules/VCS/fzf-svn.kak | 4 ++-- rc/fzf-modules/fzf-ctags.kak | 12 ++++++------ rc/fzf-modules/fzf-file.kak | 10 +++++----- rc/fzf-modules/fzf-search.kak | 13 +++++-------- rc/fzf-modules/fzf-vcs.kak | 8 ++++---- 8 files changed, 25 insertions(+), 28 deletions(-) diff --git a/rc/fzf-modules/VCS/fzf-bzr.kak b/rc/fzf-modules/VCS/fzf-bzr.kak index ecdee58..e2d7e7b 100644 --- a/rc/fzf-modules/VCS/fzf-bzr.kak +++ b/rc/fzf-modules/VCS/fzf-bzr.kak @@ -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} %{$cmd} %{-m --expect ctrl-w $additional_flags}" + printf "%s\n" "fzf %{edit} %{$cmd} %{-m --expect ctrl-w $additional_flags}" }} diff --git a/rc/fzf-modules/VCS/fzf-git.kak b/rc/fzf-modules/VCS/fzf-git.kak index dada37a..58215c3 100644 --- a/rc/fzf-modules/VCS/fzf-git.kak +++ b/rc/fzf-modules/VCS/fzf-git.kak @@ -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} %{$cmd} %{-m --expect ctrl-w $additional_flags}" + printf "%s\n" "fzf %{edit} %{$cmd} %{-m --expect ctrl-w $additional_flags}" }} diff --git a/rc/fzf-modules/VCS/fzf-hg.kak b/rc/fzf-modules/VCS/fzf-hg.kak index 6a49de1..9912f12 100644 --- a/rc/fzf-modules/VCS/fzf-hg.kak +++ b/rc/fzf-modules/VCS/fzf-hg.kak @@ -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} %{$cmd} %{-m --expect ctrl-w $additional_flags}" + printf "%s\n" "fzf %{edit} %{$cmd} %{-m --expect ctrl-w $additional_flags}" }} diff --git a/rc/fzf-modules/VCS/fzf-svn.kak b/rc/fzf-modules/VCS/fzf-svn.kak index 0a439de..ee89fc2 100644 --- a/rc/fzf-modules/VCS/fzf-svn.kak +++ b/rc/fzf-modules/VCS/fzf-svn.kak @@ -2,7 +2,7 @@ # │ Author: ║ File: │ # │ Andrey Orst ║ fzf-svn.kak │ # ╞═════════════╩═════════════════════════╡ -# │ Submodule for SVN support for fzf.kak │ +# │ Submodule for Svn support for fzf.kak │ # ╞═══════════════════════════════════════╡ # │ GitHub.com/andreyorst/fzf.kak │ # ╰───────────────────────────────────────╯ @@ -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} %{$cmd} %{-m --expect ctrl-w $additional_flags}" + printf "%s\n" "fzf %{edit} %{$cmd} %{-m --expect ctrl-w $additional_flags}" }} diff --git a/rc/fzf-modules/fzf-ctags.kak b/rc/fzf-modules/fzf-ctags.kak index 1b72470..fd38d1d 100644 --- a/rc/fzf-modules/fzf-ctags.kak +++ b/rc/fzf-modules/fzf-ctags.kak @@ -1206,14 +1206,14 @@ define-command -hidden fzf-tag -params ..2 %{ evaluate-commands %sh{ fi done if [ "$path" = "$HOME" ] && [ ! -e "./${kak_opt_tagfile:-tags}" ]; then - echo "echo -markup %{{Information}No '${kak_opt_tagfile:-tags}' found}" + printf "%s\n" "echo -markup %{{Information}No '${kak_opt_tagfile:-tags}' found}" exit elif [ "$path" = "$HOME" ] && [ -e "./${kak_opt_tagfile:-tags}" ]; then - echo "echo -markup %{{Information}'${kak_opt_tagfile:-tags}' found at $HOME. Check if it is right tag file}" + printf "%s\n" "echo -markup %{{Information}'${kak_opt_tagfile:-tags}' found at $HOME. Check if it is right tag file}" fi if [ ! -z "$1" ]; then - mode=$(echo "$additional_message" | grep ":" | awk '{$1=""; print}' | sed "s/\(.*\)/:\1/") + mode=$(printf "%s\n" "$additional_message" | grep ":" | awk '{$1=""; print}' | sed "s/\(.*\)/:\1/") cmd="cd $path; readtags -Q '(eq? \$kind \"$1\")' -l | cut -f1" else cmd="cd $path; readtags -l | cut -f1" @@ -1230,9 +1230,9 @@ define-command -hidden fzf-tag -params ..2 %{ evaluate-commands %sh{ Additional filters for $kak_opt_filetype filetype: $additional_message" - echo "info -title 'fzf tag$mode' '$message'" + printf "%s\n" "info -title 'fzf tag$mode' '$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} %{$cmd | awk '!a[\$0]++'} %{--expect ctrl-w $additional_flags $additional_keybindings}" + printf "%s\n" "set-option window ctagsfiles %{$path/${kak_opt_tagfile:-tags}}" + printf "%s\n" "fzf %{ctags-search} %{$cmd | awk '!a[\$0]++'} %{--expect ctrl-w $additional_flags $additional_keybindings}" }} diff --git a/rc/fzf-modules/fzf-file.kak b/rc/fzf-modules/fzf-file.kak index 748e047..f260688 100644 --- a/rc/fzf-modules/fzf-file.kak +++ b/rc/fzf-modules/fzf-file.kak @@ -28,7 +28,7 @@ map global fzf -docstring "open file" 'f' ': fzf-file' define-command -hidden fzf-file %{ evaluate-commands %sh{ 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'''" + printf "%s\n" "echo -markup '{Information}''$kak_opt_fzf_file_command'' is not installed. Falling back to ''find'''" kak_opt_fzf_file_command="find" fi case $kak_opt_fzf_file_command in @@ -43,8 +43,8 @@ define-command -hidden fzf-file %{ evaluate-commands %sh{ find*|ag*|rg*|fd*) cmd=$kak_opt_fzf_file_command ;; *) - executable=$(echo $kak_opt_fzf_file_command | awk '{print $1'}| tr '(' ' ' | cut -d " " -f 2) - echo "echo -markup '{Information}''$executable'' is not supported by the script. fzf.kak may not work as you expect.'" + items_executable=$(printf "%s\n" "$kak_opt_fzf_file_command" | grep -o -E "[[:alpha:]]+" | head -1) + printf "%s\n" "echo -markup '{Information}''$executable'' is not supported by the script. fzf.kak may not work as you expect.'" cmd=$kak_opt_fzf_file_command ;; esac title="fzf file" @@ -54,8 +54,8 @@ define-command -hidden fzf-file %{ evaluate-commands %sh{ message="Open single or multiple files. : open file in new buffer. : open file in new window $additional_keybindings" - echo "info -title '$title' '$message'" + printf "%s\n" "info -title '$title' '$message'" [ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s" - echo "fzf %{edit} %{$cmd} %{-m --expect ctrl-w $additional_flags}" + printf "%s\n" "fzf %{edit} %{$cmd} %{-m --expect ctrl-w $additional_flags}" }} diff --git a/rc/fzf-modules/fzf-search.kak b/rc/fzf-modules/fzf-search.kak index bf8e5cb..c954a16 100644 --- a/rc/fzf-modules/fzf-search.kak +++ b/rc/fzf-modules/fzf-search.kak @@ -8,17 +8,14 @@ # │ GitHub.com/andreyorst/fzf.kak │ # ╰──────────────────────────────────────╯ -map global fzf -docstring "search in buffer" 's' ': fzf-buffer-search' +map global fzf -docstring "search in buffer" 's' ': fzf-buffer-search' define-command -hidden fzf-buffer-search %{ evaluate-commands %sh{ title="fzf buffer search" message="Search buffer with fzf, and jump to result location" - echo "info -title '$title' '$message'" - line=$kak_cursor_line - char=$(expr $kak_cursor_char_column - 1) - buffer_content=$(mktemp ${TMPDIR:-/tmp}/kak-curr-buff.XXXXXX) - echo "execute-keys %{%cat>$buffer_content;}" - echo "execute-keys $line g $char l" - echo "fzf %{execute-keys} %{(nl -b a -n ln $buffer_content} %{--reverse | cut -f 1; rm $buffer_content; echo 'gx')}" + printf "%s\n" "info -title '$title' '$message'" + buffer_content=$(mktemp ${TMPDIR:-/tmp}/fzf-buff-${kak_buffile##*/}.XXXXXX) + printf "%s\n" "execute-keys -draft %{%cat>$buffer_content;}" + printf "%s\n" "fzf %{execute-keys} %{(nl -b a -n ln $buffer_content} %{--reverse | cut -f 1; rm $buffer_content; echo 'gx')}" }} diff --git a/rc/fzf-modules/fzf-vcs.kak b/rc/fzf-modules/fzf-vcs.kak index 6806f9e..8dc4eac 100644 --- a/rc/fzf-modules/fzf-vcs.kak +++ b/rc/fzf-modules/fzf-vcs.kak @@ -38,7 +38,7 @@ bzr status" eval $cmd >/dev/null 2>&1 res=$? if [ "$res" = "0" ]; then - vcs=$(echo $cmd | awk '{print $1}') + vcs=$(printf "%s\n" "$cmd" | awk '{print $1}') title="fzf $vcs" [ ! -z "${kak_client_env_TMUX}" ] && additional_keybindings=" : open file in horizontal split @@ -46,11 +46,11 @@ bzr status" message="Open single or multiple files from git tree. : open file in new buffer. : open file in new window $additional_keybindings" - echo "info -title '$title' '$message'" - echo "fzf-$vcs" + printf "%s\n" "info -title %{$title} %{$message}" + printf "%s\n" "fzf-$vcs" exit fi done - echo "echo -markup '{Information}No VCS found in current folder'" + printf "%s\n" "echo -markup '{Information}No VCS found in current folder'" }}