为什么 .zshrc 不加载?
Why won't .zshrc load?
我正在使用 cmder 在 运行 ubuntu 上 Windows 10 上的 zsh。我正在尝试运行 Oh My Zsh 主题。由于某种原因,我的 .zshrc 文件没有被调用。我已经确认 zsh 实际上是 运行ning:
% zsh --version
zsh 5.1.1 (x86_64-ubuntu-linux-gnu)
% echo [=10=]
zsh
我已确认变量不存在:
% echo $ZSH_THEME
// blank line
如果我逐行 运行 .zshrc 的内容,Oh My Zsh 主题会正确加载:
% ZSH=/home/user/.oh-my-zsh
% ZSH_THEME="agnoster"
% plugins=(git)
% source $ZSH/oh-my-zsh.sh
% // theme shows up now
不确定这是否是 Linux 安装的最新 Windows 子系统的结果(今天是新的)- 新安装在 user\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79blahblah\LocalState\rootfs\home\user
中 - 或者如果我'我在这里不合时宜。预先感谢您的建议。
zsh -x 输出,根据吉尔斯:
% zsh -x
+/etc/zsh/zshenv:15> [[ -z '// trimmed' == /bin:/usr/bin ]]
+/etc/zsh/zshrc:9> READNULLCMD=/usr/bin/pager
+/etc/zsh/zshrc:12> typeset -ga debian_missing_features
+/etc/zsh/zshrc:14> [[ -z '' ]]
+/etc/zsh/zshrc:15> [[ xterm-256color != emacs ]]
+/etc/zsh/zshrc:18> typeset -A key
+/etc/zsh/zshrc:19> key=( BackSpace Home H End F Insert '' Delete '' Up A Down B Left D Right C PageUp '' PageDown '' )
+/etc/zsh/zshrc:53> bind2maps emacs -- BackSpace backward-delete-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=
+bind2maps:11> widget=backward-delete-char
+bind2maps:13> [[ -z ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs backward-delete-char
+/etc/zsh/zshrc:54> bind2maps viins -- BackSpace vi-backward-delete-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=
+bind2maps:11> widget=vi-backward-delete-char
+bind2maps:13> [[ -z ]]
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins vi-backward-delete-char
+/etc/zsh/zshrc:55> bind2maps vicmd -- BackSpace vi-backward-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=
+bind2maps:11> widget=vi-backward-char
+bind2maps:13> [[ -z ]]
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd vi-backward-char
+/etc/zsh/zshrc:56> bind2maps emacs -- Home beginning-of-line
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=H
+bind2maps:11> widget=beginning-of-line
+bind2maps:13> [[ -z H ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs H beginning-of-line
+/etc/zsh/zshrc:57> bind2maps viins vicmd -- Home vi-beginning-of-line
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=H
+bind2maps:11> widget=vi-beginning-of-line
+bind2maps:13> [[ -z H ]]
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins H vi-beginning-of-line
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd H vi-beginning-of-line
+/etc/zsh/zshrc:58> bind2maps emacs -- End end-of-line
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=F
+bind2maps:11> widget=end-of-line
+bind2maps:13> [[ -z F ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs F end-of-line
+/etc/zsh/zshrc:59> bind2maps viins vicmd -- End vi-end-of-line
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=F
+bind2maps:11> widget=vi-end-of-line
+bind2maps:13> [[ -z F ]]
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins F vi-end-of-line
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd F vi-end-of-line
+/etc/zsh/zshrc:60> bind2maps emacs viins -- Insert overwrite-mode
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=''
+bind2maps:11> widget=overwrite-mode
+bind2maps:13> [[ -z '' ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs '' overwrite-mode
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins '' overwrite-mode
+/etc/zsh/zshrc:61> bind2maps vicmd -- Insert vi-insert
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=''
+bind2maps:11> widget=vi-insert
+bind2maps:13> [[ -z '' ]]
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd '' vi-insert
+/etc/zsh/zshrc:62> bind2maps emacs -- Delete delete-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=''
+bind2maps:11> widget=delete-char
+bind2maps:13> [[ -z '' ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs '' delete-char
+/etc/zsh/zshrc:63> bind2maps viins vicmd -- Delete vi-delete-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=''
+bind2maps:11> widget=vi-delete-char
+bind2maps:13> [[ -z '' ]]
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins '' vi-delete-char
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd '' vi-delete-char
+/etc/zsh/zshrc:64> bind2maps emacs viins vicmd -- Up up-line-or-history
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=A
+bind2maps:11> widget=up-line-or-history
+bind2maps:13> [[ -z A ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs A up-line-or-history
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins A up-line-or-history
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd A up-line-or-history
+/etc/zsh/zshrc:65> bind2maps emacs viins vicmd -- Down down-line-or-history
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=B
+bind2maps:11> widget=down-line-or-history
+bind2maps:13> [[ -z B ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs B down-line-or-history
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins B down-line-or-history
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd B down-line-or-history
+/etc/zsh/zshrc:66> bind2maps emacs -- Left backward-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=D
+bind2maps:11> widget=backward-char
+bind2maps:13> [[ -z D ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs D backward-char
+/etc/zsh/zshrc:67> bind2maps viins vicmd -- Left vi-backward-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=D
+bind2maps:11> widget=vi-backward-char
+bind2maps:13> [[ -z D ]]
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins D vi-backward-char
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd D vi-backward-char
+/etc/zsh/zshrc:68> bind2maps emacs -- Right forward-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=C
+bind2maps:11> widget=forward-char
+bind2maps:13> [[ -z C ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs C forward-char
+/etc/zsh/zshrc:69> bind2maps viins vicmd -- Right vi-forward-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=C
+bind2maps:11> widget=vi-forward-char
+bind2maps:13> [[ -z C ]]
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins C vi-forward-char
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd C vi-forward-char
+/etc/zsh/zshrc:73> (( 1 ))
+/etc/zsh/zshrc:73> (( 1 ))
+/etc/zsh/zshrc:82> zle -N zle-line-init
+/etc/zsh/zshrc:83> zle -N zle-line-finish
+/etc/zsh/zshrc:91> unfunction bind2maps
+/etc/zsh/zshrc:95> zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin
+/etc/zsh/zshrc:103> (( 1 ))
+/etc/zsh/zshrc:103> unalias run-help
+/etc/zsh/zshrc:104> autoload -Uz run-help
+/etc/zsh/zshrc:109> [[ -z '' ]]
+/etc/zsh/zshrc:110> autoload -U compinit
+/etc/zsh/zshrc:111> compinit
+compinit:70> emulate -L zsh
+compinit:71> setopt extendedglob
+compinit:73> typeset _i_dumpfile _i_files _i_line _i_done _i_dir _i_autodump=1
+compinit:74> typeset _i_tag _i_file _i_addfiles _i_fail=ask _i_check=yes _i_name
+compinit:76> [[ 0 -gt 0 ]]
+compinit:108> typeset -gHA _comps _services _patcomps _postpatcomps
+compinit:113> typeset -gHA _compautos
+compinit:118> typeset -gHA _lastcomp
+compinit:121> [[ -n '' ]]
+compinit:125> typeset -g _comp_dumpfile=/home/user/.zcompdump
+compinit:130> typeset -gHa _comp_options
+compinit:131> _comp_options=( bareglobqual extendedglob glob multibyte multifuncdef nullglob rcexpandparam unset NO_allexport NO_aliases NO_cshnullglob NO_cshjunkiequotes NO_errexit NO_globassign NO_globsubst NO_histsubstpattern NO_ignorebraces NO_ignoreclosebraces NO_kshglob NO_ksharrays NO_kshtypeset NO_markdirs NO_octalzeroes NO_posixbuiltins NO_shwordsplit NO_shglob NO_warncreateglobal )
+compinit:167> typeset -gH _comp_setup='local -A _comp_caller_options;
_comp_caller_options=(${(kv)options[@]});
setopt localoptions localtraps localpatterns ${_comp_options[@]};
local IFS=$'\'' \t\r\n[=13=]'\''
enable -p \| \~ \( \? \* \[ \< \^ \#
exec </dev/null;
trap - ZERR
local -a reply
local REPLY'
+compinit:180> typeset -ga compprefuncs comppostfuncs
+compinit:181> compprefuncs=( )
+compinit:182> comppostfuncs=( )
+compinit:186> : compinit /etc/zsh/zshrc
+compinit:435> typeset _i_wdirs _i_wfiles
+compinit:437> _i_wdirs=( )
+compinit:438> _i_wfiles=( )
+compinit:440> autoload -Uz compaudit
+compinit:441> [[ -n yes ]]
+compinit:442> typeset _i_q
+compinit:443> eval compaudit
+(eval):1> compaudit
+compaudit:174> compaudit
+compaudit:13> emulate -L zsh
+compaudit:14> setopt extendedglob
+compaudit:16> [[ -x /usr/bin/getent ]]
+compaudit:25> (( 0 ))
+compaudit:27> (( 30 == 0 ))
+compaudit:31> set -- // trimmed
+compaudit:38> (( 1 ))
+compaudit:44> fpath=( // trimmed )
+compaudit:49> (( 0 ))
+compaudit:50> local _compdir=''
+compaudit:51> [[ -z '' ]]
+compaudit:51> _compdir=/usr/local/share/zsh/site-functions
+compaudit:55> _i_wdirs=( )
+compaudit:56> _i_wfiles=( )
+compaudit:58> _i_files=( // trimmed )
+compaudit:59> [[ -n /usr/local/share/zsh/site-functions ]]
+compaudit:60> [[ 766 -lt 20 || /usr/local/share/zsh/site-functions == */Base || -d /usr/local/share/zsh/site-functions/Base ]]
+compaudit:82> [[ ask == use ]]
+compaudit:86> local _i_owners=u0u1000
+compaudit:89> local -a _i_exes
+compaudit:90> _i_exes=( /proc/8/exe /proc/8/object/a.out )
+compaudit:94> local _i_exe
+compaudit:99> _i_exe=/proc/8/exe
+compaudit:100> [[ -e /proc/8/exe ]]
+compaudit:101> zmodload -F zsh/stat b:zstat
+compaudit:102> local -A _i_stathash
+compaudit:103> zstat -H _i_stathash /proc/8/exe
+compaudit:104> [[ 0 -ne 0 ]]
+compaudit:108> break
+compaudit:121> _i_wdirs=( /usr/local/share/zsh/site-functions )
+compaudit:130> (( 1 ))
+compaudit:131> local GROUP GROUPMEM _i_pw _i_gid
+compaudit:132> (( UID == EUID ))
+compaudit:133> IFS=: +compaudit:133> read GROUP _i_pw _i_gid GROUPMEM
+compaudit:133> getent group user
+compaudit:138> [[ user == user && -z '' ]]
+compaudit:140> _i_wdirs=( /usr/local/share/zsh/site-functions )
+compaudit:144> [[ -f /etc/debian_version ]]
+compaudit:146> local _i_ulwdirs
+compaudit:147> _i_ulwdirs=( /usr/local/share/zsh/site-functions )
+compaudit:148> _i_wdirs=( )
+compaudit:151> _i_wdirs=( )
+compaudit:152> _i_wfiles=( )
+compaudit:154> case 0:0 (0:0)
+compaudit:155> _i_q=''
+compaudit:161> [[ -n '' ]]
+compaudit:168> return 0
+compinit:468> autoload -Uz compdump compinstall
+compinit:472> _i_done=''
+compinit:474> [[ -f /home/user/.zcompdump ]]
+compinit:475> [[ -n yes ]]
+compinit:476> IFS=' ' +compinit:476> read -rA _i_line
+compinit:477> [[ _i_autodump -eq 1 && 766 -eq 766 && 5.1.1 == 5.1.1 ]]
+compinit:480> . /home/user/.zcompdump
+/home/user/.zcompdump:3> _comps=( // trimmed )
+/home/user/.zcompdump:1341> _services=( // trimmed )
+/home/user/.zcompdump:1384> _patcomps=( '*/(init|rc[0-9S]#).d/*' _init_d 'zf*' _zftp )
+/home/user/.zcompdump:1389> _postpatcomps=( // trimmed )
+/home/user/.zcompdump:1412> _compautos=( _call_program +X )
+/home/user/.zcompdump:1416> zle -C _bash_complete-word .complete-word _bash_completions
+/home/user/.zcompdump:1417> zle -C _bash_list-choices .list-choices _bash_completions
+/home/user/.zcompdump:1418> zle -C _complete_debug .complete-word _complete_debug
+/home/user/.zcompdump:1419> zle -C _complete_help .complete-word _complete_help
+/home/user/.zcompdump:1420> zle -C _complete_tag .complete-word _complete_tag
+/home/user/.zcompdump:1421> zle -C _correct_filename .complete-word _correct_filename
+/home/user/.zcompdump:1422> zle -C _correct_word .complete-word _correct_word
+/home/user/.zcompdump:1423> zle -C _expand_alias .complete-word _expand_alias
+/home/user/.zcompdump:1424> zle -C _expand_word .complete-word _expand_word
+/home/user/.zcompdump:1425> zle -C _history-complete-newer .complete-word _history_complete_word
+/home/user/.zcompdump:1426> zle -C _history-complete-older .complete-word _history_complete_word
+/home/user/.zcompdump:1427> zle -C _list_expansions .list-choices _expand_word
+/home/user/.zcompdump:1428> zle -C _most_recent_file .complete-word _most_recent_file
+/home/user/.zcompdump:1429> zle -C _next_tags .list-choices _next_tags
+/home/user/.zcompdump:1430> zle -C _read_comp .complete-word _read_comp
+/home/user/.zcompdump:1431> bindkey '^X^R' _read_comp
+/home/user/.zcompdump:1432> bindkey '^X?' _complete_debug
+/home/user/.zcompdump:1433> bindkey '^XC' _correct_filename
+/home/user/.zcompdump:1434> bindkey '^Xa' _expand_alias
+/home/user/.zcompdump:1435> bindkey '^Xc' _correct_word
+/home/user/.zcompdump:1436> bindkey '^Xd' _list_expansions
+/home/user/.zcompdump:1437> bindkey '^Xe' _expand_word
+/home/user/.zcompdump:1438> bindkey '^Xh' _complete_help
+/home/user/.zcompdump:1439> bindkey '^Xm' _most_recent_file
+/home/user/.zcompdump:1440> bindkey '^Xn' _next_tags
+/home/user/.zcompdump:1441> bindkey '^Xt' _complete_tag
+/home/user/.zcompdump:1442> bindkey '^X~' _bash_list-choices
+/home/user/.zcompdump:1443> bindkey '^[,' _history-complete-newer
+/home/user/.zcompdump:1444> bindkey '^[/' _history-complete-older
+/home/user/.zcompdump:1445> bindkey '^[~' _bash_complete-word
+/home/user/.zcompdump:1447> // trimmed
+/home/user/.zcompdump:1600> autoload -Uz +X _call_program
+/home/user/.zcompdump:1602> typeset -gUa _comp_assocs
+/home/user/.zcompdump:1603> _comp_assocs=( '' )
+compinit:481> _i_done=yes
+compinit:488> [[ -z yes ]]
+compinit:525> _i_line=complete-word
+compinit:528> zle -C complete-word .complete-word _main_complete
+compinit:525> _i_line=delete-char-or-list
+compinit:528> zle -C delete-char-or-list .delete-char-or-list _main_complete
+compinit:525> _i_line=expand-or-complete
+compinit:528> zle -C expand-or-complete .expand-or-complete _main_complete
+compinit:525> _i_line=expand-or-complete-prefix
+compinit:528> zle -C expand-or-complete-prefix .expand-or-complete-prefix _main_complete
+compinit:525> _i_line=list-choices
+compinit:528> zle -C list-choices .list-choices _main_complete
+compinit:525> _i_line=menu-complete
+compinit:528> zle -C menu-complete .menu-complete _main_complete
+compinit:525> _i_line=menu-expand-or-complete
+compinit:528> zle -C menu-expand-or-complete .menu-expand-or-complete _main_complete
+compinit:525> _i_line=reverse-menu-complete
+compinit:528> zle -C reverse-menu-complete .reverse-menu-complete _main_complete
+compinit:530> zle -la menu-select
+compinit:534> IFS=' ' +compinit:534> read -A _i_line
+compinit:534> bindkey '^i'
+compinit:535> [[ expand-or-complete == expand-or-complete ]]
+compinit:536> zstyle -a :completion: completer _i_line
+compinit:541> unfunction compinit compaudit
+compinit:542> autoload -Uz compinit compaudit
+compinit:544> return 0
吉尔斯:
% ls -ld ~/.z*
+zsh:8> ls -ld /home/user/.zcompdump /home/user/.zcompdump-user-5.1.1 /home/user/.zsh_history /home/user/.zshrc /home/user/.zsh-update
-rw-rw-rw- 1 user user 39206 Apr 17 11:42 /home/user/.zcompdump
-rw-r--r-- 1 user user 39352 Apr 17 11:45 /home/user/.zcompdump-user-5.1.1
-rw------- 1 user user 596 Apr 17 14:09 /home/user/.zsh_history
---------- 1 user user 3132 Apr 17 13:42 /home/user/.zshrc
-rw-rw-rw- 1 user user 17 Apr 17 13:12 /home/user/.zsh-update
% head -n 1 ~/.z*
+zsh:9> head -n 1 /home/user/.zcompdump /home/user/.zcompdump-user-5.1.1 /home/user/.zsh_history /home/user/.zshrc /home/user/.zsh-update
==> /home/user/.zcompdump <==
#files: 766 version: 5.1.1
==> /home/user/.zcompdump-user-5.1.1 <==
#files: 766 version: 5.1.1
==> /home/user/.zsh_history <==
: 1523995979:0;chsh -s /usr/bin/zsh
head: cannot open '/home/user/.zshrc' for reading: Permission denied
==> /home/user/.zsh-update <==
LAST_EPOCH=17638
根据上面的输出,我尝试 sudo chown -R user .zshrc
其中 运行 没有错误,但文件仍然无法读取。
有很多事情 可能会 出错,尽管它们很少出错。
Zsh 启动时读取 a number of files。我不会在这里重复整个列表;对于交互式使用,列表是:
- 系统
zshenv
- 用户
.zshenv
- 系统
zshrc
- 用户
.zshrc
系统目录默认为/etc
,但可能会在编译时更改。它在基于 Debian 的发行版上是 /etc/zsh
,包括 Ubuntu,包括 WSL。用户目录是环境变量 ZDOTDIR
的值(如果已设置(通常未设置)),否则是主目录。
在 zsh 中,运行 echo $ZDOTDIR
查看是否定义了 ZDOTDIR
。如果是,请在以下命令中使用 $ZDOTDIR
而不是 ~
。如果不是,请使用 echo $HOME
检查您的主目录是否符合您的预期。 Windows 上 Unix 层的一个轻微常见问题(但 WSL 通常不存在)是当 shell 启动时您的主目录未设置为您期望的内容。
检查 zsh 从您的主目录加载了哪些文件,并检查它们的内容。
ls -ld ~/.zsh(env|rc)
less ~/.zsh(env|rc)
确保文件名正确。它需要以点开头并且全部小写。检查内容是否符合您的预期。
在您的情况下,ls
显示了问题所在:您没有对 ~/.zshrc
的读取权限。你可以用
解决这个问题
chmod u+r ~/.zshrc
虽然损坏的权限可能更普遍地表示您的 WSL 设置或您保存文件的应用程序出现问题。
运行 zsh 与 -x
选项来查看它加载的所有内容的踪迹。这可能非常大。从类 Unix 命令行(sh、bash 或 zsh),您可以将跟踪重定向到文件:
zsh -x 2>zsh.err
按Ctrl+D退出,查看zsh.err
的内容。这显示了所有加载的文件,例如
+/etc/zsh/zshenv:15> [[ -z '// trimmed' == /bin:/usr/bin ]]
+/etc/zsh/zshrc:9> READNULLCMD=/usr/bin/pager
…
执行了zshenv
中的一行代码(其余为空白,注释,或因条件执行而跳过)。没有用户 .zshenv
文件,因此下一行来自系统 zshrc
。你的踪迹中的最后一件事
+compinit:544> return 0
是加载完成系统的最后一行,这是 Debian/Ubuntu/WSL 的系统 zshrc
做的最后一件事。因此,没有用户 .zshrc
(或者更准确地说,没有可读用户 .zshrc
)。
我正在使用 cmder 在 运行 ubuntu 上 Windows 10 上的 zsh。我正在尝试运行 Oh My Zsh 主题。由于某种原因,我的 .zshrc 文件没有被调用。我已经确认 zsh 实际上是 运行ning:
% zsh --version
zsh 5.1.1 (x86_64-ubuntu-linux-gnu)
% echo [=10=]
zsh
我已确认变量不存在:
% echo $ZSH_THEME
// blank line
如果我逐行 运行 .zshrc 的内容,Oh My Zsh 主题会正确加载:
% ZSH=/home/user/.oh-my-zsh
% ZSH_THEME="agnoster"
% plugins=(git)
% source $ZSH/oh-my-zsh.sh
% // theme shows up now
不确定这是否是 Linux 安装的最新 Windows 子系统的结果(今天是新的)- 新安装在 user\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79blahblah\LocalState\rootfs\home\user
中 - 或者如果我'我在这里不合时宜。预先感谢您的建议。
zsh -x 输出,根据吉尔斯:
% zsh -x
+/etc/zsh/zshenv:15> [[ -z '// trimmed' == /bin:/usr/bin ]]
+/etc/zsh/zshrc:9> READNULLCMD=/usr/bin/pager
+/etc/zsh/zshrc:12> typeset -ga debian_missing_features
+/etc/zsh/zshrc:14> [[ -z '' ]]
+/etc/zsh/zshrc:15> [[ xterm-256color != emacs ]]
+/etc/zsh/zshrc:18> typeset -A key
+/etc/zsh/zshrc:19> key=( BackSpace Home H End F Insert '' Delete '' Up A Down B Left D Right C PageUp '' PageDown '' )
+/etc/zsh/zshrc:53> bind2maps emacs -- BackSpace backward-delete-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=
+bind2maps:11> widget=backward-delete-char
+bind2maps:13> [[ -z ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs backward-delete-char
+/etc/zsh/zshrc:54> bind2maps viins -- BackSpace vi-backward-delete-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=
+bind2maps:11> widget=vi-backward-delete-char
+bind2maps:13> [[ -z ]]
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins vi-backward-delete-char
+/etc/zsh/zshrc:55> bind2maps vicmd -- BackSpace vi-backward-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=
+bind2maps:11> widget=vi-backward-char
+bind2maps:13> [[ -z ]]
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd vi-backward-char
+/etc/zsh/zshrc:56> bind2maps emacs -- Home beginning-of-line
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=H
+bind2maps:11> widget=beginning-of-line
+bind2maps:13> [[ -z H ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs H beginning-of-line
+/etc/zsh/zshrc:57> bind2maps viins vicmd -- Home vi-beginning-of-line
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=H
+bind2maps:11> widget=vi-beginning-of-line
+bind2maps:13> [[ -z H ]]
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins H vi-beginning-of-line
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd H vi-beginning-of-line
+/etc/zsh/zshrc:58> bind2maps emacs -- End end-of-line
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=F
+bind2maps:11> widget=end-of-line
+bind2maps:13> [[ -z F ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs F end-of-line
+/etc/zsh/zshrc:59> bind2maps viins vicmd -- End vi-end-of-line
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=F
+bind2maps:11> widget=vi-end-of-line
+bind2maps:13> [[ -z F ]]
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins F vi-end-of-line
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd F vi-end-of-line
+/etc/zsh/zshrc:60> bind2maps emacs viins -- Insert overwrite-mode
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=''
+bind2maps:11> widget=overwrite-mode
+bind2maps:13> [[ -z '' ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs '' overwrite-mode
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins '' overwrite-mode
+/etc/zsh/zshrc:61> bind2maps vicmd -- Insert vi-insert
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=''
+bind2maps:11> widget=vi-insert
+bind2maps:13> [[ -z '' ]]
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd '' vi-insert
+/etc/zsh/zshrc:62> bind2maps emacs -- Delete delete-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=''
+bind2maps:11> widget=delete-char
+bind2maps:13> [[ -z '' ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs '' delete-char
+/etc/zsh/zshrc:63> bind2maps viins vicmd -- Delete vi-delete-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=''
+bind2maps:11> widget=vi-delete-char
+bind2maps:13> [[ -z '' ]]
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins '' vi-delete-char
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd '' vi-delete-char
+/etc/zsh/zshrc:64> bind2maps emacs viins vicmd -- Up up-line-or-history
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=A
+bind2maps:11> widget=up-line-or-history
+bind2maps:13> [[ -z A ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs A up-line-or-history
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins A up-line-or-history
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd A up-line-or-history
+/etc/zsh/zshrc:65> bind2maps emacs viins vicmd -- Down down-line-or-history
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=B
+bind2maps:11> widget=down-line-or-history
+bind2maps:13> [[ -z B ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs B down-line-or-history
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins B down-line-or-history
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd B down-line-or-history
+/etc/zsh/zshrc:66> bind2maps emacs -- Left backward-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=D
+bind2maps:11> widget=backward-char
+bind2maps:13> [[ -z D ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs D backward-char
+/etc/zsh/zshrc:67> bind2maps viins vicmd -- Left vi-backward-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=D
+bind2maps:11> widget=vi-backward-char
+bind2maps:13> [[ -z D ]]
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins D vi-backward-char
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd D vi-backward-char
+/etc/zsh/zshrc:68> bind2maps emacs -- Right forward-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ emacs != -- ]]
+bind2maps:5> maps+=( emacs )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=C
+bind2maps:11> widget=forward-char
+bind2maps:13> [[ -z C ]]
+bind2maps:15> i=emacs
+bind2maps:16> bindkey -M emacs C forward-char
+/etc/zsh/zshrc:69> bind2maps viins vicmd -- Right vi-forward-char
+bind2maps:1> local i sequence widget
+bind2maps:2> local -a maps
+bind2maps:4> [[ viins != -- ]]
+bind2maps:5> maps+=( viins )
+bind2maps:6> shift
+bind2maps:4> [[ vicmd != -- ]]
+bind2maps:5> maps+=( vicmd )
+bind2maps:6> shift
+bind2maps:4> [[ -- != -- ]]
+bind2maps:8> shift
+bind2maps:10> sequence=C
+bind2maps:11> widget=vi-forward-char
+bind2maps:13> [[ -z C ]]
+bind2maps:15> i=viins
+bind2maps:16> bindkey -M viins C vi-forward-char
+bind2maps:15> i=vicmd
+bind2maps:16> bindkey -M vicmd C vi-forward-char
+/etc/zsh/zshrc:73> (( 1 ))
+/etc/zsh/zshrc:73> (( 1 ))
+/etc/zsh/zshrc:82> zle -N zle-line-init
+/etc/zsh/zshrc:83> zle -N zle-line-finish
+/etc/zsh/zshrc:91> unfunction bind2maps
+/etc/zsh/zshrc:95> zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin
+/etc/zsh/zshrc:103> (( 1 ))
+/etc/zsh/zshrc:103> unalias run-help
+/etc/zsh/zshrc:104> autoload -Uz run-help
+/etc/zsh/zshrc:109> [[ -z '' ]]
+/etc/zsh/zshrc:110> autoload -U compinit
+/etc/zsh/zshrc:111> compinit
+compinit:70> emulate -L zsh
+compinit:71> setopt extendedglob
+compinit:73> typeset _i_dumpfile _i_files _i_line _i_done _i_dir _i_autodump=1
+compinit:74> typeset _i_tag _i_file _i_addfiles _i_fail=ask _i_check=yes _i_name
+compinit:76> [[ 0 -gt 0 ]]
+compinit:108> typeset -gHA _comps _services _patcomps _postpatcomps
+compinit:113> typeset -gHA _compautos
+compinit:118> typeset -gHA _lastcomp
+compinit:121> [[ -n '' ]]
+compinit:125> typeset -g _comp_dumpfile=/home/user/.zcompdump
+compinit:130> typeset -gHa _comp_options
+compinit:131> _comp_options=( bareglobqual extendedglob glob multibyte multifuncdef nullglob rcexpandparam unset NO_allexport NO_aliases NO_cshnullglob NO_cshjunkiequotes NO_errexit NO_globassign NO_globsubst NO_histsubstpattern NO_ignorebraces NO_ignoreclosebraces NO_kshglob NO_ksharrays NO_kshtypeset NO_markdirs NO_octalzeroes NO_posixbuiltins NO_shwordsplit NO_shglob NO_warncreateglobal )
+compinit:167> typeset -gH _comp_setup='local -A _comp_caller_options;
_comp_caller_options=(${(kv)options[@]});
setopt localoptions localtraps localpatterns ${_comp_options[@]};
local IFS=$'\'' \t\r\n[=13=]'\''
enable -p \| \~ \( \? \* \[ \< \^ \#
exec </dev/null;
trap - ZERR
local -a reply
local REPLY'
+compinit:180> typeset -ga compprefuncs comppostfuncs
+compinit:181> compprefuncs=( )
+compinit:182> comppostfuncs=( )
+compinit:186> : compinit /etc/zsh/zshrc
+compinit:435> typeset _i_wdirs _i_wfiles
+compinit:437> _i_wdirs=( )
+compinit:438> _i_wfiles=( )
+compinit:440> autoload -Uz compaudit
+compinit:441> [[ -n yes ]]
+compinit:442> typeset _i_q
+compinit:443> eval compaudit
+(eval):1> compaudit
+compaudit:174> compaudit
+compaudit:13> emulate -L zsh
+compaudit:14> setopt extendedglob
+compaudit:16> [[ -x /usr/bin/getent ]]
+compaudit:25> (( 0 ))
+compaudit:27> (( 30 == 0 ))
+compaudit:31> set -- // trimmed
+compaudit:38> (( 1 ))
+compaudit:44> fpath=( // trimmed )
+compaudit:49> (( 0 ))
+compaudit:50> local _compdir=''
+compaudit:51> [[ -z '' ]]
+compaudit:51> _compdir=/usr/local/share/zsh/site-functions
+compaudit:55> _i_wdirs=( )
+compaudit:56> _i_wfiles=( )
+compaudit:58> _i_files=( // trimmed )
+compaudit:59> [[ -n /usr/local/share/zsh/site-functions ]]
+compaudit:60> [[ 766 -lt 20 || /usr/local/share/zsh/site-functions == */Base || -d /usr/local/share/zsh/site-functions/Base ]]
+compaudit:82> [[ ask == use ]]
+compaudit:86> local _i_owners=u0u1000
+compaudit:89> local -a _i_exes
+compaudit:90> _i_exes=( /proc/8/exe /proc/8/object/a.out )
+compaudit:94> local _i_exe
+compaudit:99> _i_exe=/proc/8/exe
+compaudit:100> [[ -e /proc/8/exe ]]
+compaudit:101> zmodload -F zsh/stat b:zstat
+compaudit:102> local -A _i_stathash
+compaudit:103> zstat -H _i_stathash /proc/8/exe
+compaudit:104> [[ 0 -ne 0 ]]
+compaudit:108> break
+compaudit:121> _i_wdirs=( /usr/local/share/zsh/site-functions )
+compaudit:130> (( 1 ))
+compaudit:131> local GROUP GROUPMEM _i_pw _i_gid
+compaudit:132> (( UID == EUID ))
+compaudit:133> IFS=: +compaudit:133> read GROUP _i_pw _i_gid GROUPMEM
+compaudit:133> getent group user
+compaudit:138> [[ user == user && -z '' ]]
+compaudit:140> _i_wdirs=( /usr/local/share/zsh/site-functions )
+compaudit:144> [[ -f /etc/debian_version ]]
+compaudit:146> local _i_ulwdirs
+compaudit:147> _i_ulwdirs=( /usr/local/share/zsh/site-functions )
+compaudit:148> _i_wdirs=( )
+compaudit:151> _i_wdirs=( )
+compaudit:152> _i_wfiles=( )
+compaudit:154> case 0:0 (0:0)
+compaudit:155> _i_q=''
+compaudit:161> [[ -n '' ]]
+compaudit:168> return 0
+compinit:468> autoload -Uz compdump compinstall
+compinit:472> _i_done=''
+compinit:474> [[ -f /home/user/.zcompdump ]]
+compinit:475> [[ -n yes ]]
+compinit:476> IFS=' ' +compinit:476> read -rA _i_line
+compinit:477> [[ _i_autodump -eq 1 && 766 -eq 766 && 5.1.1 == 5.1.1 ]]
+compinit:480> . /home/user/.zcompdump
+/home/user/.zcompdump:3> _comps=( // trimmed )
+/home/user/.zcompdump:1341> _services=( // trimmed )
+/home/user/.zcompdump:1384> _patcomps=( '*/(init|rc[0-9S]#).d/*' _init_d 'zf*' _zftp )
+/home/user/.zcompdump:1389> _postpatcomps=( // trimmed )
+/home/user/.zcompdump:1412> _compautos=( _call_program +X )
+/home/user/.zcompdump:1416> zle -C _bash_complete-word .complete-word _bash_completions
+/home/user/.zcompdump:1417> zle -C _bash_list-choices .list-choices _bash_completions
+/home/user/.zcompdump:1418> zle -C _complete_debug .complete-word _complete_debug
+/home/user/.zcompdump:1419> zle -C _complete_help .complete-word _complete_help
+/home/user/.zcompdump:1420> zle -C _complete_tag .complete-word _complete_tag
+/home/user/.zcompdump:1421> zle -C _correct_filename .complete-word _correct_filename
+/home/user/.zcompdump:1422> zle -C _correct_word .complete-word _correct_word
+/home/user/.zcompdump:1423> zle -C _expand_alias .complete-word _expand_alias
+/home/user/.zcompdump:1424> zle -C _expand_word .complete-word _expand_word
+/home/user/.zcompdump:1425> zle -C _history-complete-newer .complete-word _history_complete_word
+/home/user/.zcompdump:1426> zle -C _history-complete-older .complete-word _history_complete_word
+/home/user/.zcompdump:1427> zle -C _list_expansions .list-choices _expand_word
+/home/user/.zcompdump:1428> zle -C _most_recent_file .complete-word _most_recent_file
+/home/user/.zcompdump:1429> zle -C _next_tags .list-choices _next_tags
+/home/user/.zcompdump:1430> zle -C _read_comp .complete-word _read_comp
+/home/user/.zcompdump:1431> bindkey '^X^R' _read_comp
+/home/user/.zcompdump:1432> bindkey '^X?' _complete_debug
+/home/user/.zcompdump:1433> bindkey '^XC' _correct_filename
+/home/user/.zcompdump:1434> bindkey '^Xa' _expand_alias
+/home/user/.zcompdump:1435> bindkey '^Xc' _correct_word
+/home/user/.zcompdump:1436> bindkey '^Xd' _list_expansions
+/home/user/.zcompdump:1437> bindkey '^Xe' _expand_word
+/home/user/.zcompdump:1438> bindkey '^Xh' _complete_help
+/home/user/.zcompdump:1439> bindkey '^Xm' _most_recent_file
+/home/user/.zcompdump:1440> bindkey '^Xn' _next_tags
+/home/user/.zcompdump:1441> bindkey '^Xt' _complete_tag
+/home/user/.zcompdump:1442> bindkey '^X~' _bash_list-choices
+/home/user/.zcompdump:1443> bindkey '^[,' _history-complete-newer
+/home/user/.zcompdump:1444> bindkey '^[/' _history-complete-older
+/home/user/.zcompdump:1445> bindkey '^[~' _bash_complete-word
+/home/user/.zcompdump:1447> // trimmed
+/home/user/.zcompdump:1600> autoload -Uz +X _call_program
+/home/user/.zcompdump:1602> typeset -gUa _comp_assocs
+/home/user/.zcompdump:1603> _comp_assocs=( '' )
+compinit:481> _i_done=yes
+compinit:488> [[ -z yes ]]
+compinit:525> _i_line=complete-word
+compinit:528> zle -C complete-word .complete-word _main_complete
+compinit:525> _i_line=delete-char-or-list
+compinit:528> zle -C delete-char-or-list .delete-char-or-list _main_complete
+compinit:525> _i_line=expand-or-complete
+compinit:528> zle -C expand-or-complete .expand-or-complete _main_complete
+compinit:525> _i_line=expand-or-complete-prefix
+compinit:528> zle -C expand-or-complete-prefix .expand-or-complete-prefix _main_complete
+compinit:525> _i_line=list-choices
+compinit:528> zle -C list-choices .list-choices _main_complete
+compinit:525> _i_line=menu-complete
+compinit:528> zle -C menu-complete .menu-complete _main_complete
+compinit:525> _i_line=menu-expand-or-complete
+compinit:528> zle -C menu-expand-or-complete .menu-expand-or-complete _main_complete
+compinit:525> _i_line=reverse-menu-complete
+compinit:528> zle -C reverse-menu-complete .reverse-menu-complete _main_complete
+compinit:530> zle -la menu-select
+compinit:534> IFS=' ' +compinit:534> read -A _i_line
+compinit:534> bindkey '^i'
+compinit:535> [[ expand-or-complete == expand-or-complete ]]
+compinit:536> zstyle -a :completion: completer _i_line
+compinit:541> unfunction compinit compaudit
+compinit:542> autoload -Uz compinit compaudit
+compinit:544> return 0
吉尔斯:
% ls -ld ~/.z*
+zsh:8> ls -ld /home/user/.zcompdump /home/user/.zcompdump-user-5.1.1 /home/user/.zsh_history /home/user/.zshrc /home/user/.zsh-update
-rw-rw-rw- 1 user user 39206 Apr 17 11:42 /home/user/.zcompdump
-rw-r--r-- 1 user user 39352 Apr 17 11:45 /home/user/.zcompdump-user-5.1.1
-rw------- 1 user user 596 Apr 17 14:09 /home/user/.zsh_history
---------- 1 user user 3132 Apr 17 13:42 /home/user/.zshrc
-rw-rw-rw- 1 user user 17 Apr 17 13:12 /home/user/.zsh-update
% head -n 1 ~/.z*
+zsh:9> head -n 1 /home/user/.zcompdump /home/user/.zcompdump-user-5.1.1 /home/user/.zsh_history /home/user/.zshrc /home/user/.zsh-update
==> /home/user/.zcompdump <==
#files: 766 version: 5.1.1
==> /home/user/.zcompdump-user-5.1.1 <==
#files: 766 version: 5.1.1
==> /home/user/.zsh_history <==
: 1523995979:0;chsh -s /usr/bin/zsh
head: cannot open '/home/user/.zshrc' for reading: Permission denied
==> /home/user/.zsh-update <==
LAST_EPOCH=17638
根据上面的输出,我尝试 sudo chown -R user .zshrc
其中 运行 没有错误,但文件仍然无法读取。
有很多事情 可能会 出错,尽管它们很少出错。
Zsh 启动时读取 a number of files。我不会在这里重复整个列表;对于交互式使用,列表是:
- 系统
zshenv
- 用户
.zshenv
- 系统
zshrc
- 用户
.zshrc
系统目录默认为/etc
,但可能会在编译时更改。它在基于 Debian 的发行版上是 /etc/zsh
,包括 Ubuntu,包括 WSL。用户目录是环境变量 ZDOTDIR
的值(如果已设置(通常未设置)),否则是主目录。
在 zsh 中,运行 echo $ZDOTDIR
查看是否定义了 ZDOTDIR
。如果是,请在以下命令中使用 $ZDOTDIR
而不是 ~
。如果不是,请使用 echo $HOME
检查您的主目录是否符合您的预期。 Windows 上 Unix 层的一个轻微常见问题(但 WSL 通常不存在)是当 shell 启动时您的主目录未设置为您期望的内容。
检查 zsh 从您的主目录加载了哪些文件,并检查它们的内容。
ls -ld ~/.zsh(env|rc)
less ~/.zsh(env|rc)
确保文件名正确。它需要以点开头并且全部小写。检查内容是否符合您的预期。
在您的情况下,ls
显示了问题所在:您没有对 ~/.zshrc
的读取权限。你可以用
chmod u+r ~/.zshrc
虽然损坏的权限可能更普遍地表示您的 WSL 设置或您保存文件的应用程序出现问题。
运行 zsh 与 -x
选项来查看它加载的所有内容的踪迹。这可能非常大。从类 Unix 命令行(sh、bash 或 zsh),您可以将跟踪重定向到文件:
zsh -x 2>zsh.err
按Ctrl+D退出,查看zsh.err
的内容。这显示了所有加载的文件,例如
+/etc/zsh/zshenv:15> [[ -z '// trimmed' == /bin:/usr/bin ]]
+/etc/zsh/zshrc:9> READNULLCMD=/usr/bin/pager
…
执行了zshenv
中的一行代码(其余为空白,注释,或因条件执行而跳过)。没有用户 .zshenv
文件,因此下一行来自系统 zshrc
。你的踪迹中的最后一件事
+compinit:544> return 0
是加载完成系统的最后一行,这是 Debian/Ubuntu/WSL 的系统 zshrc
做的最后一件事。因此,没有用户 .zshrc
(或者更准确地说,没有可读用户 .zshrc
)。