Linux Shell美化:oh-my-zsh

  1. 查看当前shell

    echo $SHELL
    /bin/bash
    
  2. 查看当前是否安装zsh

    cat /etc/shells 
    
    /bin/sh
    /bin/bash
    /usr/bin/sh
    /usr/bin/bash
    /bin/tcsh
    /bin/csh
    
  3. 安装zsh

    yum install -y zsh
    
  4. 设置默认shell

    chsh -s /bin/zsh
    
  5. 安装oh-my-zsh 需要git

    # 如果没有git,则安装
    yum install -y git
    sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    
  6. 安装插件

    • zsh-autosuggestions

      官网。非常好用的一个插件,会记录你之前输入过的所有命令,并且自动匹配你可能想要输入命令,然后按→补全

      # 1. Clone this repository in oh-my-zsh's plugins directory:
      git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
      
      # 2. Activate the plugin in ~/.zshrc:
      plugins=( [plugins...] zsh-autosuggestions)
      
    • zsh-syntax-highlighting

      官网。命令太多,有时候记不住,等输入完了才知道命令输错了,这个插件直接在输入过程中就会提示你,当前命令是否正确,错误红色,正确绿色

      # 1. Clone this repository into $ZSH_CUSTOM/plugins
      git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
      
      
      # 2. Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc):
      plugins=( 
          # other plugins...
           zsh-syntax-highlighting
      )
      
    • sudo

      偶尔输入某个命令,提示没有权限,需要加sudo,这个时候按两下ESC,就会在命令行头部加上sudo

  7. 修改主题

    • .oh-my-zsh/themes目录下新建一个主题my.zsh-theme,添加下面内容:
    	PROMPT="
    %{$fg[cyan]%}%M(%{$fg[red]%}%n) %(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
    PROMPT+='%{$fg[cyan]%}%c%{$reset_color%}:'
    RPROMPT="%{$fg[blue]%}%T $(git_prompt_info)"
    
    ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
    ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
    ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
    ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
    

    这个是根据自带的主题简单修改的,关于怎么自己写自定义主题,参考我写的另一篇文章

    • 修改.zshrc文件,修改主题配置字段:ZSH_THEME="my"

    • 最后source .zshrc

References:

  1. CentOS 安装 zsh

  2. oh-my-zsh常用插件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值