zoukankan      html  css  js  c++  java
  • 解决oh-my-zsh中git分支显示乱码问题

    oh-my-zsh显示github分支时,如果当前文件夹不是git仓库,它就会显示乱码。倒腾了好几个小时终于弄清楚是oh-my-zsh中函数”git_prompt_info“的锅,然后又花了半个多小时调代码,现在总算像个人了!!

    先看效果:

    实现步骤:

    1. 进入 ~/.oh-my-zsh/lib 文件夹
    2. 编辑 git.zsh,找到git_prompt_info函数:

      function git_prompt_info() {
        local ref
        if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then
          ref=$(command git symbolic-ref HEAD 2> /dev/null) || 
          if [[ -n $ref ]]; then
            ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
          fi
          if [[ -n ${ref#refs/heads/} ]]; then
            echo " ${ref#refs/heads/}"
          fi
        fi
      }

      这里修改显示逻辑,如果当前文件夹属于git仓库,就显示分支,否则什么也不显示。

    3. 进入 ~/.oh-my-zsh/thems 文件夹,编辑robbyrussell.zsh-theme

      local ret_status="%(?:%{$fg_bold[green]%}➜:%{$fg_bold[red]%}➜)"
      PROMPT='${ret_status} %{$fg[cyan]%}%c%{$fg_bold[blue]%}$(git_prompt_info) %{$reset_color%}$ '
      ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}"
      ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
      ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
      ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
      

      这里是修改prompt格式,直接拷贝进去就好,不要漏空格,否则会很丑。

     大功告成~! 

  • 相关阅读:
    caffe中的sgd,与激活函数(activation function)
    image retrieval数据集
    八卦
    caffe的损失函数
    caffe的输入
    rcnn spp_net hcp
    js实现幻灯片播放图片示例代码
    Checbox的操作含已选、未选及判断代码
    shell中case的用法学习笔记
    linux bash shell中case语句的实例
  • 原文地址:https://www.cnblogs.com/Rhythm-/p/11337006.html
Copyright © 2011-2022 走看看