導航到資料夾 ZSH

導航到資料夾 ZSH

我真的很喜歡這個oh my zsh功能,它允許您導航到包含文件的資料夾。不知道是插件還是配置。

我一直在測試以下設定但尚未找到它:

setopt auto_name_dirs
setopt auto_cd
setopt cdable_vars
setopt pushd_ignore_dups
setopt auto_pushd

這個想法是將文件拖放到終端應用程式(在 Mac 中),然後導航到其資料夾,但不使用oh my zsh.有誰知道如何做到這一點?

謝謝!

答案1

我已經找到了:https://unix.stackexchange.com/questions/76227/how-to-make-cd-dir-filename-take-me-to-dir

我已將此功能添加到我的.zshrc

cd() {
    if [ -d "$1" ] || [ -z "$1" ]; then
        builtin cd "$@"
    else
        builtin cd "${1%/*}"
    fi
}

它正在發揮作用

相關內容