zsh: cleanup

This commit is contained in:
Marco Thomas
2023-01-10 15:07:36 +01:00
parent 85a5af72de
commit e4ad267c4a

View File

@@ -94,29 +94,11 @@ export FZF_DEFAULT_OPTS='
--color=info:#5c6a72,prompt:#5c6a72,pointer:#5c6a72
--color=marker:#5c6a72,spinner:#5c6a72,header:#5c6a72'
## ripgrep-all
# needs https://github.com/phiresky/ripgrep-all
rga-fzf() {
RG_PREFIX="rga --files-with-matches"
local file
file="$(
FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \
fzf --sort --preview="[[ ! -z {} ]] && rga --pretty --context 5 {q} {}" \
--phony -q "$1" \
--bind "change:reload:$RG_PREFIX {q}" \
--preview-window="70%:wrap"
)" &&
echo "opening $file" &&
xdg-open "$file"
}
zle -N rga-fzf
bindkey '^S' "rga-fzf"
## fzf Bindings in zsh (C-r and C-f)
# c/p from ohmyzsh
if [[ -x $(which fzf 2> /dev/null) ]]
then
# The code at the top and the bottom of this file is the same as in completion.zsh.
# Refer to that file for explanation.
# some setup
if 'zmodload' 'zsh/parameter' 2>'/dev/null' && (( ${+options} )); then
__fzf_key_bindings_options="options=(${(j: :)${(kv)options[@]}})"
else
@@ -132,11 +114,9 @@ then
done
}
fi
'emulate' 'zsh' '-o' 'no_aliases'
{
[[ -o interactive ]] || return 0
# CTRL-F - Paste the selected file path(s) into the command line
@@ -201,7 +181,7 @@ then
eval $__fzf_key_bindings_options
'unset' '__fzf_key_bindings_options'
}
else
else # fzf is not installed
bindkey '^R' history-incremental-search-backward
fi