跳转至

Install Zsh from source

导言

在工作的时候,发现机器有许多网络限制,EulerOS 也没有zsh,tmux(请看tmux的内容),所以尝试从源码安装。

依赖

# sudo apt-get install libncurses-dev
sudo yum install ncurses-devel

安装

# 可能遇到证书错误,需要手动下载,scp传上去,mobaxterm传输也会抽风
wget http://www.zsh.org/pub/zsh-5.9.tar.xz
tar -xf zsh-5.9.tar.xz
cd zsh-5.9
./configure
make -j
sudo make install

Oh my zsh

wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh

主题安装

默认主题是agnoster,修改.zshrc文件,将ZSH_THEME="agnoster"改为ZSH_THEME="chivier"

配置文件很简单,存放在~/.oh-my-zsh/themes/chivier.zsh-theme

#PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[blue]%}(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}*%{$fg[blue]%})%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"

PROMPT='%{$fg_bold[white]%}%n%{$fg[magenta]%}@%{$fg_bold[yellow]%}%m %{$fg_bold[green]%}%~ %{$reset_color%}$(git_prompt_info) %{$fg[cyan]%}%D{[%I:%M:%S]}

插件安装

先把两个装了

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

修改.zshrc 加上plugins=(zsh-syntax-highlighting zsh-autosuggestions)

语法正确性高亮

zsh-syntax-highlighting 能在输入命令时用红色和绿色来显示语法错误(命令或者路径是否存在)。

命令补齐

zsh-autosuggestions 会基于zsh_history来预测出下一个命令。

zshrc常见配置

alias l='ls -al --color=auto'
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias diff='diff --color=auto'
alias py='python3'
alias pytho3='python3'
alias pip='pip3'

function find() {
    if [ $# = 1 ];
    then
        command find . -iname "*$@*"
    else
        command find "$@"
    fi
}

# source ~/set_proxy.sh
cd

参考文献

评论