Arch Linux zsh 配置
从来没用过 zsh,换了 Arch 之后也换个 shell 尝鲜一下,对于我这样的普通用户而言,使用下来暂时没有发现和 bash 有任何差异。

zsh 纯新手,仅仅是简单配置一下,zsh 在绝大多数发行版下面都不是默认 shell,完全没有折腾的必要,而且自己也已经过了折腾的年纪了。

$ sudo pacman -S zsh zsh-completions zsh-autosuggestions
$ yay -S oh-my-zsh-git

更改默认 shell:

$ chsh -s /bin/zsh

然后重启系统或重新登录。

theme

$ cp /usr/share/oh-my-zsh/zshrc ~/.zshrc
$ vi ~/.zshrc
ZSH_THEME="powerlevel10k/powerlevel10k"

$ mkdir -p ~/.oh-my-zsh/custom/themes
$ cd ~/.oh-my-zsh/custom/themes/
$ git clone git@github.com:romkatv/powerlevel10k.git

然后安装并配置 powerlevel10k README.md 中提及的 Meslo Nerd Font 字体。

重新打开终端,会提示对 powerlevel10k 主题进行配置,后续也可以手动更改 powerlevel10k 主题配置:

$ p10k configure

Powerlevel10k - A Zsh theme
https://github.com/romkatv/powerlevel10k

Fonts
https://github.com/romkatv/powerlevel10k#fonts

ls colors

cd ~/.oh-my-zsh/custom/plugins
❯ git clone --recursive git@github.com:joel-porquet/zsh-dircolors-solarized.git

❯ vi ~/.zshrc
plugins=(git zsh-dircolors-solarized)

重新打开终端,进行如下配置:

❯ lssolarized
dircolors.256dark
dircolors.ansi-dark
dircolors.ansi-light
dircolors.ansi-universal

❯ setupsolarized dircolors.ansi-light

Solarized dircolors plugin for zsh
https://github.com/joel-porquet/zsh-dircolors-solarized

split history

多个终端不要共享同一个历史记录:

❯ vi ~/.zshrc
unsetopt inc_append_history
unsetopt share_history

iTerm2 (version 3): Individual history per tab?
https://superuser.com/questions/1245273/iterm2-version-3-individual-history-per-tab

zsh-autocomplete

实际试用之后发现不是太好用,觉得有点繁琐多余。

cd ~/.oh-my-zsh/custom/plugins
❯ git clone git@github.com:marlonrichert/zsh-autocomplete.git

❯ vi ~/.zshrc
plugins=(git zsh-dircolors-solarized zsh-autocomplete)

Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.
https://github.com/marlonrichert/zsh-autocomplete

zshrc

❯ cat ~/.zshrc
ZSH=/usr/share/oh-my-zsh/
ZSH_THEME="powerlevel10k/powerlevel10k"
ZSH_CUSTOM=~/.oh-my-zsh/custom

plugins=(git zsh-dircolors-solarized)

fpath+=(~/.oh-my-zsh/completion.d)

source $ZSH/oh-my-zsh.sh

unsetopt inc_append_history
unsetopt share_history

alias ll='ls -l --color=auto'
alias vi=vim
alias sudo='sudo '

最后修改于 2023-07-08