+-
【WSL】WSL折腾之旅(2)安装ZSH和Docker
首页 专栏 docker 文章详情
0

【WSL】WSL折腾之旅(2)安装ZSH和Docker

爱折腾的小码农 发布于 3 月 8 日
前一篇已设置默认为root用户,故所有命令省略sudo,非root用户需在命令前自行添加sudo
ZSH

1.1 安装zsh

通过命令apt-get install zsh直接安装。

通过命令chsh -s /bin/zsh替换默认的Shell。

1.2 安装oh-my-zsh

(1)安装

原安装命令为:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

但由于https://raw.github.com网址可能无法访问,会报如下错误:

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

改为gitee.com的网址执行命令:

sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"

(2)修改主题

安装完成后,执行vi ~/.zshrc编辑文件,修改主题为agnoster

(3)隐藏机器名

编辑 agnoster 主题文件,修改第92行,删除最后的@%m

vi ~/.oh-my-zsh/themes/agnoster.zsh-theme

设置完成后,wsl终端美化完成。

1.3 安装oh-my-zsh插件

安装 zsh-syntax-higlighting语法高亮插件

(1)Git下载

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

(2)移动至oh-my-zsh插件文件夹

mv zsh-syntax-highlighting $ZSH_CUSTOM/plugins

(3)编辑.zshrc文件,如图示添加内容

(4)配置生效

source ~/.zshrc

安装 zsh-autosuggestions语法历史记录插件

Git下载

git clone https://github.com/zsh-users/zsh-autosuggestions.git

其余步骤同上

安装插件后zsh提示 Insecure completion-dependent directories detected解决方法:

chmod -R 755 [dir]

[dir]为提示有问题的目录。

Docker

2.1 安装Docker

(1)安装软件包以允许 apt 通过 HTTPS 使用存储库

apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

(2)信任Docker的GPG公钥

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

(3)对于amd64架构的计算机,添加软件仓库

add-apt-repository "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

(4)安装Docker

apt-get update sudo apt-get install docker-ce

2.2 运行Docker

(1)启动Docker

service docker start

(2)查看Docker版本

docker version

(3)运行hello-world

docker run hello-world

2.3 设置Docker开机自启

(1)编辑/etc/init.wsl文件,添加service docker start

vi /etc/init.wsl

(2)打开Windows注册表,在计算机HKEY_CURRENT_USERSOFTWAREMicrosoftWindowsCurrentVersionRun下添加一个REG_SZ 类型的值,名称可自定义,值为mshta vbscript:CreateObject("WScript.Shell").Run("wsl -d Ubuntu-20.04 -u root bash /etc/init.wsl",0,TRUE)(window.close)

注:编辑/etc/init.wsl文件可添加其他开机自启的服务。

zsh docker WSL2
阅读 131 更新于 3 月 8 日
收藏
分享
本作品系原创, 采用《署名-非商业性使用-禁止演绎 4.0 国际》许可协议
avatar
爱折腾的小码农
1 声望
0 粉丝
关注作者
0 条评论
得票 时间
提交评论
avatar
爱折腾的小码农
1 声望
0 粉丝
关注作者
宣传栏
目录
前一篇已设置默认为root用户,故所有命令省略sudo,非root用户需在命令前自行添加sudo
ZSH

1.1 安装zsh

通过命令apt-get install zsh直接安装。

通过命令chsh -s /bin/zsh替换默认的Shell。

1.2 安装oh-my-zsh

(1)安装

原安装命令为:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

但由于https://raw.github.com网址可能无法访问,会报如下错误:

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

改为gitee.com的网址执行命令:

sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"

(2)修改主题

安装完成后,执行vi ~/.zshrc编辑文件,修改主题为agnoster

(3)隐藏机器名

编辑 agnoster 主题文件,修改第92行,删除最后的@%m

vi ~/.oh-my-zsh/themes/agnoster.zsh-theme

设置完成后,wsl终端美化完成。

1.3 安装oh-my-zsh插件

安装 zsh-syntax-higlighting语法高亮插件

(1)Git下载

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

(2)移动至oh-my-zsh插件文件夹

mv zsh-syntax-highlighting $ZSH_CUSTOM/plugins

(3)编辑.zshrc文件,如图示添加内容

(4)配置生效

source ~/.zshrc

安装 zsh-autosuggestions语法历史记录插件

Git下载

git clone https://github.com/zsh-users/zsh-autosuggestions.git

其余步骤同上

安装插件后zsh提示 Insecure completion-dependent directories detected解决方法:

chmod -R 755 [dir]

[dir]为提示有问题的目录。

Docker

2.1 安装Docker

(1)安装软件包以允许 apt 通过 HTTPS 使用存储库

apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

(2)信任Docker的GPG公钥

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

(3)对于amd64架构的计算机,添加软件仓库

add-apt-repository "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

(4)安装Docker

apt-get update sudo apt-get install docker-ce

2.2 运行Docker

(1)启动Docker

service docker start

(2)查看Docker版本

docker version

(3)运行hello-world

docker run hello-world

2.3 设置Docker开机自启

(1)编辑/etc/init.wsl文件,添加service docker start

vi /etc/init.wsl

(2)打开Windows注册表,在计算机HKEY_CURRENT_USERSOFTWAREMicrosoftWindowsCurrentVersionRun下添加一个REG_SZ 类型的值,名称可自定义,值为mshta vbscript:CreateObject("WScript.Shell").Run("wsl -d Ubuntu-20.04 -u root bash /etc/init.wsl",0,TRUE)(window.close)

注:编辑/etc/init.wsl文件可添加其他开机自启的服务。