interactive cd
This commit is contained in:
19
zsh/functions/interactive_cd.sh
Normal file
19
zsh/functions/interactive_cd.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
function cdi() {
|
||||
selected_dir=""
|
||||
if (( $+commands[fzf] )); then
|
||||
if (( $+commands[fd] )); then
|
||||
if [[ $1 == "-I" ]]; then
|
||||
selected_dir=$(fd --type d --hidden --no-ignore --exclude .git | fzf)
|
||||
else
|
||||
selected_dir=$(fd --type d --hidden --exclude .git | fzf)
|
||||
fi
|
||||
else
|
||||
selected_dir=$(find . -type d -name '.git' -prune -o -type d -print | fzf)
|
||||
fi
|
||||
if [[ -n $selected_dir ]]; then
|
||||
cd $selected_dir
|
||||
fi
|
||||
else
|
||||
echo "[fzf] is not installed"
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user