Skip to content

Commit 4250418

Browse files
committed
Ch02: Reorganize terminal personalization
1 parent 71951e4 commit 4250418

File tree

1 file changed

+80
-15
lines changed

1 file changed

+80
-15
lines changed

docs/Ch02/supplement.md

Lines changed: 80 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ $ sudo reboot
5757
$ sudo reboot
5858
```
5959

60-
## GNOME 相关
60+
## 桌面环境个性化 {#desktop-personalization}
6161

62-
### GNOME 桌面环境的个性化 {#gnome-personalization}
62+
### GNOME
63+
64+
#### GNOME 主题 {#gnome-themes}
6365

6466
大部分桌面环境都支持主题的个性化。例如:窗口样式,按钮样式,Dock 样式,指针样式等等。
6567

@@ -175,7 +177,7 @@ $ gnome-extensions-app
175177

176178
这是一款[第三方开发](https://github.com/mjakeman/extension-manager)的 GNOME 扩展管理工具,功能更强大。
177179

178-
## Xfce 联网下载安装更多主题 {#xfce-themes}
180+
### Xfce
179181

180182
除了系统自带的外观样式和图标外,网络上有更多的主题提供下载。例如在 [Xfce-look](https://www.xfce-look.org/) 上,就有上万个不同类型的主题。安装方法也十分简单。
181183

@@ -233,11 +235,22 @@ $ gnome-extensions-app
233235
$ echo $SHELL
234236
```
235237

236-
检查目前我们正在用的是什么 Shell。Ubuntu 默认使用 Bash,在这里推荐一个更加强大的 Shell 工具——Z shell(Zsh)。
238+
检查目前我们正在用的是什么 Shell。Ubuntu 默认使用 Bash,但是可以使用 `chsh` 命令来更换 Shell。
239+
240+
```console
241+
$ # 列出系统中可用的 shell
242+
$ chsh -l
243+
$ # 更换到 zsh
244+
$ chsh -s /bin/zsh
245+
$ # 更换到 fish
246+
$ chsh -s /bin/fish
247+
$ # 更换回 bash
248+
$ chsh -s /bin/bash
249+
```
237250

238-
#### Zsh
251+
### Zsh 与 oh-my-zsh {#zsh-ohmyzsh}
239252

240-
首先通过 apt 安装 `zsh`
253+
Z shell(Zsh)是一个功能强大的 shell。首先通过 apt 安装 `zsh`
241254

242255
```console
243256
$ sudo apt install zsh
@@ -249,15 +262,7 @@ $ sudo apt install zsh
249262
$ chsh -s /bin/zsh
250263
```
251264

252-
重启后打开终端就会发现 shell 已经变成了 zsh。
253-
254-
第一次打开 zsh 会有首次使用提示,这里我们按 0 跳过。
255-
256-
接下来的提示中按 Y 回车即安装。
257-
258-
然而这时的 zsh 仍然是黑底白字,要让它变好看,我们需要对 zsh 进行配置。
259-
260-
##### oh-my-zsh
265+
重启后打开终端就会发现 shell 已经变成了 zsh。然而这时的 zsh 仍然是黑底白字,要让它变好看,我们需要对 zsh 进行配置。
261266

262267
oh-my-zsh 是一个管理 zsh 配置的框架,评价也非常好。
263268

@@ -287,6 +292,66 @@ $ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/t
287292
具体主题可以在 [oh-my-zsh 的项目 Wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) 中找到。
288293
当然你也可以尝试自己做一个主题。
289294

295+
### Fish {#fish}
296+
297+
Fish 是一个用户友好的命令行 shell,安装也非常简单:
298+
299+
```console
300+
$ sudo apt install fish
301+
```
302+
303+
将 fish 设定为默认 shell:
304+
305+
```console
306+
$ chsh -s /bin/fish
307+
```
308+
309+
Fish 基本不需要配置,开箱即用。需要注意的是,**Fish 不兼容 POSIX 标准**,因此 Bash 等 POSIX shell 下的脚本在 Fish 下是无法运行的。
310+
311+
### Bash 的个性化 {#bash-personalization}
312+
313+
即使不想更换 shell,我们也可以对 Bash 进行个性化配置。以下提供一种配置的选择,以供参考。
314+
315+
首先使用 [starship](https://starship.rs/) 来美化 Bash 的提示符:
316+
317+
```console
318+
$ curl -sS https://starship.rs/install.sh | sh
319+
```
320+
321+
然后在 `~/.bashrc` 文件的末尾添加以下内容:
322+
323+
```shell
324+
eval "$(starship init bash)"
325+
```
326+
327+
可以使用以下命令添加(注意,`>>` 是追加到文件末尾,因此这条命令只要执行一次即可):
328+
329+
```console
330+
$ echo 'eval "$(starship init bash)"' >> ~/.bashrc
331+
```
332+
333+
重新打开一个终端就可以看到效果了。更进一步的修改请参考[starship 的配置文档](https://starship.rs/config/)
334+
335+
之后我们配置按下 Ctrl + R 时搜索历史命令的功能。尽管 bash 已经内置了该功能,但是它的交互性非常差,难以使用,因此我们使用 [fzf](https://junegunn.github.io/fzf/) 来增强该功能。
336+
337+
```console
338+
$ sudo apt install fzf
339+
```
340+
341+
之后同样在 `~/.bashrc` 文件的末尾添加以下内容:
342+
343+
```shell
344+
eval "$(fzf --bash)"
345+
```
346+
347+
同样可以使用以下命令添加:
348+
349+
```console
350+
$ echo 'eval "$(fzf --bash)"' >> ~/.bashrc
351+
```
352+
353+
重新打开一个终端,按下 Ctrl + R 即可使用该功能。
354+
290355
## 其它的个性化 {#other-personalizations}
291356

292357
上面内容都是外观上的个性化,更多地,Linux 系统的可客制化还体现在一些配置文件上。

0 commit comments

Comments
 (0)