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
|
||||
}
|
||||
22
zsh/zshrc
22
zsh/zshrc
@@ -2,18 +2,20 @@
|
||||
|
||||
# path -> settings -> alias -> functions -> plugins -> prompt
|
||||
|
||||
if [ -n "${ZSH_VERSION}" ]; then
|
||||
_source="${(%):-%x}"
|
||||
_path=$(dirname "$(realpath "$_source")")
|
||||
unset _source
|
||||
else
|
||||
if [ ! -n "${ZSH_VERSION}" ]; then
|
||||
echo "Unsupported shell"
|
||||
exit 1
|
||||
return 1
|
||||
fi
|
||||
|
||||
# get the dir name that current file in
|
||||
function get_current_dir_name {
|
||||
_source="${(%):-%x}"
|
||||
_path=$(dirname "$(realpath "$_source")")
|
||||
echo $_path
|
||||
}
|
||||
|
||||
# Set basic path to zsh-polyjuice installation
|
||||
export ZSH_POLYJUICE_PATH="$_path"
|
||||
unset _path
|
||||
export ZSH_POLYJUICE_PATH=$(get_current_dir_name)
|
||||
export ZSH_PLUGINS_PATH="$ZSH_POLYJUICE_PATH/plugins"
|
||||
export ZSH_ALIAS_PATH="$ZSH_POLYJUICE_PATH/alias"
|
||||
export ZSH_SETTINGS_PATH="$ZSH_POLYJUICE_PATH/settings"
|
||||
@@ -51,10 +53,6 @@ source $ZSH_PLUGINS_PATH/ohmyzsh/plugins/zoxide/zoxide.plugin.zsh
|
||||
source $ZSH_PLUGINS_PATH/ohmyzsh/plugins/python/python.plugin.zsh
|
||||
|
||||
|
||||
function cdi() {
|
||||
cd $(find . -type d | fzf)
|
||||
}
|
||||
|
||||
# using starship as prompt
|
||||
if (( $+commands[starship] )); then
|
||||
eval "$(starship init zsh)"
|
||||
|
||||
Reference in New Issue
Block a user