1

目前在 OSX (10.10.3) 上使用 ZSH 和 prezto,我遇到了标签完成问题。在键入以下任一内容后,我总是能够按 Tab 键:

 $ cd ~
 $ cd ~/

我会得到一个目录菜单,其中包含我的用户主文件夹的内容。
出于某种原因,在点击标签后我得到:

 $ cd ~
 -- named directory --
_comp_dumpfile
 -- user --
Guest          cr85ir3        macprod-pc  root

这是键入cd ~/并按 Tab的结果

 $ cd ~//Users/CR85IR3/

我尝试禁用 autonamedirs 和 cdablevars。还重新安装了 prezto 并尝试使用 /usr/local/bin/zsh 这是 homebrew 安装的最新 zsh。

非常感谢一些帮助,谢谢

编辑 #1
分离输出并在下面添加 prezto 配置。

.zpreztorc

#
# Sets Prezto options.
#
# Authors:
#   Sorin Ionescu <sorin.ionescu@gmail.com>
#

#
# General
#

# Set case-sensitivity for completion, history lookup, etc.
# zstyle ':prezto:*:*' case-sensitive 'yes'

# Color output (auto set to 'no' on dumb terminals).
zstyle ':prezto:*:*' color 'yes'

# Set the Zsh modules to load (man zshmodules).
# zstyle ':prezto:load' zmodule 'attr' 'stat'

# Set the Zsh functions to load (man zshcontrib).
# zstyle ':prezto:load' zfunction 'zargs' 'zmv'

# Set the Prezto modules to load (browse modules).
# The order matters.
zstyle ':prezto:load' pmodule \
  'environment' \
  'terminal' \
  'editor' \
  'history' \
  'directory' \
  'spectrum' \
  'utility' \
  'completion' \
  'homebrew' \
  'osx' \
  'git' \
  'syntax-highlighting' \
  'history-substring-search' \
  'prompt'

#
# Editor
#

# Set the key mapping style to 'emacs' or 'vi'.
zstyle ':prezto:module:editor' key-bindings 'emacs'

# Auto convert .... to ../..
# zstyle ':prezto:module:editor' dot-expansion 'yes'

#
# Git
#

# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'.
# zstyle ':prezto:module:git:status:ignore' submodules 'all'

#
# GNU Utility
#

# Set the command prefix on non-GNU systems.
# zstyle ':prezto:module:gnu-utility' prefix 'g'

#
# History Substring Search
#

# Set the query found color.
# zstyle ':prezto:module:history-substring-search:color' found ''

# Set the query not found color.
# zstyle ':prezto:module:history-substring-search:color' not-found ''

# Set the search globbing flags.
# zstyle ':prezto:module:history-substring-search' globbing-flags ''

#
# Pacman
#

# Set the Pacman frontend.
# zstyle ':prezto:module:pacman' frontend 'yaourt'

#
# Prompt
#

# Set the prompt theme to load.
# Setting it to 'random' loads a random theme.
# Auto set to 'off' on dumb terminals.
zstyle ':prezto:module:prompt' theme 'paradox'

#
# Ruby
#

# Auto switch the Ruby version on directory change.
# zstyle ':prezto:module:ruby:chruby' auto-switch 'yes'

#
# Screen
#

# Auto start a session when Zsh is launched in a local terminal.
# zstyle ':prezto:module:screen:auto-start' local 'yes'

# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:screen:auto-start' remote 'yes'

#
# SSH
#

# Set the SSH identities to load into the agent.
# zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_rsa2' 'id_github'

#
# Syntax Highlighting
#

# Set syntax highlighters.
# By default, only the main highlighter is enabled.
 zstyle ':prezto:module:syntax-highlighting' highlighters \
   'main' \
#   'brackets' \
#   'pattern' \
#   'cursor' \
#   'root'
#
# Set syntax highlighting styles.
# zstyle ':prezto:module:syntax-highlighting' styles \
#   'builtin' 'bg=blue' \
#   'command' 'bg=blue' \
#   'function' 'bg=blue'

#
# Terminal
#

# Auto set the tab and window titles.
 zstyle ':prezto:module:terminal' auto-title 'yes'

# Set the window title format.
# zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s'

