2019-06-17 06:47:21 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-06-17 21:13:55 +00:00
|
|
|
sk-with-binds() {
|
|
|
|
sk --ansi --color=dark --border \
|
|
|
|
--preview-window=":hidden" \
|
|
|
|
--preview='head -$LINES {}' \
|
|
|
|
--bind='ctrl-y:execute-silent(echo {} | xclip -selection "clipboard"),ctrl-x:toggle-preview' \
|
|
|
|
--header='[ctrl-y]:yank current item [ctrl-x]:toggle preview window' \
|
|
|
|
"$@"
|
|
|
|
}
|
|
|
|
|
2019-06-17 06:47:21 +00:00
|
|
|
# check for existence of fuzzy finders. If found, substitute fzf with it.
|
|
|
|
# order is skim > fzy > fzf > nothing
|
|
|
|
if type sk >/dev/null 2>&1; then
|
|
|
|
alias fzf=sk
|
|
|
|
elif type fzy >/dev/null 2>&1; then
|
2019-06-17 16:30:19 +00:00
|
|
|
echo "[WARNING]: fzy found as fuzzy finder - install sk to use full script functionality"
|
2019-06-17 06:47:21 +00:00
|
|
|
alias fzf=fzy
|
|
|
|
elif type fzf >/dev/null 2>&1; then
|
2019-06-17 16:30:19 +00:00
|
|
|
echo "[WARNING]: fzf found as fuzzy finder - install sk to use full script functionality"
|
2019-06-17 06:47:21 +00:00
|
|
|
alias fzf=fzf
|
|
|
|
else
|
2019-06-17 16:30:19 +00:00
|
|
|
echo "[WARNING]: No fuzzy finder found - install sk to enable functionality"
|
2019-06-17 06:47:21 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# check for existence of greplikes. If found, substitute fzf with it.
|
|
|
|
# order is skim > fzy > fzf > nothing
|
|
|
|
if type rg >/dev/null 2>&1; then
|
|
|
|
alias rg=rg
|
|
|
|
elif type ag >/dev/null 2>&1; then
|
|
|
|
alias rg=ag
|
|
|
|
elif type ack >/dev/null 2>&1; then
|
|
|
|
alias rg=ack
|
|
|
|
else
|
|
|
|
echo "[WARNING]: No grep-like found - install rg/ag/ack to enable functionality"
|
|
|
|
fi
|
2019-06-17 16:01:23 +00:00
|
|
|
|
|
|
|
# set up fuzzy file and directory search
|
2019-06-17 16:30:19 +00:00
|
|
|
# TODO still uses rifle (from ranger fm) - decide whether to keep it or not
|
2019-06-17 16:01:23 +00:00
|
|
|
alias f="fzf -c 'find . -type f' --preview='head -$LINES {}' | xargs rifle"
|
|
|
|
alias F="fzf -c 'find ~ -type f' --preview='head -$LINES {}' | xargs rifle"
|
|
|
|
|
2019-06-17 20:33:13 +00:00
|
|
|
alias d="fzf -c 'find . -type d' --preview='ls --color='always' {}' | cd"
|
|
|
|
alias D="fzf -c 'find ~ -type d' --preview='ls --color='always' {}' --color=dark --ansi | cd"
|
2019-06-17 16:30:19 +00:00
|
|
|
|
|
|
|
# Display fuzzy-searchable history
|
|
|
|
alias zhfind="history | fzf --tac --height 20"
|