如何正确的配置 Linux/macOS 环境中的 shell

  1. 安装 Zsh
  2. 安装 Oh-my-zsh
  3. 安装插件
    1. zsh-syntax-highlighting
    2. zsh-autosuggestions
    3. 配置 Zsh 的配置文件
    4. 选择 Themes(optional)
  4. 安装 Fastfetch
  5. 为 iterm2 配置代理

一个简易的安装 Zsh Oh-my-zsh(including plugs)Fastfetch 的教程

[toc]

安装 Zsh

1
brew install zsh

安装 Oh-my-zsh

1
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

应该将zsh自动设为你的默认 shell 了,如果没有,可以手动输入:

1
chsh -s $(which zsh)

安装插件

zsh-syntax-highlighting

1
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

zsh-autosuggestions

1
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

配置 Zsh 的配置文件

1
vim ~/.zshrc

打开zsh的配置文件,将plugin添加到你的.zshrc

1
plugins=(git zsh-syntax-highlighting zsh-autosuggestions)

选择 Themes(optional)

1
ZSH_THEME=robbyrussell

默认的主题就是 robbyrussell,具体可见Themes · ohmyzsh/ohmyzsh Wiki (github.com)

安装 Fastfetch

fastfetch-cli/fastfetch (github.com)

1
brew install fastfetch

生成配置文件

1
fastfetch --gen-config
1
vim ~/.config/fastfetch/config.jsonc

以下是我的配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"modules": [
"title",
"separator",
"os",
"kernel",
"uptime",
"shell",
"theme",
"icons",
"terminal",
"cpu",
"gpu",
"memory",
"swap",
"localip",
"battery",
"poweradapter",
"locale",
"break",
"colors",
]
}

每次打开自动运行

1
vim ~/.zshrc

在最底处输入

1
fastfetch

为 iterm2 配置代理

1
code ~/.zshrc

新增

1
2
alias proxy='export http_proxy=http://127.0.0.1:7890 https_proxy=http://127.0.0.1:7890'
alias unproxy='unset http_proxy https_proxy'