oh-my-zsh 安装

前备工作:
yum -y install zsh / apt install zsh
chsh -s /bin/zsh

安装oh my zsh

  1. 打开官网:https://ohmyz.sh/ 或 Github页面:https://github.com/ohmyzsh/ohmyzsh
  2. 找到安装命令
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  1. 如果出现 443 等网络问题

访问下面地址,得到ip地址,追加进 hosts 文件即可(github的可一并加上)

https://ipaddress.com/website/raw.githubusercontent.com
https://ipaddress.com/website/www.github.com

我的最终结果为:

185.199.108.133 raw.githubusercontent.com
140.82.113.4    github.com
  1. 安装完成后修改主题为 agnoster,编辑.zshrc大概11行左右
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# ZSH_THEME="robbyrussell"
ZSH_THEME="agnoster"

关闭oh my zsh自动更新

  1. 编辑.zshrc找到27行左右,带有 # disable automatic updates,去掉注解
# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled  # disable automatic updates

变为:

# Uncomment one of the following lines to change the auto-update behavior
zstyle ':omz:update' mode disabled  # disable automatic updates
  1. 手动更新命令
$ omz update

修改主题

  1. 变更格式

vim .oh-my-zsh/themes/agnoster.zsh-theme 大概在92行, 或搜索: prompt_context()

### Prompt components
# Each component will draw itself, and hide itself if no information needs to be shown

# Context: user@hostname (who am I and where am I)
prompt_context() {
  if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    # prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
    prompt_segment black default "%(!.%{%F{yellow}%}.)%n"
  fi
}

去掉@%m, 可以省略机器名

  1. 变更颜色

上面的 prompt_segment black default "%(!.%{%F{yellow}%}.)%n" 可以修改 back 和 default 和 yellow, 来改变配色

插件

  • oh-my-zsh 中有内置有很多插件,使用命令vim ~/.zshrc打开,找到 plugins 添加下面的内容
plugins=(
   git
   extract
   z
   zsh-syntax-highlighting
   zsh-autosuggestions
)
# extract 用于解压任何压缩文件,不必根据压缩文件的后缀名来记忆压缩软件
# z 可以直接跳转到曾经去过的文件夹,在项目多的时候非常实用,之前在 mac 上使用的 autojump,后面发现 zsh 内置的插件 z 也能达到同样的效果
  • 剩下两款插件需额外添加
# git clone https://gitee.com/whereabouts-fork/zsh-autosuggestions.git ~/.oh-my-zsh//plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/plugins/zsh-autosuggestions

# git clone https://gitee.com/whereabouts-fork/zsh-syntax-highlighting.git ~/.oh-my-zsh//plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
  • 最后运行
source ~/.zshrc
  • 另一种方式
brew install zsh-autosuggestions
brew install zsh-syntax-highlighting

echo "source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh" >> ~/.zshrc
echo "source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ~/.zshrc
  • 配置后 .zshrc 效果
....
source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值