linux服务器初建之zsh安装

安装zsh

root下操作

安装zsh

1
yum -y install zsh

切换bash至zsh

1
2
chsh -s $(which zsh) $(whoami)
reboot

install oh-my-zsh

1
2
3
4
5
6
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# add proxy
sh -c "$(curl -fsSLx http://www-proxy.example.com:8080 https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
vim ~/.zshrc
plugins=(git z zsh-autosuggestions zsh-syntax-highlighting)
ZSH_THEME="powerlevel10k/powerlevel10k"
POWERLEVEL10K_MODE="nerdfont-complete"
# you can run the command 'p10k configure' to reconfigure your powerlevel10k

git clone git://github.com/zsh-users/zsh-autosuggestions \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

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

git clone git://github.com/romkatv/powerlevel10k \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

# ========= install powerline fonts =========
# clone
# git clone https://github.com/ryanoasis/nerd-fonts --depth=1
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts
# If needed, you can make it work all users
install -d /usr/share/fonts; cp /root/.local/share/fonts/* /usr/share/fonts

BTW

Tips:

fd bat and lsd are very nice.
Maybe you can install them. For more information, you can access their home page.

1
2
3
4
5
6
7
8
9
10
# install fd, bat and lsd on RHEL/CentOS
# Author="sharkdp"; Repo="fd";
# Author="sharkdp"; Repo="bat";
Author="Peltoche"; Repo="lsd"; latest_url="https://api.github.com/repos/$Author/$Repo/releases/latest"; \
V=$(curl --silent $latest_url | grep -Eo '"tag_name": "v?(.*)"' | sed -E 's/.*"([^"]+)".*/\1/'); \
Latest_tar="$Repo-$V-x86_64-unknown-linux-musl.tar.gz" \
&& curl -sOL "https://github.com/$Author/$Repo/releases/download/$V/$Latest_tar" \
&& tar xzvf $Latest_tar -C . \
&& sudo sh -c "cp ./$Repo-$V-x86_64-unknown-linux-musl/$Repo /usr/local/bin/$Repo" \
&& rm $Latest_tar