diff --git a/source/_posts/Linux.md b/source/_posts/Linux.md index 4254f24..cc95ea2 100644 --- a/source/_posts/Linux.md +++ b/source/_posts/Linux.md @@ -2345,10 +2345,33 @@ dnf install -y zsh ### 脚本安装 +| **Method** | **Command** | +| ------------------------------------------------ | ------------------------------------------------------------ | +| **curl** | `sh -c "$(curl -fsSL https://install.ohmyz.sh/)"` | +| **wget** | `sh -c "$(wget -O- https://install.ohmyz.sh/)"` | +| **fetch** | `sh -c "$(fetch -o - https://install.ohmyz.sh/)"` | +| 国内curl[镜像](https://gitee.com/pocmon/ohmyzsh) | `sh -c "$(curl -fsSL https://gitee.com/pocmon/ohmyzsh/raw/master/tools/install.sh)"` | +| 国内wget[镜像](https://gitee.com/pocmon/ohmyzsh) | `sh -c "$(wget -O- https://gitee.com/pocmon/ohmyzsh/raw/master/tools/install.sh)"` | + +注意:同意使用 Oh-my-zsh 的配置模板覆盖已有的 `.zshrc`。 + +![image-20250417105106956](http://minio.wenyongdalucky.club:9000/hexo/image-20250417105106956.png) + +### 从`.bashrc`中迁移配置(可选) + +如果之前在使用`bash`时自定义了一些环境变量、别名等,那么在切换到`zsh`后,你需要手动迁移这些自定义配置。 + ```shell -sh -c "$(wget -O- https://install.ohmyz.sh/)" +# 查看bash配置文件,并手动复制自定义配置 +cat ~/.bashrc +# 编辑zsh配置文件,并粘贴自定义配置 +vim ~/.zshrc +# 启动新的zsh配置 +source ~/.zshrc ``` +`root`用户在执行`sudo su`命令后,再运行上述代码查看、手动复制、粘贴自定义配置。 + ### 配置 ```shell @@ -2375,8 +2398,100 @@ echo $SHELL #### Powerlevel10K -```shell +根据 [What’s the best theme for Oh My Zsh?](https://www.slant.co/topics/7553/~theme-for-oh-my-zsh) 中的排名,以及自定义化、美观程度,强烈建议使用 [powerlevel10k](https://github.com/romkatv/powerlevel10k) 主题。 +```shell +git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k + +# 中国用户可以使用 gitee.com 上的官方镜像加速下载 +git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k +``` + +在 `~/.zshrc` 设置 `ZSH_THEME="powerlevel10k/powerlevel10k"`。接下来,终端会自动引导你配置 `powerlevel10k`。 + +### 插件 + +> `oh-my-zsh` 已经内置了 `git` 插件,内置插件可以在 `~/.oh-my-zsh/plugins` 中查看,下面介绍一下我常用的插件,更多插件可以在 [awesome-zsh-plugins](https://github.com/unixorn/awesome-zsh-plugins) 里查看。 + +#### zsh -autosuggestions + +[zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions) 是一个命令提示插件,当你输入命令时,会自动推测你可能需要输入的命令,按下右键可以快速采用建议。 + +![zsh-autosuggestions自动补全](https://cdn.haoyep.com/gh/leegical/Blog_img/cdnimg/202401012250028.png) + +安装方式:把插件下载到本地的 `~/.oh-my-zsh/custom/plugins` 目录。 + +```shell +git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions + +# 中国用户可以使用下面任意一个加速下载 +# 加速1 +git clone https://github.moeyy.xyz/https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions +# 加速2 +git clone https://gh.xmly.dev/https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions +# 加速3 +git clone https://gh.api.99988866.xyz/https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions +``` + +#### zsh-syntax-highlighting + +[zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting) 是一个命令语法校验插件,在输入命令的过程中,若指令不合法,则指令显示为红色,若指令合法就会显示为绿色。 + +![命令语法校验](https://cdn.haoyep.com/gh/leegical/Blog_img/cdnimg/202401012252786.png) + +安装方式:把插件下载到本地的 `~/.oh-my-zsh/custom/plugins` 目录。 + +```shell +git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting + +# 中国用户可以使用下面任意一个加速下载 +# 加速1 +git clone https://github.moeyy.xyz/https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting +# 加速2 +git clone https://gh.xmly.dev/https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting +# 加速3 +git clone https://gh.api.99988866.xyz/https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting +``` + +#### z + +`oh-my-zsh` 内置了 `z` 插件。`z` 是一个文件夹快捷跳转插件,对于曾经跳转过的目录,只需要输入最终目标文件夹名称,就可以快速跳转,避免再输入长串路径,提高切换文件夹的效率。 + +![使用z跳转目录](https://cdn.haoyep.com/gh/leegical/Blog_img/cdnimg/202401012254065.png) + +#### extract + +`oh-my-zsh` 内置了 `extract` 插件。`extract` 用于解压任何压缩文件,不必根据压缩文件的后缀名来记忆压缩软件。使用 `x` 命令即可解压文件。 + +![extract 解压](https://cdn.haoyep.com/gh/leegical/Blog_img/cdnimg/202401012259966.png) + +#### web-search + +oh-my-zsh 内置了 `web-search` 插件。`web-search` 能让我们在命令行中使用搜索引擎进行搜索。使用`搜索引擎关键字+搜索内容` 即可自动打开浏览器进行搜索。效果如下: + +![web-search搜索](https://cdn.haoyep.com/gh/leegical/Blog_img/cdnimg/202401012302476.png) + +### 启用插件 + +修改`~/.zshrc`中插件列表为: + +```shell +plugins=(git zsh-autosuggestions zsh-syntax-highlighting z extract web-search) +``` + +开启新的 Shell 或执行 `source ~/.zshrc`,就可以开始体验插件。 + +### 卸载 + +```shell +uninstall_oh_my_zsh +Are you sure you want to remove Oh My Zsh? [y/N] Y +``` + +### 手动更新 + +```shell +upgrade_oh_my_zsh ``` 安装Nerd Fonts @@ -2566,4 +2681,3 @@ Environment="JAVA_OPTS=-Djava.awt.headless=true -Duser.language=C.UTF-8" systemctl daemon-reload ``` - diff --git a/source/_posts/VsCode.md b/source/_posts/VsCode.md index c522ebb..c16b84d 100644 --- a/source/_posts/VsCode.md +++ b/source/_posts/VsCode.md @@ -81,3 +81,11 @@ Windows `~/.ssh` 目录属性中 安全 -> 高级 再次点击确定 重复上述步骤,将 当前系统登录用户 添加,不需要勾选完全控制 即可 + +# 问题 + +## 解决VSCode使用微软账户同步设置后,再打开需要重新登录的问题 + +在设置中搜索Microsoft-sovereign-cloud: Environment +修改为ChinaCloud +