aboutsummaryrefslogtreecommitdiff
path: root/config/zsh/plugins/fzf-cd.zsh
blob: 9d47e17d91aacee8a80a2935f4bda5936ea8b84a (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=$(fd --type d --maxdepth 1 --hidden --no-ignore | fzf);
  if [ ! -z "$selected" ] && [ "$selected" != "$(pwd)" ]; then
    cd $selected;
  fi
  zle send-break || true
}

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

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

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