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.”

Win10 环境下安装配置 zsh_第1张图片

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

Win10 环境下安装配置 zsh_第2张图片

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

Win10 环境下安装配置 zsh_第3张图片

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

Win10 环境下安装配置 zsh_第4张图片

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

Win10 环境下安装配置 zsh_第5张图片

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

Win10 环境下安装配置 zsh_第6张图片

7. Wait for the installer to finish.

Win10 环境下安装配置 zsh_第7张图片

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

Win10 环境下安装配置 zsh_第8张图片

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

Win10 环境下安装配置 zsh_第9张图片

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.

Win10 环境下安装配置 zsh_第10张图片

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

Win10 环境下安装配置 zsh_第11张图片

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

Win10 环境下安装配置 zsh_第12张图片

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.”

Win10 环境下安装配置 zsh_第13张图片

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

Win10 环境下安装配置 zsh_第14张图片

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.

Win10 环境下安装配置 zsh_第15张图片

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

sudo apt-get install zsh

如果安装不成功,试试:sudo apt-get update,再输入上面的命令。

Win10 环境下安装配置 zsh_第16张图片

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

Win10 环境下安装配置 zsh_第17张图片

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

Win10 环境下安装配置 zsh_第18张图片

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

Win10 环境下安装配置 zsh_第19张图片


二、使用 zsh

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

1. Open Bash from the Start Menu.

Win10 环境下安装配置 zsh_第20张图片

2. Type zsh and press “Enter.”

Win10 环境下安装配置 zsh_第21张图片

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.

Win10 环境下安装配置 zsh_第22张图片

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

Win10 环境下安装配置 zsh_第23张图片

原文链接: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

你可能感兴趣的:(Linux,环境,zsh,Win10)