个人喜欢的linux命令行环境搭建

最好全程代理,否则有的包可能下不下来

相关依赖

sudo apt install git curl sudo zsh -y

fzf

模糊搜索神器

安装

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install

zsh

强大的shell环境,推荐oh-my-zsh

安装

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

卸载

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

设置为默认sehll

chsh -s /usr/bin/zsh

powerlevel10k主题

漂亮的shell主题

安装

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k

对应的终端需要安装字体,参考

.zshrc添加一行

source ~/.oh-my-zsh/custom/themes/powerlevel10k/powerlevel10k.zsh-theme

按照提示配置即可:

p10k configure

关闭自动更新

每次启动都要更新拖慢速度,可以修改.zshrc关闭

DISABLE_AUTO_UPDATE="true"

插件

修改.zshrc

plugins=(zsh-syntax-highlighting git zsh-z osx zsh-autosuggestions)

zsh-syntax-highlighting

zsh语法高亮插件

安装(基于oh my zsh):

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

注:安装后命令行会比较卡,慎用

zsh-autosuggestions

自动提示插件

安装(基于oh my zsh):

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

使用’,‘作为自动补全快捷键,.zshrc添加

bindkey ',' autosuggest-accept

zsh-z

目录切换工具

安装(基于oh my zsh):

git clone https://github.com/agkozak/zsh-z $ZSH_CUSTOM/plugins/zsh-z

完整命令

debian系

#first run in bash
sudo apt install git curl zsh -y
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
#second run in zsh
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/agkozak/zsh-z $ZSH_CUSTOM/plugins/zsh-z
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
sed -i 's/plugins=(git)/plugins=(git zsh-z zsh-autosuggestions)/' ~/.zshrc
sed -i 's/# DISABLE_AUTO_UPDATE="true"/DISABLE_AUTO_UPDATE="true"/' ~/.zshrc
echo "[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh" >> ~/.zshrc
echo "source ~/.oh-my-zsh/custom/themes/powerlevel10k/powerlevel10k.zsh-theme" >> ~/.zshrc
echo "bindkey ',' autosuggest-accept" >> ~/.zshrc
source ~/.zshrc

RHEL系

centos7的zsh版本过低,powerlevel10k无法使用,需要手工编译安装

sudo yum update -y
sudo yum install -y git make ncurses-devel gcc autoconf man yodl
git clone -b zsh-5.7.1 https://github.com/zsh-users/zsh.git /tmp/zsh
cd /tmp/zsh
./Util/preconfig
./configure
sudo make -j 20 install

安装oh-my-zsh

#sudo yum install zsh -y
#zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
#second run in zsh
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/agkozak/zsh-z $ZSH_CUSTOM/plugins/zsh-z
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
sed -i 's/plugins=(git)/plugins=(git zsh-z zsh-autosuggestions)/' ~/.zshrc
sed -i 's/# DISABLE_AUTO_UPDATE="true"/DISABLE_AUTO_UPDATE="true"/' ~/.zshrc
echo "[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh" >> ~/.zshrc
echo "source ~/.oh-my-zsh/custom/themes/powerlevel10k/powerlevel10k.zsh-theme" >> ~/.zshrc
echo "bindkey ',' autosuggest-accept" >> ~/.zshrc
echo "setopt no_nomatch" >> ~/.zshrc
source ~/.zshrcz