gpt4 book ai didi

bash - zsh 自动完成不工作 : _get_comp_words_by_ref:16: bad substitution

转载 作者:行者123 更新时间:2023-12-04 11:45:26 28 4
gpt4 key购买 nike

刚刚切换到使用 zsh (Oh-My-Zsh) 并且无法使用自动完成功能。每当我打开一个新终端(使用 iTerm 以及 VSCode 终端)时,都会在终端上打印以下输出:

/usr/local/etc/bash_completion:59: command not found: shopt
/usr/local/etc/bash_completion:65: command not found: complete
/usr/local/etc/bash_completion:72: command not found: complete
/usr/local/etc/bash_completion:73: command not found: complete
/usr/local/etc/bash_completion:74: command not found: complete
/usr/local/etc/bash_completion:76: command not found: complete
/usr/local/etc/bash_completion:77: command not found: complete
/usr/local/etc/bash_completion:79: command not found: complete
/usr/local/etc/bash_completion:80: command not found: complete
/usr/local/etc/bash_completion:81: command not found: complete
/usr/local/etc/bash_completion:82: command not found: complete
/usr/local/etc/bash_completion:83: command not found: complete
/usr/local/etc/bash_completion:84: command not found: complete
/usr/local/etc/bash_completion:85: command not found: complete
/usr/local/etc/bash_completion:86: command not found: complete
/usr/local/etc/bash_completion:87: command not found: complete
/usr/local/etc/bash_completion:88: command not found: complete
/usr/local/etc/bash_completion:89: command not found: complete
/usr/local/etc/bash_completion:90: command not found: complete
/usr/local/etc/bash_completion:91: command not found: complete
/usr/local/etc/bash_completion:92: command not found: complete
/usr/local/etc/bash_completion:93: command not found: complete
/usr/local/etc/bash_completion:94: command not found: complete
/usr/local/etc/bash_completion:95: command not found: complete
/usr/local/etc/bash_completion:96: command not found: complete
/usr/local/etc/bash_completion:97: command not found: complete
/usr/local/etc/bash_completion:98: command not found: complete
/usr/local/etc/bash_completion:99: command not found: complete
/usr/local/etc/bash_completion:100: command not found: complete
/usr/local/etc/bash_completion:101: command not found: complete
/usr/local/etc/bash_completion:102: command not found: complete
/usr/local/etc/bash_completion:103: command not found: complete
/usr/local/etc/bash_completion:104: command not found: complete
/usr/local/etc/bash_completion:105: command not found: complete
/usr/local/etc/bash_completion:106: command not found: complete
/usr/local/etc/bash_completion:107: command not found: complete
/usr/local/etc/bash_completion:108: command not found: complete
/usr/local/etc/bash_completion:110: command not found: complete
/usr/local/etc/bash_completion:111: command not found: complete
/usr/local/etc/bash_completion:112: command not found: complete
/usr/local/etc/bash_completion:113: command not found: complete
/usr/local/etc/bash_completion:114: command not found: complete
/usr/local/etc/bash_completion:115: command not found: complete
/usr/local/etc/bash_completion:116: command not found: complete
/usr/local/etc/bash_completion:117: command not found: complete
/usr/local/etc/bash_completion:118: command not found: complete
/usr/local/etc/bash_completion:119: command not found: complete
/usr/local/etc/bash_completion:120: command not found: complete
/usr/local/etc/bash_completion:121: command not found: complete
/usr/local/etc/bash_completion:122: command not found: complete
/usr/local/etc/bash_completion:123: command not found: complete
/usr/local/etc/bash_completion:124: command not found: complete
/usr/local/etc/bash_completion:125: command not found: complete
/usr/local/etc/bash_completion:126: command not found: complete
/usr/local/etc/bash_completion:132: command not found: complete
/usr/local/etc/bash_completion:135: command not found: complete
/usr/local/etc/bash_completion:138: command not found: complete
/usr/local/etc/bash_completion:141: command not found: complete
/usr/local/etc/bash_completion:144: command not found: complete
/usr/local/etc/bash_completion:147: command not found: complete
/usr/local/etc/bash_completion:150: command not found: complete
/usr/local/etc/bash_completion:153: command not found: complete
/usr/local/etc/bash_completion:156: command not found: complete
/usr/local/etc/bash_completion:159: command not found: complete
/usr/local/etc/bash_completion:162: command not found: complete
/usr/local/etc/bash_completion:1192: command not found: shopt
/usr/local/etc/bash_completion:1367: command not found: complete
/usr/local/etc/bash_completion:1420: command not found: shopt
/usr/local/etc/bash_completion:1423: command not found: complete
/usr/local/etc/bash_completion:1523: command not found: complete
/usr/local/etc/bash_completion:1532: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
/usr/local/etc/bash_completion:1577: command not found: complete
(eval):1: command not found: complete
(eval):1: command not found: complete
/usr/local/etc/bash_completion.d/bash-builtins:20: command not found: complete
/usr/local/etc/bash_completion.d/bash-builtins:46: command not found: complete
/usr/local/etc/bash_completion.d/bash-builtins:69: command not found: complete
/usr/local/etc/bash_completion.d/bash-builtins:120: command not found: complete
/usr/local/etc/bash_completion.d/bind-utils:15: command not found: complete
/usr/local/etc/bash_completion.d/brctl:40: command not found: complete
/usr/local/etc/bash_completion.d/brew:870: command not found: complete
/usr/local/etc/bash_completion.d/bzip2:43: command not found: complete
/usr/local/etc/bash_completion.d/chsh:29: command not found: complete
/usr/local/etc/bash_completion.d/configure:36: command not found: complete
/usr/local/etc/bash_completion.d/coreutils:50: command not found: complete
/usr/local/etc/bash_completion.d/coreutils:94: command not found: complete
/usr/local/etc/bash_completion.d/coreutils:113: command not found: complete
/usr/local/etc/bash_completion.d/coreutils:141: command not found: complete
/usr/local/etc/bash_completion.d/cpan2dist:44: command not found: complete
/usr/local/etc/bash_completion.d/cpio:94: command not found: complete
/usr/local/etc/bash_completion.d/crontab:52: command not found: complete
/usr/local/etc/bash_completion.d/cups:13: command not found: complete
/usr/local/etc/bash_completion.d/dd:31: command not found: complete
/usr/local/etc/bash_completion.d/docker:69: command not found: shopt
/usr/local/etc/bash_completion.d/docker:70: command not found: shopt
/usr/local/etc/bash_completion.d/docker:5629: command not found: complete
/usr/local/etc/bash_completion.d/docker-compose:19: command not found: shopt
/usr/local/etc/bash_completion.d/docker-compose:20: command not found: shopt
/usr/local/etc/bash_completion.d/docker-compose:665: command not found: complete
/usr/local/etc/bash_completion.d/findutils:120: command not found: complete
/usr/local/etc/bash_completion.d/gcc:49: command not found: complete
/usr/local/etc/bash_completion.d/gzip:47: command not found: complete
/usr/local/etc/bash_completion.d/heimdal:124: command not found: complete
/usr/local/etc/bash_completion.d/iconv:38: command not found: complete
/usr/local/etc/bash_completion.d/info:50: command not found: complete
/usr/local/etc/bash_completion.d/jar:28: command not found: complete
/usr/local/etc/bash_completion.d/java:237: command not found: complete
/usr/local/etc/bash_completion.d/java:289: command not found: complete
/usr/local/etc/bash_completion.d/java:321: command not found: complete
/usr/local/etc/bash_completion.d/java:394: command not found: complete
/usr/local/etc/bash_completion.d/java:440: command not found: complete
/usr/local/etc/bash_completion.d/java:495: command not found: complete
/usr/local/etc/bash_completion.d/java:525: command not found: complete
/usr/local/etc/bash_completion.d/lsof:56: command not found: complete
/usr/local/etc/bash_completion.d/lzma:38: command not found: complete
/usr/local/etc/bash_completion.d/make:70: command not found: complete
/usr/local/etc/bash_completion.d/man:72: command not found: complete
/usr/local/etc/bash_completion.d/mount:132: command not found: complete
/usr/local/etc/bash_completion.d/mount:155: command not found: complete
/usr/local/etc/bash_completion.d/openldap:59: command not found: complete
/usr/local/etc/bash_completion.d/openldap:96: command not found: complete
/usr/local/etc/bash_completion.d/openldap:129: command not found: complete
/usr/local/etc/bash_completion.d/openldap:162: command not found: complete
/usr/local/etc/bash_completion.d/openldap:195: command not found: complete
/usr/local/etc/bash_completion.d/openldap:228: command not found: complete
/usr/local/etc/bash_completion.d/openldap:257: command not found: complete
/usr/local/etc/bash_completion.d/openssl:245: command not found: complete
/usr/local/etc/bash_completion.d/perl:82: command not found: complete
/usr/local/etc/bash_completion.d/perl:122: command not found: complete
/usr/local/etc/bash_completion.d/postfix:32: command not found: complete
/usr/local/etc/bash_completion.d/postfix:78: command not found: complete
/usr/local/etc/bash_completion.d/postfix:121: command not found: complete
/usr/local/etc/bash_completion.d/postfix:163: command not found: complete
/usr/local/etc/bash_completion.d/postfix:224: command not found: complete
/usr/local/etc/bash_completion.d/procps:22: command not found: complete
/usr/local/etc/bash_completion.d/procps:38: command not found: complete
/usr/local/etc/bash_completion.d/python:47: command not found: complete
/usr/local/etc/bash_completion.d/quota-tools:60: command not found: complete
/usr/local/etc/bash_completion.d/quota-tools:99: command not found: complete
/usr/local/etc/bash_completion.d/quota-tools:131: command not found: complete
/usr/local/etc/bash_completion.d/quota-tools:160: command not found: complete
/usr/local/etc/bash_completion.d/quota-tools:189: command not found: complete
/usr/local/etc/bash_completion.d/quota-tools:216: command not found: complete
/usr/local/etc/bash_completion.d/quota-tools:248: command not found: complete
/usr/local/etc/bash_completion.d/ri:87: command not found: complete
/usr/local/etc/bash_completion.d/rsync:84: command not found: complete
/usr/local/etc/bash_completion.d/screen:58: command not found: complete
/usr/local/etc/bash_completion.d/service:35: no matches found: /etc/init.d/*
/usr/local/etc/bash_completion.d/sh:33: command not found: complete
/usr/local/etc/bash_completion.d/shadow:171: command not found: complete
/usr/local/etc/bash_completion.d/shadow:314: command not found: complete
/usr/local/etc/bash_completion.d/shadow:326: command not found: complete
/usr/local/etc/bash_completion.d/shadow:415: command not found: complete
/usr/local/etc/bash_completion.d/sqlite3:31: command not found: complete
/usr/local/etc/bash_completion.d/ssh:194: command not found: shopt
/usr/local/etc/bash_completion.d/ssh:247: command not found: shopt
/usr/local/etc/bash_completion.d/ssh:393: command not found: complete
/usr/local/etc/bash_completion.d/ssh:419: command not found: complete
/usr/local/etc/bash_completion.d/sysctl:16: command not found: complete
/usr/local/etc/bash_completion.d/tar:63: command not found: complete
/usr/local/etc/bash_completion.d/tcpdump:29: command not found: complete
/usr/local/etc/bash_completion.d/util-linux:32: command not found: complete
/usr/local/etc/bash_completion.d/util-linux:52: command not found: complete
/usr/local/etc/bash_completion.d/util-linux:68: command not found: complete
/usr/local/etc/bash_completion.d/xmllint:47: command not found: complete
/usr/local/etc/bash_completion.d/xrandr:17: parse error near `)'
/usr/local/etc/bash_completion.d/xsltproc:48: command not found: complete
/usr/local/etc/bash_completion.d/xz:60: command not found: complete
/usr/local/etc/bash_completion.d/xz:94: command not found: complete

我的 /.zshrc文件包含以下内容:
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

autoload -U +X bashcompinit && bashcompinit
autoload -U +X compinit && compinit

# Path to your oh-my-zsh installation.
export ZSH="/Users/p2915782/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="powerlevel9k/powerlevel9k"

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir rbenv vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time virtualenv)
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
# Add a space in the first prompt
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%f"
local user_symbol="$"
if [[ $(print -P "%#") =~ "#" ]]; then
user_symbol = "#"
fi
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%{%B%F{black}%K{yellow}%} $user_symbol%{%b%f%k%F{yellow}%} %{%f%}"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS=true

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
plugins=(virtualenv)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

当我尝试在终端内自动完成时,出现以下错误:
_get_comp_words_by_ref:16: bad substitution
我尝试了多种解决方案,例如将以下内容添加到我的 ~/.zshrc 的顶部
autoload -U +X bashcompinit && bashcompinit autoload -U +X compinit && compinit
但我还没有找到解决办法。

最佳答案

您正在采购整个 bash_completion 项目的某个地方 - 不要。 Bash 补全在 zsh 中不起作用,即使有,它们也比原生 zsh 更糟糕。 bashcompinit仅对个别、精心挑选和测试的功能有用。但还是避免为好。

目前尚不清楚它的来源。语法高亮插件不太可能。 oh-my-zsh 也不应该这样做,但我会先尝试禁用它。还要检查其他启动文件,如 .zshenv , .zlogin , .zprofile和系统文件,例如 /etc/zshenv .

另外,关于您引用的 .zshrc:没有必要通过 +Xautoload ,那毫无意义。对 plugins 数组的第二个赋值是替换第一个赋值中的值。你要吗+=反而?如果你想在提示中为普通用户使用 $ 和为 root 使用 #,你可以直接使用 %(!.#.$) 来做到这一点。

关于bash - zsh 自动完成不工作 : _get_comp_words_by_ref:16: bad substitution,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60554806/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com