# Set the tab title format.
# zstyle ':prezto:module:terminal:tab-title' format '%m: %s'

#
# Tmux
#

# Auto start a session when Zsh is launched in a local terminal.
# zstyle ':prezto:module:tmux:auto-start' local 'yes'

# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:tmux:auto-start' remote 'yes'

# Integrate with iTerm2.
# zstyle ':prezto:module:tmux:iterm' integrate 'yes'  

哪个_cd

❯ which _cd                                                                                                                                                           [17:55:01]
    _cd () {
        _cd_options () {
            _arguments -s '-q[quiet, no output or use of hooks]' '-s[refuse to use paths with symlinks]' '(-P)-L[retain symbolic links ignoring CHASE_LINKS]' '(-L)-P[resolve symbolic links as CHASE_LINKS]'
        }
        setopt localoptions nonomatch
        local expl ret=1 curarg
        integer argstart=2 noopts
        if (( CURRENT > 1 ))
        then
            while [[ $words[$argstart] = -* && argstart -lt CURRENT ]]
            do
                curarg=$words[$argstart]
                [[ $curarg = -<-> ]] && break
                (( argstart++ ))
                [[ $curarg = -- ]] && noopts=1  && break
            done
        fi
        if [[ CURRENT -eq $((argstart+1)) ]]
        then
            local rep
            rep=(${~PWD/$words[$argstart]/*}~$PWD(-/))
            rep=(${${rep#${PWD%%$words[$argstart]*}}%${PWD#*$words[$argstart]}})
            (( $#rep )) && _wanted -C replacement strings expl replacement compadd -a rep
        else
            if [[ "$PREFIX" = (#b)(\~|)[^/]# && ( -n "$match[1]" || ( CURRENT -gt 1 && ! -o cdablevars ) ) ]]
            then
                _directory_stack && ret=0
            fi
            local -a tmpWpath
            if [[ $PREFIX = (|*/)../* ]]
            then
                local tmpprefix
                tmpprefix=$(cd ${PREFIX%/*} >&/dev/null && print $PWD)
                if [[ -n $tmpprefix ]]
                then
                    tmpWpath=(-W $tmpprefix)
                    IPREFIX=${IPREFIX}${PREFIX%/*}/
                    PREFIX=${PREFIX##*/}
                fi
            fi
            if [[ $PREFIX != (\~|/|./|../)* && $IPREFIX != ../* ]]
            then
                local tmpcdpath alt
                alt=()
                tmpcdpath=(${${(@)cdpath:#.}:#$PWD})
                (( $#tmpcdpath )) && alt=('path-directories:directory in cdpath:_path_files -W tmpcdpath -/')
                if [[ -o cdablevars && -n "$PREFIX" && "$PREFIX" != <-> ]]
                then
                    if [[ "$PREFIX" != */* ]]
                    then
                        alt=("$alt[@]" 'named-directories: : _tilde')
                    else
                        local oipre="$IPREFIX" opre="$PREFIX" dirpre dir
                        dirpre="${PREFIX%%/*}/"
                        IPREFIX="$IPREFIX$dirpre"
                        eval "dir=( ~$dirpre )"
                        PREFIX="${PREFIX#*/}"
                        [[ $#dir -eq 1 && "$dir[1]" != "~$dirpre" ]] && _wanted named-directories expl 'directory after cdablevar' _path_files -W dir -/ && ret=0
                        PREFIX="$opre"
                        IPREFIX="$oipre"
                    fi
                fi
                [[ CURRENT -ne 1 || ( -z "$path[(r).]" && $PREFIX != */* ) ]] && alt=("${cdpath+local-}directories:${cdpath+local }directory:_path_files ${(j: :)${(@q)tmpWpath}} -/" "$alt[@]")
                if [[ CURRENT -eq argstart && noopts -eq 0 && $PREFIX = -* ]] && zstyle -t ":completion:${curcontext}:options" complete-options
                then
                    alt=("$service-options:$service option:_cd_options" "$alt[@]")
                fi
                _alternative "$alt[@]" && ret=0
                return ret
            fi
            [[ CURRENT -ne 1 ]] && _wanted directories expl directory _path_files $tmpWpath -/ && ret=0
            return ret
        fi
    }
4

0 回答 0