我刚刚在 MacOS 上从 切换到bash
并且zsh
想加载当前的,.bash_profile
因此我这样做了:
- 添加
#!/bin/zsh
到我的.bash_profile
并运行:
% . ~/.bash_profile
我因为这个bash
显示git
分支的命令而陷入困境:
export PS1="\[\033[0;32m\]\u@\h\[\033[00m\]:\[\033[0;33m\]\W\[\033[0;35m\]\$(parse_git_branch)\[\033[00m\]\$ "
而且zsh
就是不让我放弃它。我在网上查过,也试过:control + c, g, x, v
但都不起作用。我对 shell 了解不够,无法弄清楚bash
当我切换到zsh
答案1
对于 Zsh 新手来说,应该这样开始:
- 备份任何现有
rc
文件profile
并将其从用户目录中删除。 - 重启 shell。你将看到以下内容:
This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~). This function can help you with a few settings that should
make your use of the shell easier.
You can:
(q) Quit and do nothing. The function will be run again next time.
(0) Exit, creating the file ~/.zshrc containing just a comment.
That will prevent this function being run again.
(1) Continue to the main menu.
--- Type one of the keys in parentheses ---
- 按1。这将带您进入以下屏幕:
Please pick one of the following options:
(1) Configure settings for history, i.e. command lines remembered
and saved by the shell. (Recommended.)
(2) Configure the new completion system. (Recommended.)
(3) Configure how keys behave when editing command lines. (Recommended.)
(4) Pick some of the more common shell options. These are simple "on"
or "off" switches controlling the shell's features.
(0) Exit, creating a blank ~/.zshrc file.
(a) Abort all settings and start from scratch. Note this will overwrite
any settings from zsh-newuser-install already in the startup file.
It will not alter any of your other settings, however.
(q) Quit and do nothing else. The function will be run again next time.
--- Type one of the keys in parentheses ---
- 从这里开始,通过菜单 1 到 4 来配置事物。
- 最后,按 将0您的设置保存到
~/.zshrc
。 - 重新启动你的终端,开始使用 Z shell,不用担心你的旧点文件。
- 然后,每当你发现你的旧 shell 缺少某个功能时,你可以尝试有选择地将其从旧的点文件中迁移过来。
这样,您遇到的麻烦就会最少,并且您将能够在此过程中清除旧点文件中的大量垃圾。