Win10 環境下安裝配置 zsh

一、在Windows10上安裝Ubantu,然後安裝 zsh

Before we can install zsh or Oh My Zsh, we need to first enable the default shell called Bash. This used to require third-party programs likeCygwin, and you can still do it that way. However, Windows 10 now ships with a Linux subsystem that’s turned off by default. If we turn it on, we’ll be able to run Bash on Windows using native software packages.

1. Open Settings and click on “Updates & Security.”

settings-update-and-security

2. Click “For developers” in the sidebar, then click the radio button next to “Developer mode.”

settings-developer-mode

3. In the pop-up window, click “Yes” to proceed with enabling developer mode.

settings-developer-mode-2

4. Open Control Panel and navigate to the “Programs and Features” menu.

control-panel-programs-features-open

5. Click “Turn Windows features on or off” in the sidebar.

control-panel-turn-windows-features

6. Scroll down and tick the checkbox next to “Windows Subsystem for Linux (Beta)” to enable the Linux subsystem. Then click the “OK” button.

control-panel-turn-on-linux-subsystem

7. Wait for the installer to finish.

windows-features-installing

8. When the installer is finished, click “Restart Now” to restart your computer and complete the installation.

windows-features-restart-now

9. After you’ve restarted your computer, type “bash” into the Start Menu and launch the bash script.

bash-exe-start-menu

10. This will open a command prompt and finish installing UNIX and Bash. Type the “y” key and press “Enter” to confirm installation of the remaining components.

bash-exe-install-script-2

11. Wait while the remaining components are downloaded and configured.

bash-exe-install-script-3

12. When prompted, create a username for Bash and UNIX.

bash-exe-install-script-4

13. Enter a password you’ll use for Bash and UNIX. You won’t see any characters appear as you type, but they are being saved. Press “Enter.”

bash-exe-install-script-5

14. When the installation is finished, you’ll be returned to the command prompt. You can now close this window.

bash-exe-install-script-6

Now that we have a shell on Windows, our next step is to install zsh. We’ll use the “apt-get” package manager to download and install it.

1. Open Bash from the Start Menu.

bash-on-ubuntu-start-menu

2. Type the following command into the command prompt and press “Enter:”

sudo apt-get install zsh

如果安裝不成功,試試:sudo apt-get update,再輸入上面的命令。

bash-apt-get-1

3. Enter your Bash/UNIX password when prompted and press “Enter.”

bash-apt-get-2

4. When prompted, type “Y” and press “Enter” to continue the installation.

bash-apt-get-3

5. When the installation is complete, you’ll be returned to the command prompt.

bash-apt-get-4


二、使用 zsh

Now that we’ve installed zsh, we can start using it.

1. Open Bash from the Start Menu.

bash-on-ubuntu-start-menu

2. Type zsh and press “Enter.”

zsh-launch-zsh

3. On first run, you’ll need to go through some zsh configuration options. There’s a bunch there, but we recommend actually looking at all the information and choosing the options you like. If you’re not sure what to choose, you can just press the “2” key to accept the default configuration.

zsh-configure-zsh

4. When the configuration is complete, you’ll be returned to the zsh command prompt.

zsh-command-prompt

原文鏈接:https://www.maketecheasier.com/install-zsh-and-oh-my-zsh-windows10/


三、安裝 oh-my-zsh

輸入命令(wget):

 

更改主題

$ vi ~/.zshrc 打開zsh配置文件

更改裏面的主題爲“ys”: ZSH_THEME="ys"


四、問題

在安裝完Zsh後,zsh是可以使用的,但是重啓之後,又恢復至默認的bash。
我在安裝好之後,使用命令chsh -s /bin/zsh切換默認shell。
然後,輸出$SHELL變量是這樣的:

root@XY ~ # echo $SHELL
/bin/bash

設置無效,我以爲要重啓。
於是,重新啓動Bash On Ubuntu On Window。
結果依然無效。

辦法

我在BashOnWindows的GitHub上開了一個issues,目前下面的辦法可能是最簡單易行的。

在.bashrc配置文件裏面加上zsh

打開.bashrc文件:

root@XY ~ # vi ~/.bashrc

在文件末尾加上bash -c zsh

然後重新啓動終端即可。

問題原文鏈接:http://www.jianshu.com/p/9a575dda0eff

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章