天空的诱惑 發表於 2021-7-27 16:16:00

Debian安装zsh和oh-my-zsh

<h1 id="linux下安装zsh和oh-my-zsh">Linux下安装zsh和oh-my-zsh</h1>
<blockquote>
<p>系统:Debian 10.5 (阿里云)</p>
<p>工具:Xshell 6 (Build 0206)</p>
</blockquote>
<h2 id="1zsh的介绍">1.Zsh的介绍</h2>
<p>Zsh(Z-shell)是一款用于交互式使用的shell,也可以作为脚本解释器来使用。其包含了 bash,ksh,tcsh 等其他shell中许多优秀功能,也拥有诸多自身特色。</p>
<p>从 macOS Catalina 版开始,其默认shell从bash改为zsh。</p>
<h2 id="2安装zsh">2.安装Zsh</h2>
<pre><code class="language-shell">sudo apt-get update
sudo apt-get install zsh
chsh -s /bin/zsh #将zsh替换为你的默认shell
</code></pre>
<p><img src="https://raw.githubusercontent.com/lixbao/PicGo/main/img/20210727141220.png" alt="image-20210727141220871" loading="lazy"></p>
<h2 id="3安装git如有请忽略此步">3.安装git(如有请忽略此步)</h2>
<pre><code class="language-shell">sudo apt-get install git
</code></pre>
<h2 id="4安装oh-my-zsh">4.安装oh-my-zsh</h2>
<p>默认的 Zsh 配置有点麻烦。因此一个叫 robbyrussel 的用户在 GitHub 上制作了一个配置文件 oh-my-zsh,这是目前为止最流行的 Zsh 配置:https://github.com/ohmyzsh/ohmyzsh</p>
<p>安装教程在上面仓库的readme文件中有描述(这里以使用curl为例)</p>
<table>
<thead>
<tr>
<th>方式</th>
<th>命令</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>curl</strong></td>
<td><code>sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"</code></td>
</tr>
<tr>
<td><strong>wget</strong></td>
<td><code>sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"</code></td>
</tr>
<tr>
<td><strong>fetch</strong></td>
<td><code>sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"</code></td>
</tr>
</tbody>
</table>
<p><img src="https://raw.githubusercontent.com/lixbao/PicGo/main/img/20210727142721.png" alt="image-20210727142721746" loading="lazy"></p>
<h2 id="5主题配置">5.主题配置</h2>
<p>下载完oh-my-zsh后的默认主题【robbyrussell】效果如上一步效果图</p>
<p>主题详细预览参考仓库中的wiki</p>
<p>https://github.com/robbyrussell/oh-my-zsh/wiki/themes</p>
<p>打开配置文件【~/.zshrc】,直接更改目标位置(esc后键入冒号输入/ZSH_THEME检索)的字符串即可</p>
<p><img src="https://raw.githubusercontent.com/lixbao/PicGo/main/img/20210727142921.png" alt="image-20210727142921803" loading="lazy"></p>
<p>例如配置成【xiong-chiamiov-plus】</p>
<pre><code class="language-shell">ZSH_THEME="xiong-chiamiov-plus"
</code></pre>
<p><img src="https://raw.githubusercontent.com/lixbao/PicGo/main/img/20210727143313.png" alt="image-20210727143312961" loading="lazy"></p>
<h2 id="6插件配置">6.插件配置</h2>
<p>同样插件在仓库wiki也有描述</p>
<p>https://github.com/ohmyzsh/ohmyzsh/wiki/plugins</p>
<p>打开配置文件【~/.zshrc】,直接在目标位置(esc后键入冒号输入/plugins检索)的括号中添加即可</p>
<p><img src="https://raw.githubusercontent.com/lixbao/PicGo/main/img/20210727143938.png" alt="image-20210727143938921" loading="lazy"></p>
<p>其实需要哪个插件就在~/.oh-my-zsh/custom/plugins/中克隆哪个仓库就行了</p>
<p>https://github.com/zsh-users</p>
<p>例如通过上方仓库添加代码高亮与自动补全</p>
<pre><code class="language-shell">cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-autosuggestions.git #自动补全
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git #代码高亮
</code></pre>
<p><img src="https://raw.githubusercontent.com/lixbao/PicGo/main/img/20210727144518.png" alt="image-20210727144518803" loading="lazy"></p>
<p>然后将这两个插件添加到【~/.zshrc】中</p>
<p><img src="https://raw.githubusercontent.com/lixbao/PicGo/main/img/20210727144839.png" alt="image-20210727144839567" loading="lazy"></p>
<p>补全和高亮成功设置</p>
<p><img src="https://raw.githubusercontent.com/lixbao/PicGo/main/img/20210727144915.png" alt="image-20210727144915383" loading="lazy"></p><br><br>
来源:https://www.cnblogs.com/illusory---/p/15066495.html
頁: [1]
查看完整版本: Debian安装zsh和oh-my-zsh