OSX上的ZSH:cd~和〜/ Tab完成问题

时间:2015-05-14 00:21:22

标签: macos zsh osx-yosemite zsh-completion prezto

目前在OSX上使用ZSH和prezto(10.10.3)并且我在选项卡完成时遇到问题。键入以下任一项后,我始终能够点击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这是自制的最新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
    }

0 个答案:

没有答案