-
Could the integration with fzf be implemented in this script? I would like a way to implement this function 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"
} into this script #!/usr/bin/env bash
# Store the STDOUT of fzf in a variable
selection=$(find -type d | fzf --multi --height=80% --border=sharp \
--preview='tree -C {}' --preview-window='45%,border-sharp' \
--prompt='Dirs > ' \
--bind='del:execute(rm -ri {+})' \
--bind='ctrl-p:toggle-preview' \
--bind='ctrl-d:change-prompt(Dirs > )' \
--bind='ctrl-d:+reload(find -type d)' \
--bind='ctrl-d:+change-preview(tree -C {})' \
--bind='ctrl-d:+refresh-preview' \
--bind='ctrl-f:change-prompt(Files > )' \
--bind='ctrl-f:+reload(find -type f)' \
--bind='ctrl-f:+change-preview(cat {})' \
--bind='ctrl-f:+refresh-preview' \
--bind='ctrl-a:select-all' \
--bind='ctrl-x:deselect-all' \
--header '
CTRL-D to display directories | CTRL-F to display files
CTRL-A to select all | CTRL-x to deselect all
ENTER to edit | DEL to delete
CTRL-P to toggle preview
'
)
# Determine what to do depending on the selection
if [ -d "$selection" ]; then
cd "$selection" || exit
else
eval "$EDITOR $selection"
fi maybe using an additional keybind like ctrl+g. I tried to figure out a way to do this but failed, can someone help me out please? |
Beta Was this translation helpful? Give feedback.
Answered by
amigthea
Jun 26, 2023
Replies: 1 comment
-
I came up with a working solution:
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
amigthea
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I came up with a working solution: