From be97b387ffa73487055095ca8e0762705bb2ac37 Mon Sep 17 00:00:00 2001 From: Till Höppner Date: Sun, 22 Apr 2018 11:09:28 +0200 Subject: Add fzf aliases --- conf.d/99-fzf.zsh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 conf.d/99-fzf.zsh diff --git a/conf.d/99-fzf.zsh b/conf.d/99-fzf.zsh new file mode 100644 index 0000000..5aaf3fa --- /dev/null +++ b/conf.d/99-fzf.zsh @@ -0,0 +1,28 @@ +# cf - fuzzy cd from anywhere +cf() { + local file + + # previously had "grep -z -vE '~$'" in the pipeline + file="$(locate -Ai -0 \* | fzf --read0)" + + if [[ -n $file ]] + then + if [[ -d $file ]] + then + cd -- $file + else + cd -- ${file:h} + fi + fi +} + +rf() { + rg --no-heading --no-line-number --color never . | fzf +} + +fh() { + print -z $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed 's/ *[0-9]* *//') +} + +# bindkey -s '^f' 'cf\n' +# bindkey -s '^h' 'fh\n' -- cgit v1.2.3