Replies: 1 comment
-
Here's my #!/usr/bin/env bash
export FRUITS="$(printf '%s\n' apples oranges strawberries)"
change_fruits()
{
if [[ $FZF_KEY == ctrl-r ]]; then
read -e -p "$1 -> " newfruits
if [[ "$newfruits" ]] && [[ "$1" != "$newfruits" ]]; then
NEW_FRUITS="$(echo "$OLD_FRUITS" | sed "s/$1/$newfruits/")"
NEW_FRUITS_POS="$(echo "$NEW_FRUITS" | sed -n "/$newfruits/=")"
fzf_loop "$NEW_FRUITS" "$NEW_FRUITS_POS"
else
fzf_loop "$OLD_FRUITS" "$2"
fi
fi
}
export -f change_fruits
fzf_loop()
{
export OLD_FRUITS="$1"
echo "$1" |\
fzf \
--ghost "Do you like fruits?" \
--bind "result:pos($2)" \
--bind 'ctrl-r:become(change_fruits {} $FZF_POS)'
}
export -f fzf_loop
fzf_loop "$FRUITS" NOTE. Thanks for the interesting quiz. 😄 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Can someone provide a simple example on how to select an entry and rename it, reloading the list afterwards? e.g.
Ctrl-r
onoranges
entry, prompt to rename, enterpears
, and reload list.printf %s\n apples oranges strawberries | fzf
I am not sure where to go from
--bind 'ctrl-r:
--I know bash hasread
...Much appreciated.
Beta Was this translation helpful? Give feedback.
All reactions