mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge pull request #28405 from wxy/20221227.1-⭐️⭐️-oh-my-zsh-and-powerlevel10k-A-Match-Made-in-Heaven
ALL:published/20221227.1 ⭐️⭐️ oh my zsh and powerlevel10k A Match Made in Heaven.md
This commit is contained in:
commit
c724dc2bf8
@ -0,0 +1,224 @@
|
||||
[#]: subject: "oh my zsh and powerlevel10k: A Match Made in Heaven"
|
||||
[#]: via: "https://www.debugpoint.com/oh-my-zsh-powerlevel10k/"
|
||||
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "wxy"
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-15432-1.html"
|
||||
|
||||
Oh My Zsh 和 Powerlevel10k:天作之合
|
||||
======
|
||||
|
||||
> 这是一篇快速而简单的指南,用 Oh My Zsh 和 Powerlevel10k 主题改造你的 Zsh 终端 Shell,使其在 Ubuntu 和其他 Linux 发行版中看起来很酷。
|
||||
|
||||
![][1]
|
||||
|
||||
大多数 Linux 发行版中的默认 Shell 是 Bash。Bash 是一个可靠的和传统的工具。然而,它缺乏一些自定义功能,比如漂亮的颜色、光标支持等等。
|
||||
|
||||
你可以使用另一个 Shell,即 Zsh 来得到更多的设置调整,并帮助你扩展你的 Bash Shell 体验。
|
||||
|
||||
这个简单的指南解释了如何安装 Zsh、Oh My Zsh 并应用 Powerlevel10k 主题。
|
||||
|
||||
### Oh My Zsh 和 Powerlevel10k 安装和配置指南
|
||||
|
||||
#### 1、安装 Zsh 和改变 Shell
|
||||
|
||||
打开一个终端,使用以下适用于你的发行版的命令安装 Zsh。
|
||||
|
||||
Ubuntu、Debian、Linux Mint 和所有相关的发行版:
|
||||
|
||||
```
|
||||
sudo apt install zsh
|
||||
```
|
||||
|
||||
Fedora:
|
||||
|
||||
```
|
||||
sudo dnf install zsh
|
||||
```
|
||||
|
||||
Arch:
|
||||
|
||||
```
|
||||
pacman -S zsh
|
||||
```
|
||||
|
||||
安装完成后,找出 Zsh 的安装路径:
|
||||
|
||||
```
|
||||
whereis zsh
|
||||
```
|
||||
|
||||
然后使用当前用户的 Zsh 可执行路径改变 Shell。
|
||||
|
||||
```
|
||||
chsh -s /usr/bin/zsh <用户名 >
|
||||
```
|
||||
|
||||
![改变当前用户的 Shell][2]
|
||||
|
||||
关闭并再次打开终端。然后你应该看到 Zsh 的首次设置。选择选项 2。它将用一个默认的主题改变你的 Shell 提示符的外观,如下图所示:
|
||||
|
||||
![Zsh 的首次设置][3]
|
||||
|
||||
#### 2、安装 Oh My Zsh
|
||||
|
||||
Oh My Zsh 是一套可以进一步定制 Zsh 的脚本。
|
||||
|
||||
首先,我们将从 GitHub 上下载 Oh My Zsh 脚本来安装它。如果你有 `wget` 和 `git` 软件包,那就最好了。如果还没有安装,请使用以下命令 [安装 wget][4] & git:
|
||||
|
||||
```
|
||||
sudo apt install wget
|
||||
sudo apt install git
|
||||
```
|
||||
|
||||
然后用下面的命令安装 Oh My Zsh:
|
||||
|
||||
```
|
||||
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||
```
|
||||
|
||||
然后你应该看到 Oh My Zsh 及默认主题 Robbyrussell 应用到了你的终端。
|
||||
|
||||
![安装 Oh My Zsh 和默认主题][5]
|
||||
|
||||
Oh My Zsh 还附带了其他的主题,你可以 [使用这篇指南][6] 安装它们。然而,在本教程中,我将谈论一个特定的主题,即 Powerlevel10k。
|
||||
|
||||
#### 3、为 Oh My Zsh 安装 Powerlevel10k 主题
|
||||
|
||||
打开终端,运行以下命令,从 GitHub 上克隆 Powerlevel10k 代码库,并将文件放到 Oh My Zsh 的配置文件夹中。
|
||||
|
||||
```
|
||||
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
|
||||
```
|
||||
|
||||
用文本编辑器打开 `~/.zshrc` 文件,将 `ZSH_THEME` 变量设为 `"powerlevel10k/powerlevel10k"`。
|
||||
|
||||
```
|
||||
cd ~
|
||||
```
|
||||
|
||||
```
|
||||
nano .zshrc
|
||||
```
|
||||
|
||||
默认情况下,它应该是 Robbyrussell。删除 `”robbyrussell"`,添加下面的 `"powerlevel10k/powerlevel10k"`。
|
||||
|
||||
更改后,你的 `~/.zshrc` 文件应该是这样的:
|
||||
|
||||
```
|
||||
ZSH_THEME="powerlevel10k/powerlevel10k”
|
||||
```
|
||||
|
||||
保存并关闭该文件(`CTRL+O`、回车和 `CTRL+X`)。
|
||||
|
||||
![改变 Oh My Zsh 主题为 Powerlevel10k][7]
|
||||
|
||||
重新启动你的终端,启动首次向导来设置 Powerlevel10k 主题。
|
||||
|
||||
#### 4、Powerleve10k 的首次设置
|
||||
|
||||
安装后启动终端时,Powerlevel10k 会提示你各种问题以了解你的 Linux 发行版设置。所以,根据你的需要按下键,按照你的口味来定制你的终端。下面是一些问题的例子截图,可以给你一些启发。
|
||||
|
||||
![Powerlevel10k - wizard1][8]
|
||||
|
||||
![Powerlevel10k - wizard2][9]
|
||||
|
||||
最后,你可以保存文件,享受你的终端的新面貌。
|
||||
|
||||
![应用 Powerlevel10k Zsh 主题设置后][10]
|
||||
|
||||
如果你想再次重启配置向导,运行以下程序。你可以随心所欲地做,次数不限。
|
||||
|
||||
```
|
||||
p10k configure
|
||||
```
|
||||
|
||||
基本设置就这样结束了。如果你想了解更多,请继续阅读。
|
||||
|
||||
### 更多配置(高级用法)
|
||||
|
||||
#### 5、安装 Dracula GNOME 终端主题
|
||||
|
||||
如果你使用的是带有原生终端应用的 GNOME 桌面,你可以试试令人惊叹的 Drakula 主题。要做到这一点,打开一个终端,运行下面的命令来下载该主题:
|
||||
|
||||
```
|
||||
git clone https://github.com/dracula/gnome-terminalcd gnome-terminal
|
||||
```
|
||||
|
||||
打开 GNOME “终端”应用,进入偏好设置。通过点击 “+” 添加一个新的配置文件,并命名为 “drakula”。然后进入颜色标签,取消勾选 “<ruby>使用系统主题的颜色<rt>use colors from system theme</rt></ruby>” 选项。
|
||||
|
||||
![为终端创建一个新的配置文件][11]
|
||||
|
||||
回到终端,运行以下程序。当出现提示时,选择你刚才创建的配置文件名称,如上所述。
|
||||
|
||||
```
|
||||
./install.sh
|
||||
```
|
||||
|
||||
![为 GNOME “终端”应用 Drakula 主题][12]
|
||||
|
||||
一旦安装完成,回到偏好设置中,将 Drakula 配置文件标记为默认。
|
||||
|
||||
#### 6、Zsh 的自动补完和语法高亮
|
||||
|
||||
你可能想试试由社区开发的两个可用于 Zsh 的插件。它们是 zsh-autosuggestions 和 zsh-syntax-highlighting。
|
||||
|
||||
打开终端,运行以下程序,下载 zsh-autosuggestions,并将其放在插件文件夹中:
|
||||
|
||||
```
|
||||
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
|
||||
```
|
||||
|
||||
同样地,为语法高亮插件运行以下程序:
|
||||
|
||||
```
|
||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
|
||||
```
|
||||
|
||||
通过文本编辑器打开 `~/.zshrc`文件(使用以下命令),并找到 `plugins=(git)` 一行。并将其替换为以下内容:
|
||||
|
||||
```
|
||||
nano ~/.zshrc
|
||||
```
|
||||
|
||||
```
|
||||
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
|
||||
```
|
||||
|
||||
使用 `CTRL+O`、回车和 `CTRL+X` 保存并关闭该文件。
|
||||
|
||||
关闭并打开你的终端。现在,你应该可以使用自动建议和语法高亮了。
|
||||
|
||||
### 总结
|
||||
|
||||
这样就好了!你现在应该已经在你的系统上安装了 Oh My Zsh 和 Powerlevel10k 主题。你可以根据自己的需要,进一步定制 Powerlevel10k 主题的外观和行为。
|
||||
|
||||
干杯。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.debugpoint.com/oh-my-zsh-powerlevel10k/
|
||||
|
||||
作者:[Arindam][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.debugpoint.com/author/admin1/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://www.debugpoint.com/wp-content/uploads/2022/12/ohp10k.jpg
|
||||
[2]: https://www.debugpoint.com/wp-content/uploads/2022/12/change-the-shell-for-the-current-user.jpg
|
||||
[3]: https://www.debugpoint.com/wp-content/uploads/2022/12/first-time-setup-for-zsh.jpg
|
||||
[4]: https://www.debugpoint.com/wget-not-found-error/
|
||||
[5]: https://www.debugpoint.com/wp-content/uploads/2022/12/Install-oh-my-zsh-and-default-theme.jpg
|
||||
[6]: https://www.debugpoint.com/install-use-zsh/
|
||||
[7]: https://www.debugpoint.com/wp-content/uploads/2022/12/change-oh-my-zsh-theme-to-powerlevel10k.jpg
|
||||
[8]: https://www.debugpoint.com/wp-content/uploads/2022/12/powerlevel10k-wizard1.jpg
|
||||
[9]: https://www.debugpoint.com/wp-content/uploads/2022/12/powerlevel10k-wizard-2.jpg
|
||||
[10]: https://www.debugpoint.com/wp-content/uploads/2022/12/After-applying-settings-in-powerlevel10k-zsh-theme.jpg
|
||||
[11]: https://www.debugpoint.com/wp-content/uploads/2022/12/create-a-new-profile-for-terminal.jpg
|
||||
[12]: https://www.debugpoint.com/wp-content/uploads/2022/12/applying-the-drakula-theme-for-gnome-terminal.jpg
|
@ -1,222 +0,0 @@
|
||||
[#]: subject: "oh my zsh and powerlevel10k: A Match Made in Heaven"
|
||||
[#]: via: "https://www.debugpoint.com/oh-my-zsh-powerlevel10k/"
|
||||
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: " "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
oh my zsh and powerlevel10k: A Match Made in Heaven
|
||||
======
|
||||
|
||||
**A quick and simple guide to transforming your zsh terminal shell with oh my zsh and powerlevel10k theme to make it look cool in Ubuntu and other Linux distros.**
|
||||
|
||||
![][1]
|
||||
|
||||
The default shell in most of the Linux distributions is bash. Bash is solid and a legacy utility. However, it lacks some customizations, such as nice colours, cursor support, etc.
|
||||
|
||||
You can use another shell, zsh to enjoy additional tweaks and help you to extend your Bash shell experience.
|
||||
|
||||
This crisp guide explains how to install zsh, oh my zsh and apply the powerlevel10k theme.
|
||||
|
||||
### oh my zsh and powerlevel10k: Installation and configuration guide
|
||||
|
||||
#### 1. Installing zsh and changing the shell
|
||||
|
||||
Open a terminal and install zsh using the following command applicable to your distribution.
|
||||
|
||||
**_Ubuntu, Debian, Linux Mint and all related distro_**
|
||||
|
||||
```
|
||||
sudo apt install zsh
|
||||
```
|
||||
|
||||
_**Fedora**_
|
||||
|
||||
```
|
||||
sudo dnf install zsh
|
||||
```
|
||||
|
||||
**_Arch_**
|
||||
|
||||
```
|
||||
pacman -S zsh
|
||||
```
|
||||
|
||||
After installation is complete, find out the zsh install path
|
||||
|
||||
```
|
||||
whereis zsh
|
||||
```
|
||||
|
||||
Then change the shell using the zsh executable path for the current user.
|
||||
|
||||
```
|
||||
chsh -s /usr/bin/zsh <username>
|
||||
```
|
||||
|
||||
![change the shell for the current user][2]
|
||||
|
||||
Close and open the terminal again. And you should see the first-time setup for zsh. Select option 2. And it will change the look of your shell prompt with a default theme, as shown below.
|
||||
|
||||
![first time setup for zsh][3]
|
||||
|
||||
#### 2. Install oh my zsh
|
||||
|
||||
The oh my zsh is a set of scripts to customize zsh further.
|
||||
|
||||
Firstly, we will install oh my zsh script by downloading it from GitHub. It would be best if you had wget and git package for that. [Install wget][4] & git using the following command if it’s not installed.
|
||||
|
||||
```
|
||||
sudo apt install wget
|
||||
sudo apt install git
|
||||
```
|
||||
|
||||
Then install oh my zsh using the following command.
|
||||
|
||||
```
|
||||
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||
```
|
||||
|
||||
And you should see the oh my zsh theme is applied with a default theme robbyrussell to your terminal.
|
||||
|
||||
![Install oh my zsh and default theme][5]
|
||||
|
||||
The Oh my zsh also comes with additional themes, and you can install them [using this guide][6]. However, in this tutorial, I will talk about a specific theme, i.e. powerlevel10k.
|
||||
|
||||
#### 3. Install powerlevel10k theme for oh my zsh
|
||||
|
||||
Open a terminal and run the following command to clone powerlevel10k repo from GitHub and put the files in the config folder of oh my zsh.
|
||||
|
||||
```
|
||||
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
|
||||
```
|
||||
|
||||
Open the `~/.zshrc` file in a text editor and set the `ZSH_THEME` variable to `"powerlevel10k/powerlevel10k"`.
|
||||
|
||||
```
|
||||
cd ~
|
||||
```
|
||||
|
||||
```
|
||||
nano .zshrc
|
||||
```
|
||||
|
||||
By default, it should be robbyrussell. Remove “robbyrussell” and add the below `"powerlevel10k/powerlevel10k"`.
|
||||
|
||||
Your `~/.zshrc` file should look something like this after the change:
|
||||
|
||||
`ZSH_THEME="powerlevel10k/powerlevel10k"`
|
||||
|
||||
Save and close the file (CTRL+O, ENTER and CTRL+X).
|
||||
|
||||
![change oh my zsh theme to powerlevel10k][7]
|
||||
|
||||
Restart your terminal to launch the first-time wizard to set up the powerlevel10k theme.
|
||||
|
||||
#### 4. First time set up for powerleve10k
|
||||
|
||||
When you launch the terminal after the installation, the powerlevel10k prompts you with various questions to understand your Linux distro setup. So, press the key as per your need to customize your terminal as per your taste. Some example screenshots of questions are below to give you some idea.
|
||||
|
||||
![powerlevel10k - wizard1][8]
|
||||
|
||||
![powerlevel10k - wizard 2][9]
|
||||
|
||||
And finally, you can save the file to enjoy the new look of your terminal.
|
||||
|
||||
![After applying settings in powerlevel10k zsh theme][10]
|
||||
|
||||
If you want to restart the configuration wizard again, run the following. You can do it as many times as you want.
|
||||
|
||||
```
|
||||
p10k configure
|
||||
```
|
||||
|
||||
This concludes the basic setup. If you want more, follow along.
|
||||
|
||||
### More configuration (advanced usage)
|
||||
|
||||
#### 5. Installing dracula GNOME Terminal theme
|
||||
|
||||
If you are using GNOME desktop with the native terminal, you can try the stunning drakula theme. To do that, open a terminal and run the following command to download the theme.
|
||||
|
||||
```
|
||||
git clone https://github.com/dracula/gnome-terminalcd gnome-terminal
|
||||
```
|
||||
|
||||
Open GNOME Terminal and go to preferences. Add a new profile by clicking on the [+] and name it “drakula”. Then go to colours tab and uncheck ‘use colors from system theme’ option.
|
||||
|
||||
![create a new profile for terminal][11]
|
||||
|
||||
Go back to the terminal and run the following. When prompted, select the profile name which you just created as above.
|
||||
|
||||
```
|
||||
./install.sh
|
||||
```
|
||||
|
||||
![applying the drakula theme for gnome terminal][12]
|
||||
|
||||
Once the installation is complete, go back to preferences and mark the drakula profile as default.
|
||||
|
||||
#### 6. Autocomplete and syntax highlighting for zsh
|
||||
|
||||
There are two community-developed plugins available for zsh, which you may want to try out. They are zsh-autosuggestions and zsh-syntax-highlighting.
|
||||
|
||||
Open a terminal and run the following to download zsh-autosuggestions and put it inside the plugin folder.
|
||||
|
||||
```
|
||||
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
|
||||
```
|
||||
|
||||
Similarly, run the following for the syntax highlighting plugin.
|
||||
|
||||
```
|
||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
|
||||
```
|
||||
|
||||
Open the ~/.zshrc file via a text editor (use the following command), and find the plugins=(git) line. And replace it with the following:
|
||||
|
||||
```
|
||||
nano ~/.zshrc
|
||||
```
|
||||
|
||||
```
|
||||
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
|
||||
```
|
||||
|
||||
Save & close the file using CTRL+O, ENTER and CTRL+X.
|
||||
|
||||
Close and open your terminal; now, you should be able to use the auto-suggestions and syntax highlighting.
|
||||
|
||||
### Wrapping Up
|
||||
|
||||
That’s it! You should now have “Oh My Zsh” and the Powerlevel10k theme installed on your system. You can customize the appearance and behaviour of the Powerlevel10k theme by customizing further as per your need.
|
||||
|
||||
Cheers.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.debugpoint.com/oh-my-zsh-powerlevel10k/
|
||||
|
||||
作者:[Arindam][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.debugpoint.com/author/admin1/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://www.debugpoint.com/wp-content/uploads/2022/12/ohp10k.jpg
|
||||
[2]: https://www.debugpoint.com/wp-content/uploads/2022/12/change-the-shell-for-the-current-user.jpg
|
||||
[3]: https://www.debugpoint.com/wp-content/uploads/2022/12/first-time-setup-for-zsh.jpg
|
||||
[4]: https://www.debugpoint.com/wget-not-found-error/
|
||||
[5]: https://www.debugpoint.com/wp-content/uploads/2022/12/Install-oh-my-zsh-and-default-theme.jpg
|
||||
[6]: https://www.debugpoint.com/install-use-zsh/
|
||||
[7]: https://www.debugpoint.com/wp-content/uploads/2022/12/change-oh-my-zsh-theme-to-powerlevel10k.jpg
|
||||
[8]: https://www.debugpoint.com/wp-content/uploads/2022/12/powerlevel10k-wizard1.jpg
|
||||
[9]: https://www.debugpoint.com/wp-content/uploads/2022/12/powerlevel10k-wizard-2.jpg
|
||||
[10]: https://www.debugpoint.com/wp-content/uploads/2022/12/After-applying-settings-in-powerlevel10k-zsh-theme.jpg
|
||||
[11]: https://www.debugpoint.com/wp-content/uploads/2022/12/create-a-new-profile-for-terminal.jpg
|
||||
[12]: https://www.debugpoint.com/wp-content/uploads/2022/12/applying-the-drakula-theme-for-gnome-terminal.jpg
|
Loading…
Reference in New Issue
Block a user