在Arch中安装zsh并配置p10k主题和补全、高亮插件

Tips: The commands are all in archlinux platform.

zsh的安装

*安装之前建议先sudo pacman -Syu进行更新

1
$ sudo pacman -S zsh

查看已安装的shell

1
$ chsh -l

or you can use cat /etc/shells to list the shells you have installed.

执行这条命令后,你可以看到类似以下的info:

1
2
3
4
5
6
[ljk@leejk ~]$ chsh -l
/bin/sh
/bin/bash
/usr/bin/git-shell
/bin/zsh
/usr/bin/zsh

更换默认的shell为zsh

1
$ sudo chsh -s /usr/bin/zsh

重新登录后进入打开konsole会显示第一次使用,可以按提示进行配置。配置完成后会在 ~/ 下生成 .zshrc 配置文件。

配置zsh

切换shell后重新打开终端模拟器会提示对zsh进行配置,按 1 键就可以进入配置界面了:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Please pick one of the following options:
(1)  Configure settings for history, i.e. command lines remembered
     and saved by the shell.  (Recommended.)
(2)  Configure the new completion system.  (Recommended.)
(3)  Configure how keys behave when editing command lines.  (Recommended.)
(4)  Pick some of the more common shell options.  These are simple "on"
     or "off" switches controlling the shell's features.  
(0)  Exit, creating a blank ~/.zshrc file.
(a)  Abort all settings and start from scratch.  Note this will overwrite
     any settings from zsh-newuser-install already in the startup file.
     It will not alter any of your other settings, however.
(q)  Quit and do nothing else.  The function will be run again next time.
--- Type one of the keys in parentheses --- 

完成基本的zsh设置,使用cat查看配置文件内容如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
leejk% cat .zshrc 
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/ljk/.zshrc'

autoload -Uz compinit
compinit
# End of lines added by compinstall

使用zsh+p10k的方案,个人倾向于轻量,oh-my-zsh是很强大的zsh插件管理器

installation

1
2
3
4
# themes
sudo pacman -S zsh-theme-powerlevel10k
# plugins
sudo pacman -S zsh-autosuggestions zsh-syntax-highlighting zsh-completions

configration

开启文件夹color

1
2
# in ~/.zhsrc
alias ls='ls --color=auto'

启用p10k主题和三个补全插件

1
2
3
4
5
6
# in ~/.zhsrc
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme
# 使用tab键显示命令的参数和作用
autoload -Uz compinit && compinit
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy