formatting & cleanup
This commit is contained in:
parent
1de1082a45
commit
7fef4973e6
8 changed files with 51 additions and 67 deletions
29
rc/fzf.kak
29
rc/fzf.kak
|
@ -139,16 +139,17 @@ fzf -params .. %{ evaluate-commands %sh{
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-kak-cmd) shift; kakoune_cmd="$1" ;;
|
(-kak-cmd) shift; kakoune_cmd="$1" ;;
|
||||||
-multiple-cmd) shift; multiple_cmd="$1" ;;
|
(-multiple-cmd) shift; multiple_cmd="$1" ;;
|
||||||
-items-cmd) shift; items_cmd="$1 |" ;;
|
(-items-cmd) shift; items_cmd="$1 |" ;;
|
||||||
-fzf-impl) shift; fzf_impl="$1" ;;
|
(-fzf-impl) shift; fzf_impl="$1" ;;
|
||||||
-fzf-args) shift; fzf_args="$1" ;;
|
(-fzf-args) shift; fzf_args="$1" ;;
|
||||||
-preview-cmd) shift; preview_cmd="$1" ;;
|
(-preview-cmd) shift; preview_cmd="$1" ;;
|
||||||
-preview) preview="true" ;;
|
(-preview) preview="true" ;;
|
||||||
-filter) shift; filter="| $1" ;;
|
(-filter) shift; filter="| $1" ;;
|
||||||
-post-action) shift; post_action="$1" ;;
|
(-post-action) shift; post_action="$1" ;;
|
||||||
esac; shift
|
esac
|
||||||
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
[ -z "$multiple_cmd" ] && multiple_cmd="$kakoune_cmd"
|
[ -z "$multiple_cmd" ] && multiple_cmd="$kakoune_cmd"
|
||||||
|
@ -157,11 +158,11 @@ fzf -params .. %{ evaluate-commands %sh{
|
||||||
# bake position option to define them at runtime
|
# bake position option to define them at runtime
|
||||||
[ -n "${kak_client_env_TMUX}" ] && tmux_height="${kak_opt_fzf_preview_tmux_height}"
|
[ -n "${kak_client_env_TMUX}" ] && tmux_height="${kak_opt_fzf_preview_tmux_height}"
|
||||||
case ${kak_opt_fzf_preview_pos} in
|
case ${kak_opt_fzf_preview_pos} in
|
||||||
(top|up) preview_position="pos=top:${kak_opt_fzf_preview_height};" ;;
|
(top|up) preview_position="pos=top:${kak_opt_fzf_preview_height};" ;;
|
||||||
(bottom|down) preview_position="pos=down:${kak_opt_fzf_preview_height};" ;;
|
(bottom|down) preview_position="pos=down:${kak_opt_fzf_preview_height};" ;;
|
||||||
(right) preview_position="pos=right:${kak_opt_fzf_preview_width};" ;;
|
(right) preview_position="pos=right:${kak_opt_fzf_preview_width};" ;;
|
||||||
(left) preview_position="pos=left:${kak_opt_fzf_preview_width};" ;;
|
(left) preview_position="pos=left:${kak_opt_fzf_preview_width};" ;;
|
||||||
(auto|*) 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};"
|
(auto|*) 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};"
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# handle preview if not defined explicitly with `-preview-cmd'
|
# handle preview if not defined explicitly with `-preview-cmd'
|
||||||
|
|
|
@ -25,10 +25,8 @@ define-command -hidden fzf-bzr %{ evaluate-commands %sh{
|
||||||
current_path=$(pwd)
|
current_path=$(pwd)
|
||||||
repo_root=$(bzr root)
|
repo_root=$(bzr root)
|
||||||
case $kak_opt_fzf_bzr_command in
|
case $kak_opt_fzf_bzr_command in
|
||||||
bzr)
|
(bzr) cmd="bzr ls -R --versioned -0" ;;
|
||||||
cmd="bzr ls -R --versioned -0" ;;
|
(bzr*) cmd=$kak_opt_fzf_bzr_command ;;
|
||||||
bzr*)
|
|
||||||
cmd=$kak_opt_fzf_bzr_command ;;
|
|
||||||
esac
|
esac
|
||||||
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
|
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
|
||||||
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags} -post-action %{cd $current_path}"
|
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags} -post-action %{cd $current_path}"
|
||||||
|
|
|
@ -25,10 +25,8 @@ define-command -override -hidden fzf-git %{ evaluate-commands %sh{
|
||||||
current_path=$(pwd)
|
current_path=$(pwd)
|
||||||
repo_root=$(git rev-parse --show-toplevel)
|
repo_root=$(git rev-parse --show-toplevel)
|
||||||
case $kak_opt_fzf_git_command in
|
case $kak_opt_fzf_git_command in
|
||||||
git)
|
(git) cmd="git ls-tree --full-tree --name-only -r HEAD" ;;
|
||||||
cmd="git ls-tree --full-tree --name-only -r HEAD" ;;
|
(git*) cmd=$kak_opt_fzf_git_command ;;
|
||||||
git*)
|
|
||||||
cmd=$kak_opt_fzf_git_command ;;
|
|
||||||
esac
|
esac
|
||||||
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
|
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
|
||||||
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags} -post-action %{cd $current_path}"
|
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags} -post-action %{cd $current_path}"
|
||||||
|
|
|
@ -25,10 +25,8 @@ define-command -hidden fzf-hg %{ evaluate-commands %sh{
|
||||||
current_path=$(pwd)
|
current_path=$(pwd)
|
||||||
repo_root=$(hg root)
|
repo_root=$(hg root)
|
||||||
case $kak_opt_fzf_hg_command in
|
case $kak_opt_fzf_hg_command in
|
||||||
hg)
|
(hg) cmd="hg locate -f -0 -I .hg locate -f -0 -I ." ;;
|
||||||
cmd="hg locate -f -0 -I .hg locate -f -0 -I ." ;;
|
(hg*) cmd=$kak_opt_fzf_hg_command ;;
|
||||||
hg*)
|
|
||||||
cmd=$kak_opt_fzf_hg_command ;;
|
|
||||||
esac
|
esac
|
||||||
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
|
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
|
||||||
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags} -post-action %{cd $current_path}"
|
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags} -post-action %{cd $current_path}"
|
||||||
|
|
|
@ -25,10 +25,8 @@ define-command -hidden fzf-svn %{ evaluate-commands %sh{
|
||||||
current_path=$(pwd)
|
current_path=$(pwd)
|
||||||
repo_root=$(svn info | awk -F': ' '/Working Copy Root Path: .*/ {print $2}')
|
repo_root=$(svn info | awk -F': ' '/Working Copy Root Path: .*/ {print $2}')
|
||||||
case $kak_opt_fzf_svn_command in
|
case $kak_opt_fzf_svn_command in
|
||||||
svn)
|
(svn) cmd="svn list -R $repo_root | grep -v '$/'" ;;
|
||||||
cmd="svn list -R $repo_root | grep -v '$/'" ;;
|
(svn*) cmd=$kak_opt_fzf_svn_command ;;
|
||||||
svn*)
|
|
||||||
cmd=$kak_opt_fzf_svn_command ;;
|
|
||||||
esac
|
esac
|
||||||
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
|
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
|
||||||
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags} -post-action %{cd $current_path}"
|
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags} -post-action %{cd $current_path}"
|
||||||
|
|
|
@ -37,12 +37,9 @@ define-command -hidden fzf-cd %{ evaluate-commands %sh{
|
||||||
tmux_height=$kak_opt_fzf_tmux_height
|
tmux_height=$kak_opt_fzf_tmux_height
|
||||||
printf '%s\n' "info -title %{fzf change directory} %{Change the server's working directory
|
printf '%s\n' "info -title %{fzf change directory} %{Change the server's working directory
|
||||||
current path: $(pwd)}"
|
current path: $(pwd)}"
|
||||||
|
|
||||||
case $kak_opt_fzf_cd_command in
|
case $kak_opt_fzf_cd_command in
|
||||||
find)
|
(find) items_command="(echo .. && find . \( -path '*/.svn*' -o -path '*/.git*' \) -prune -o -type d -print)" ;;
|
||||||
items_command="(echo .. && find . \( -path '*/.svn*' -o -path '*/.git*' \) -prune -o -type d -print)" ;;
|
(*) items_command=$kak_opt_fzf_cd_command ;;
|
||||||
*)
|
|
||||||
items_command=$kak_opt_fzf_cd_command ;;
|
|
||||||
esac
|
esac
|
||||||
if [ "$kak_opt_fzf_cd_preview" = "true" ]; then
|
if [ "$kak_opt_fzf_cd_preview" = "true" ]; then
|
||||||
preview_flag="-preview"
|
preview_flag="-preview"
|
||||||
|
|
|
@ -34,20 +34,14 @@ define-command -hidden fzf-file %{ evaluate-commands %sh{
|
||||||
kak_opt_fzf_file_command="find"
|
kak_opt_fzf_file_command="find"
|
||||||
fi
|
fi
|
||||||
case $kak_opt_fzf_file_command in
|
case $kak_opt_fzf_file_command in
|
||||||
find)
|
(find) cmd="find -L . -type f" ;;
|
||||||
cmd="find -L . -type f" ;;
|
(ag) cmd="ag -l -f --hidden --one-device . " ;;
|
||||||
ag)
|
(rg) cmd="rg -L --hidden --files" ;;
|
||||||
cmd="ag -l -f --hidden --one-device . " ;;
|
(fd) cmd="fd --type f --follow" ;;
|
||||||
rg)
|
(find*|ag*|rg*|fd*) cmd=$kak_opt_fzf_file_command ;;
|
||||||
cmd="rg -L --hidden --files" ;;
|
(*) items_executable=$(printf "%s\n" "$kak_opt_fzf_file_command" | grep -o -E "[[:alpha:]]+" | head -1)
|
||||||
fd)
|
printf "%s\n" "echo -markup '{Information}'Warning: '$executable'' is not supported by fzf.kak.'"
|
||||||
cmd="fd --type f --follow" ;;
|
cmd=$kak_opt_fzf_file_command ;;
|
||||||
find*|ag*|rg*|fd*)
|
|
||||||
cmd=$kak_opt_fzf_file_command ;;
|
|
||||||
*)
|
|
||||||
items_executable=$(printf "%s\n" "$kak_opt_fzf_file_command" | grep -o -E "[[:alpha:]]+" | head -1)
|
|
||||||
printf "%s\n" "echo -markup '{Information}'Warning: '$executable'' is not supported by fzf.kak.'"
|
|
||||||
cmd=$kak_opt_fzf_file_command ;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
cmd="$cmd 2>/dev/null"
|
cmd="$cmd 2>/dev/null"
|
||||||
|
|
|
@ -49,16 +49,16 @@ define-command -hidden fzf-save-path-as-project-no-prompt %{ evaluate-commands %
|
||||||
mkdir -p "${kak_opt_fzf_project_file%/*}"
|
mkdir -p "${kak_opt_fzf_project_file%/*}"
|
||||||
# portable version of `basename'
|
# portable version of `basename'
|
||||||
base() {
|
base() {
|
||||||
filename=$1
|
filename="$1"
|
||||||
case "$filename" in
|
case "$filename" in
|
||||||
*/*[!/]*)
|
(*/*[!/]*)
|
||||||
trail=${filename##*[!/]}
|
trail=${filename##*[!/]}
|
||||||
filename=${filename%%"$trail"}
|
filename=${filename%%"$trail"}
|
||||||
base=${filename##*/} ;;
|
base=${filename##*/} ;;
|
||||||
*[!/]*)
|
(*[!/]*)
|
||||||
trail=${filename##*[!/]}
|
trail=${filename##*[!/]}
|
||||||
base=${filename%%"$trail"} ;;
|
base=${filename%%"$trail"} ;;
|
||||||
*) base="/" ;;
|
(*) base="/" ;;
|
||||||
esac
|
esac
|
||||||
printf "%s\n" "${base}"
|
printf "%s\n" "${base}"
|
||||||
}
|
}
|
||||||
|
@ -84,16 +84,16 @@ fzf-add-project -file-completion -params 1..2 %{ evaluate-commands %sh{
|
||||||
fi
|
fi
|
||||||
# portable version of `basename'
|
# portable version of `basename'
|
||||||
base() {
|
base() {
|
||||||
filename=$1
|
filename="$1"
|
||||||
case "$filename" in
|
case "$filename" in
|
||||||
*/*[!/]*)
|
(*/*[!/]*)
|
||||||
trail=${filename##*[!/]}
|
trail=${filename##*[!/]}
|
||||||
filename=${filename%%"$trail"}
|
filename=${filename%%"$trail"}
|
||||||
base=${filename##*/} ;;
|
base=${filename##*/} ;;
|
||||||
*[!/]*)
|
(*[!/]*)
|
||||||
trail=${filename##*[!/]}
|
trail=${filename##*[!/]}
|
||||||
base=${filename%%"$trail"} ;;
|
base=${filename%%"$trail"} ;;
|
||||||
*) base="/" ;;
|
(*) base="/" ;;
|
||||||
esac
|
esac
|
||||||
printf "%s\n" "${base}"
|
printf "%s\n" "${base}"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue