-
Notifications
You must be signed in to change notification settings - Fork 127
Home
Adelhard Krämer edited this page Apr 12, 2022
·
13 revisions
Here are some scripts people have built using fzy. Please feel free to add your own.
FILE=$(ag -l -g '' | fzy) && vim "$FILE"
This has to be a shell function (not script file) in order to use cd
fcd(){
cd "$(find -type d | fzy)"
}
Filter the directory to match the first keyword
f(){
cd "$(find -type d -iname "*$1*" | fzy)"
}
#!/bin/sh
GEM=$(bundle list | cut -f 4 -d' ' | fzy)
DESTINATION=$(bundle show $GEM)
tmux new-window -c "$DESTINATION" -n "$GEM"
alias fzyank='fzy | xclip'
Based on snippet from selecta's EXAMPLES.md
function insert-fzy-path-in-command-line() {
local selected_path
echo # Run fzy underneath the current prompt
selected_path=$(ag . -l -g '' | fzy) || return
LBUFFER="$LBUFFER${(q)selected_path} " # ${(q)VAR} shell-escapes the string
zle reset-prompt
}
zle -N insert-fzy-path-in-command-line
unsetopt flowcontrol # By default, ^S freezes terminal output, only needed if keybinding is ^S
bindkey "^S" "insert-fzy-path-in-command-line"
function history-fzy() {
local tac
if which tac > /dev/null; then
tac="tac"
else
tac="tail -r"
fi
BUFFER=$(history -n 1 | eval $tac | fzy --query "$LBUFFER")
CURSOR=$#BUFFER
zle reset-prompt
}
zle -N history-fzy
bindkey '^r' history-fzy