summaryrefslogtreecommitdiff
path: root/conf.d/99-fzf.zsh
blob: 5aaf3fac476537a973ae3ac60e60a9b4e95442f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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'