linux安装oh-my-zsh

1、安装 zsh 

macOS:

mac自带zsh,通过homebrew安装即可

brew install zsh
ubuntu:

这里我只尝试了ubuntu,Debian同样可以通过apt-get进行安装

sudo apt-get install zsh

使用 cat /etc/shells 查看系统可以用的 shell

使用 chsh -s /bin/zsh 更改系统默认 shell  

2、安装 oh-my-zsh 

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

3、配置 oh-my-zsh 

vim ~/.zshrc
#找到这一行修改
ZSH_THEME="要修改的主题名称"

刚安装好zsh后,prompt光秃秃的不好看 
PROMPT='%F{green}%n@%m:%~%# %f'

PROMPT='%F{green}%n@%m:%~$ %f'

最后,执行 source ~/.zshrc 配置生效

source ~/.zshrc

4、配置提示

下载插件以下插件 放到~/.oh-my-zsh/custom/plugins 下

zsh-syntax-highlighting
zsh-autosuggestions
zsh-completions
zsh-history-substring-search

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

 配置提示:在~/.zshrc添加如下信息,默认只有git

plugins=(git
        zsh-syntax-highlighting
        zsh-autosuggestions
        zsh-completions
        zsh-history-substring-search)

source $ZSH/oh-my-zsh.sh
 

5、解决Bash切换Zsh后,bashrc文件失效
 

Add two lines code to your ~/.zshrc, zsh will autorun your customized commands in .bashrc.

# Exec ~/.bashrc and ~/.profile when using zsh
if [ -f '~/.profile' ]; then; source '~/.profile'; fi;
source <(awk '{ if(NR>118)print}' ~/.bashrc)  
# Line 118 is works for Ubuntu's default .bashrc

Once done then run:

source ~/.zshrc

参考:zsh - How can you export your .bashrc to .zshrc? - Stack Overflow 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值