为什么赢得.zshrc加载?

时间:2018-04-17 21:04:43

标签: windows-10 zsh windows-subsystem-for-linux

我使用cmder在Windows 10上的ubuntu上运行zsh。我试图让我的Zsh主题继续运行。由于某种原因,我的.zshrc文件未被调用。我确认zsh实际上正在运行:

% zsh --version
zsh 5.1.1 (x86_64-ubuntu-linux-gnu)
% echo $0
zsh

我已经确认vars不存在:

% 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

不确定这是否是最新的Windows Subsystem for Linux安装的结果(截至今天是新的) - 新安装位于user\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79blahblah\LocalState\rootfs\home\user - 或者如果我刚刚在我的元素之外。提前感谢您的建议。

zsh -x输出,根据Gilles:

% 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\0'\''
             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运行没有错误,但文件仍然无法读取。

1 个答案:

答案 0 :(得分:1)

Zsh在启动时会读取a number of files。我不会在这里重复整个清单;对于交互式使用,列表是:

  1. system zshenv
  2. 用户.zshenv
  3. system zshrc
  4. 用户.zshrc
  5. 默认情况下,系统目录为/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设置或保存文件的应用程序更常出现错误的迹象。

    使用-x选项运行zsh以查看其加载的所有内容的跟踪。这可能非常大。从类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)。

相关问题