ZSH /etc/zsh/zshrc-未找到函数定义文件

ZSH /etc/zsh/zshrc-未找到函数定义文件

我为多个用户安装了 zsh 和 oh-my-zsh,并且我看到了一篇关于符号链接/root/.zshrc/root/.oh-my-zsh$HOME 路径变量的帖子,以便所有用户都会拥有相同的配置文件。

ln -s $HOME/.oh-my-zsh           /root/.oh-my-zsh
ln -s $HOME/.zshrc               /root/.zshrc

我想过删除所有用户的 zsh 和 oh-my-zsh,然后重新开始,因为我还没有对任何用户进行.zshrc我想要保留的配置。

我在删除一些文件时有点草率,我想我不小心删除了一些不属于安装的内容apt zsh。因为我在 root 用户上再次安装 zsh 后出现了很多错误。

现在我已经以普通用户身份安装了 zsh jonas,并进入 root 权限,当我尝试时,su jonas它显示/etc/zsh/zshrc:112: compinit: function definition file not found

我可以进入 zsh shell,但它没有任何功能。一切都是空白,尽管我已经设置了我的.zshrc文件。

我注意到etc/passwdjonas 用户使用了 zsh,所以我将其更改为 bash。

在 jonas 用户中,系统似乎知道 zsh,但缺少了一些东西。我可以进入 zsh,但它没有任何功能。

然而这有点令人困惑

jonas@L480:/etc/zsh$ zsh
/etc/zsh/zshrc:112: compinit: function definition file not found
L480% echo $SHELL
/bin/bash
jonas@L480:/$ zsh
/etc/zsh/zshrc:112: compinit: function definition file not found
L480% pwd
/
L480% bash
jonas@L480:/$ 

我尝试使用 卸载sudo apt-get --purge remove zsh并重新安装,sudo apt install zsh 但问题仍然存在。zsh 确实有一些默认功能,例如建议导航。

zsh我以 root 身份获得

L480 jonas # zsh
/etc/zsh/zshrc:112: compinit: function definition file not found
/home/jonas/.oh-my-zsh/oh-my-zsh.sh:69: compinit: function definition file not found
/home/jonas/.oh-my-zsh/lib/completion.zsh:76: bashcompinit: function definition file not found
/home/jonas/.oh-my-zsh/lib/directories.zsh:32: command not found: compdef
/home/jonas/.oh-my-zsh/lib/termsupport.zsh:109: add-zsh-hook: function definition file not found
/home/jonas/.oh-my-zsh/lib/termsupport.zsh:110: add-zsh-hook: function definition file not found
/home/jonas/.oh-my-zsh/lib/theme-and-appearance.zsh:2: colors: function definition file not found
/home/jonas/.oh-my-zsh/plugins/git/git.plugin.zsh:19: command not found: compdef
/home/jonas/.oh-my-zsh/plugins/git/git.plugin.zsh:89: command not found: compdef
/home/jonas/.oh-my-zsh/plugins/git/git.plugin.zsh:104: command not found: compdef
/home/jonas/.oh-my-zsh/plugins/git/git.plugin.zsh:109: command not found: compdef
/home/jonas/.oh-my-zsh/plugins/git/git.plugin.zsh:119: command not found: compdef
/home/jonas/.oh-my-zsh/plugins/git/git.plugin.zsh:129: command not found: compdef
/home/jonas/.oh-my-zsh/plugins/git/git.plugin.zsh:138: command not found: compdef
/home/jonas/.oh-my-zsh/plugins/git/git.plugin.zsh:144: command not found: compdef
/home/jonas/.oh-my-zsh/plugins/git/git.plugin.zsh:229: is-at-least: function definition file not found

这是我的etc/zsh/zshrc文件

# /etc/zsh/zshrc: system-wide .zshrc file for zsh(1).
#
# This file is sourced only for interactive shells. It
# should contain commands to set up aliases, functions,
# options, key bindings, etc.
#
# Global Order: zshenv, zprofile, zshrc, zlogin

READNULLCMD=${PAGER:-/usr/bin/pager}
export FPATH="/usr/local/share/zsh/functions:$FPATH"

# An array to note missing features to ease diagnosis in case of problems.
typeset -ga debian_missing_features

if [[ -z "${DEBIAN_PREVENT_KEYBOARD_CHANGES-}" ]] &&
   [[ "$TERM" != 'emacs' ]]
then

    typeset -A key
    key=(
        BackSpace  "${terminfo[kbs]}"
        Home       "${terminfo[khome]}"
        End        "${terminfo[kend]}"
        Insert     "${terminfo[kich1]}"
        Delete     "${terminfo[kdch1]}"
        Up         "${terminfo[kcuu1]}"
        Down       "${terminfo[kcud1]}"
        Left       "${terminfo[kcub1]}"
        Right      "${terminfo[kcuf1]}"
        PageUp     "${terminfo[kpp]}"
        PageDown   "${terminfo[knp]}"
    )

    function bind2maps () {
        local i sequence widget
        local -a maps

        while [[ "$1" != "--" ]]; do
            maps+=( "$1" )
            shift
        done
        shift

        sequence="${key[$1]}"
        widget="$2"

        [[ -z "$sequence" ]] && return 1

        for i in "${maps[@]}"; do
            bindkey -M "$i" "$sequence" "$widget"
        done
    }

    bind2maps emacs             -- BackSpace   backward-delete-char
    bind2maps       viins       -- BackSpace   vi-backward-delete-char
    bind2maps             vicmd -- BackSpace   vi-backward-char
    bind2maps emacs             -- Home        beginning-of-line
    bind2maps       viins vicmd -- Home        vi-beginning-of-line
    bind2maps emacs             -- End         end-of-line
    bind2maps       viins vicmd -- End         vi-end-of-line
    bind2maps emacs viins       -- Insert      overwrite-mode
    bind2maps             vicmd -- Insert      vi-insert
    bind2maps emacs             -- Delete      delete-char
    bind2maps       viins vicmd -- Delete      vi-delete-char
    bind2maps emacs viins vicmd -- Up          up-line-or-history
    bind2maps emacs viins vicmd -- Down        down-line-or-history
    bind2maps emacs             -- Left        backward-char
    bind2maps       viins vicmd -- Left        vi-backward-char
    bind2maps emacs             -- Right       forward-char
    bind2maps       viins vicmd -- Right       vi-forward-char

    # Make sure the terminal is in application mode, when zle is
    # active. Only then are the values from $terminfo valid.
    if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
        function zle-line-init () {
            emulate -L zsh
            printf '%s' ${terminfo[smkx]}
        }
        function zle-line-finish () {
            emulate -L zsh
            printf '%s' ${terminfo[rmkx]}
        }
        zle -N zle-line-init
        zle -N zle-line-finish
    else
        for i in {s,r}mkx; do
            (( ${+terminfo[$i]} )) || debian_missing_features+=($i)
        done
        unset i
    fi

    unfunction bind2maps

fi # [[ -z "$DEBIAN_PREVENT_KEYBOARD_CHANGES" ]] && [[ "$TERM" != 'emacs' ]]

zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
                                           /usr/local/bin  \
                                           /usr/sbin       \
                                           /usr/bin        \
                                           /sbin           \
                                           /bin            \
                                           /usr/X11R6/bin

(( ${+aliases[run-help]} )) && unalias run-help
autoload -Uz run-help

# If you don't want compinit called here, place the line
# skip_global_compinit=1
# in your $ZDOTDIR/.zshenv or $ZDOTDIR/.zprofile
if [[ -z "$skip_global_compinit" ]]; then
  autoload -U compinit
  compinit
fi

相关内容