aboutsummaryrefslogtreecommitdiff
path: root/config/zsh/plugins/fzf-cd.zsh
blob: f1897c5ca3d2668d1130fd793f47bea1a270baeb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fzf-change-dir-cwd() { # fzf + cd in cwd
  selected=$(find . -maxdepth 1 -type d | fzf);
  if [ ! -z "$selected" ] && [ "$selected" != "$(pwd)" ]; then
    cd $selected;
  fi
  zle send-break
}

zle -N fzf-change-dir-cwd;
bindkey '^O' fzf-change-dir-cwd;

fzf-change-dir() {
  local result=$(find -type d | fzf);
  if ! [[ -z "$result" ]]; then
    cd "$result"
  fi
  zle send-break
}

zle -N fzf-change-dir;
bindkey '^F' fzf-change-dir;