diff options
Diffstat (limited to 'docs/applications/shell')
| -rw-r--r-- | docs/applications/shell/bash.md | 41 | ||||
| -rw-r--r-- | docs/applications/shell/fish.md | 75 | ||||
| -rw-r--r-- | docs/applications/shell/shell.md | 13 | ||||
| -rw-r--r-- | docs/applications/shell/zsh.md | 88 |
4 files changed, 217 insertions, 0 deletions
diff --git a/docs/applications/shell/bash.md b/docs/applications/shell/bash.md new file mode 100644 index 0000000..ef11240 --- /dev/null +++ b/docs/applications/shell/bash.md @@ -0,0 +1,41 @@ +# Bash + + + +[官网](https://www.gnu.org/software/bash/) + +[官方文档](https://www.gnu.org/software/bash/manual/bash.html) + +**Bash的配置文件: `~/.bashrc`** + +## 概述 + +Bash是一个古老的[Shell](./shell.md),大多数发行版预装了Bash并作为默认Bash,Bash符合POSIX标准,这代表Bash可以运行Zsh的脚本,反之亦然。 + +## 安装 + +- Debian系列: `sudo apt install bash` +- 红帽系: `sudo dnf install bash` +- Arch系: `sudo pacman -S bash` + +## 配置 + +### Starship + +您可以使用[starship](https://starship.rs/zh-CN/)配置Bash。 + +???+ note "字体" + 我们您可以安装[Nerd Fonts字体](https://www.nerdfonts.com/)以解决字体乱码问题。 + +```bash +curl -sS https://starship.rs/install.sh | sh +``` + +在`~/.bashrc`的最后,添加以下内容: +```bash + +eval "$(starship init bash)" + +``` + +更多的配置推荐您阅读[Starship官方文档](https://starship.rs/zh-CN/guide/)。 diff --git a/docs/applications/shell/fish.md b/docs/applications/shell/fish.md new file mode 100644 index 0000000..d8e3fe1 --- /dev/null +++ b/docs/applications/shell/fish.md @@ -0,0 +1,75 @@ +# Fish + + + +## 概述 + +Fish是一个[Shell](./shell.md),它有着功能丰富,开箱即用,脚本编写简便的特点。 + +**但它不兼容[POSIX标准](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html),这意味着Bash无法运行Fish的脚本,反之亦然**。 + +## 安装 + +- Debian系: +```bash +sudo apt install fish +``` + +- 红帽系: +```bash +sudo dnf install fish +``` + +- Arch系: +```bash +sudo pacman -S fish +``` + +## 使用 + +将Fish作为默认Shell + +```bash +# 将Fish加入Shell列表 +command -v fish | sudo tee -a /etc/shells + +# 更改默认Shell +chsh -s "$(command -v fish)" +``` +当您在Fish输入命令时,光标后会有一个暗灰色建议,如果您同意这个建议,您可以按右方向键或`ctrl-f` + +当您在Fish输入命令时,您可以按Tab键列出所有选项,您可以使用方向键选择选项,使用回车键补全 + +使用`ctrl-a`或`ctrl-e`移动到命令的头部或尾部 + +使用`ctrl-k`删除光标后的所有内容 + +使用`ctrl-c`中断命令 + +使用`alt-c`将光标后面的第一个字母大写 + +使用`alt-u`将光标后面的所有字母大写 + +**Fish默认使用Emacs快捷键,您可以使用`fish_vi_key_bindings`切换到vi模式,使用`fish_default_key_bindings`,切换回去**。 + +## 配置 + +您可以在config-fish添加以下文本关闭Fish的欢迎信息: +```bash +set -U fish_greeting +``` + +您可以使用以下语法设置别名 +```bash +alias 别名="原本的命令" +abbr -a 别名="原本的命令" +``` + +## 关于更多 + +受限于我们的专门性,建议选择这些更专门的教程或文档学习 + +- [官方文档](https://fishshell.com/docs/current/index.html) +- [Fish语言教程](https://fishshell.com/docs/current/tutorial.html) + + diff --git a/docs/applications/shell/shell.md b/docs/applications/shell/shell.md new file mode 100644 index 0000000..06f26ca --- /dev/null +++ b/docs/applications/shell/shell.md @@ -0,0 +1,13 @@ +# Shell 概述 + +Shell是用户与Linux内核直接对话的“窗口”,你可以将它理解为Windows的CMD(命令提示符)。用户通过在Shell输入指令达到操作系统的目的。 + +大多数Shell的配置文件包括环境变量、主题等内容,且位于用户目录下,为以`.`开头的隐藏文件,如`.bashrc`(Bash)、`.zshrc`(Zsh)。 + +!!! warning "消歧义" + 终端是Shell的图形化呈现。尽管有Ptyxis、Konsole等等终端,但其所调用、运行的依然是诸如Bash等等的Shell。 + +???+ example "常见的Linux Shell" + - Bash: 大多数Linux发行版预装的Shell,兼容性强,支持广 + - Zsh: 自定义性强,有强大的自动补全功能,并兼容Bash语法 + - Fish: 用户友好,人性化设计,易配置
\ No newline at end of file diff --git a/docs/applications/shell/zsh.md b/docs/applications/shell/zsh.md new file mode 100644 index 0000000..6d216e0 --- /dev/null +++ b/docs/applications/shell/zsh.md @@ -0,0 +1,88 @@ +# Zsh + +## 概述 + +Zsh是一款拥有高度自定义性的[Shell](./shell.md),它具有强大的自动补全、语法高亮,并且由于Oh My Zsh的支持,拥有海量主题与插件,特别适合用于美化。 + +## 安装 + +### Zsh + +以下命令用于安装Zsh与部分推荐扩展。 + +Debian系: +```bash +sudo apt install zsh zsh-autosuggestions zsh-syntax-highlighting +``` + +红帽系 +```bash +sudo dnf install zsh zsh-autosuggestions zsh-syntax-highlighting +``` + +Arch系 +```bash +sudo pacman -S zsh zsh-autosuggestions zsh-syntax-highlighting +``` + +安装好后,您可以运行`chsh -s /bin/zsh`来设置Zsh为默认终端。 + +???+info "注意" + 部分发行版源的`zsh`包,在初次运行`zsh`时,会询问您想要如何配置`.zshrc`(Zsh的配置文件)。我们建议您输入2来选择`(2) Populate your ~/.zshrc with the configuration recommended by the system administrator and exit (you will need to edit the file by hand, if so desired).`(默认推荐配置)。 + +### Oh My Zsh + +[Oh My Zsh](https://ohmyz.sh/)能够用于管理`.zshrc`配置文件,简化Zsh的配置过程,并通过丰富的插件和主题生态,极大地提升终端的使用效率和视觉体验。 + +在安装之前,您首先需要使用包管理器安装Git(包名`git`)。 + +#### 一键安装 + +运行以下一键安装脚本即可。 + +```bash +sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" +# 或者 +sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)" +``` +!!! warning "网络问题" + 该脚本与 https://install.ohmyz.sh 的脚本本质相同,均需要从Github克隆Zsh仓库,因此可能需要较好的网络环境。 + +#### 手动安装 + +若您因为网络原因无法使用一键安装,您可以采用手动安装。 + +```bash +# 克隆仓库(使用gh-proxy以规避网络问题) +git clone https://gh-proxy.com/https://github.com/ohmyzsh/ohmyzsh ~/.oh-my-zsh +# 或者使用Gitee(需要登录) +# git clone https://gitee.com/mirrors/ohmyzsh ~/.oh-my-zsh +# 备份.zshrc +mv ~/.zshrc ~/.zshrc.orig +# 使用Oh My Zsh提供的模板 +cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc +# 应用Oh My Zsh +zsh +``` + +## 主题 + +大部分Zsh主题可以在[Github](https://github.com/topics/zsh-theme)上找到,同时,Oh My Zsh也拥有大量的[预置主题](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes)。大部分主题均提供了安装脚本,此处我们以[Powerlevel10k](https://github.com/romkatv/powerlevel10k)为例。 + +??? note "字体" + Powerlevel10k需要安装以下字体(链接已加速)来确保呈现效果: + + - [MesloLGS NF Regular.ttf](https://gh-proxy.com/https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf) + - [MesloLGS NF Bold.ttf](https://gh-proxy.com/https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf) + - [MesloLGS NF Italic.ttf](https://gh-proxy.com/https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf) + - [MesloLGS NF Bold Italic.ttf](https://gh-proxy.com/https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf) + + 下载字体后,双击通过桌面环境自带的字体应用安装即可。同时,您可能需要[配置对应终端的字体(Github)](https://github.com/romkatv/powerlevel10k#meslo-nerd-font-patched-for-powerlevel10k)。 + + +```bash +# 克隆仓库 +git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ~/powerlevel10k +# 写入.zshrc +echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc +``` |
