安装
rockylinux9先安装:
sudo dnf install util-linux-user -y
dnf install epel-release
文档地址:zhuanlan.zhihu.com/p/50464006
haoyep.com/posts/zsh-c…
-
There are two main ways to install Zsh:
- With the package manager of your choice, e.g.
sudo apt install zshoryum update && sudo yum -y install zsh(see below for more examples) - From source, following the instructions from the Zsh FAQ.
- With the package manager of your choice, e.g.
-
Verify installation by running
zsh --version. Expected result:zsh 5.0.8or more recent. -
Make it your default shell:
chsh -s $(which zsh)or usesudo lchsh $USER(rocky上) if you are on Fedora.- Note that this will not work if Zsh is not in your authorized shells list (
/etc/shells) or if you don't have permission to usechsh. If that's the case you'll need to use a different procedure. - If you use
lchshyou need to type/bin/zshto make it your default shell.
- Note that this will not work if Zsh is not in your authorized shells list (
-
Log out and log back in again to use your new default shell.
-
Test that it worked with
echo $SHELL. Expected result:/bin/zshor similar. -
Test with
$SHELL --version. Expected result: 'zsh 5.8' or similar
安装# Oh my zsh.
Install with curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting)
- Download zsh-autosuggestions by
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
- Download zsh-syntax-highlighting by
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
nano ~/.zshrcfindplugins=(git)- Append
zsh-autosuggestions & zsh-syntax-highlightingtoplugins()like this
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
强烈建议主题:
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
# 中国用户可以使用 gitee.com 上的官方镜像加速下载
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
在 ~/.zshrc 设置 ZSH_THEME="powerlevel10k/powerlevel10k"。接下来,终端会自动引导你配置 powerlevel10k。
1
sudo wget -O $ZSH_CUSTOM/themes/haoomz.zsh-theme https://cdn.haoyep.com/gh/leegical/Blog_img/zsh/haoomz.zsh-theme
编辑 ~/.zshrc 文件,将 ZSH_THEME 设为 haoomz。当然你也可以设置为其他主题,例如lukerandall、robbyrussell。
- Reopen terminal
安装autojump
$ sudo apt install autojump [On Debian, Ubuntu and Mint]
$ sudo yum install autojump [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
$ sudo emerge -a autojump [On Gentoo Linux]
$ sudo apk add autojump [On Alpine Linux]
$ sudo pacman -S autojump [On Arch Linux]
$ sudo zypper install autojump [On OpenSUSE]
ZSH_THEME="agnoster"
plugins=(
kubectl
dnf
git
autojump
zsh-autosuggestions
zsh-syntax-highlighting
)
source ~/.zshrc
root账号下安装:
需要使用sudo命令
sudo cp -r /home/cyxinda/.oh-my-zsh /root
sudo cp -r /home/cyxinda/.zshrc /root
安装好zsh后,需要一些,能够使ctr+w的行为与bash一致:
# Create a new widget.
zle -N backward-kill-space-word
backward-kill-space-word() {
# Inform the line editor that this widget will kill text.
zle -f kill
# Set $WORDCHARS for this command only.
WORDCHARS='*?_-.[]~=/&;!#$%^(){}<>' zle .backward-kill-word
}
# See comments above.
zle -N backward-kill-bash-word
backward-kill-bash-word() {
zle -f kill
WORDCHARS='' zle .backward-kill-word
}
# Bind the widgets to keys.
bindkey '^W' backward-kill-space-word
bindkey '^[^H' backward-kill-bash-word