执行命令 source ~/.bashrc 时出错

执行命令 source ~/.bashrc 时出错
/home/my-pc/.bashrc:16: command not found: shopt
/home/my-pc/.bashrc:24: command not found: shopt
/home/my-pc/.bashrc:111: command not found: shopt
/usr/share/bash-completion/bash_completion:51: command not found: shopt
/usr/share/bash-completion/bash_completion:57: command not found: complete
/usr/share/bash-completion/bash_completion:62: command not found: complete
/usr/share/bash-completion/bash_completion:65: command not found: complete
/usr/share/bash-completion/bash_completion:68: command not found: complete
/usr/share/bash-completion/bash_completion:71: command not found: complete
/usr/share/bash-completion/bash_completion:74: command not found: complete
/usr/share/bash-completion/bash_completion:77: command not found: complete
/usr/share/bash-completion/bash_completion:80: command not found: complete
/usr/share/bash-completion/bash_completion:83: command not found: complete
/usr/share/bash-completion/bash_completion:86: command not found: complete
/usr/share/bash-completion/bash_completion:89: command not found: complete
/usr/share/bash-completion/bash_completion:92: command not found: complete
/usr/share/bash-completion/bash_completion:314: parse error near `\n'
\[\e]0;\u@\h: \w\a\]\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$ 

这是输出

答案1

发生这种情况的原因是 Linux 的默认 shell 设置为 zsh,要更改它,我们可以使用以下命令:

chsh -s /bin/bash

然后获取你的 bash 文件来导出其中存在的路径:

source ~/.bashrc

答案2

如果您的 shell 是 zsh,请在 .bashrc 中进行编辑~/.zshrc

完成后,使用:wq(假设您使用 vim)保存文件并运行以下命令:

source ~/.zshrc

记住删除对 .bashrc 所做的所有更改,以免它被执行两次。

相关内容