1:问题描述:

  在Windows环境下习惯使用git bash操作git分支,最近学习linux环境,发现linux环境终端不显示git分支,相关现象如下:

       

  期望效果是:

    

  我的linux环境版本是:Ubuntu 18.04 LTS

系统默认的终端是:Terminal

2:修改方案:

  通过百度,找到解决方案:oh-my-zsh

  1:oh-my-zsh介绍:

        oh-my-zsh是基于Zsh(Zsh是一个Linux用户很少使用的power-shell,这是由于大多数Linux产品安装,以及默认使用bash shell)的功能作了一个扩展,方便插件管理、主体自定义等。

oh-my-zsh源码在  https://github.com/robbyrussell/oh-my-zsh ,它的License为MIT。

  2:oh-my-zsh安装:

安装zsh:hlp@hlp:~/code/github_code/git_mytest$ sudo apt install zsh查看安装成功:hlp@hlp:~/code/github_code/git_mytest$ zsh --versionzsh 5.4.2 (x86_64-ubuntu-linux-gnu)安装oh-my-zsh:hlp@hlp:~/code/github_code/git_mytest$ sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

   附图:安装成功的标志:

  

  3:结果验证:  

启动zsh终端:hlp@hlp:~/code/github_code/git_mytest$ zsh
➜  git_mytest git:(master) ls    ------》成功显示了分支
doc      LICENSE       README.md  src         webpack.config.js
example  package.json  release    SUMMARY.md
➜  git_mytest git:(master) exit   -----》退出zsh终端
hlp@hlp:~/code/github_code/git_mytest$ 

4:配置修改:

分支显示颜色修改:进入配置文件:hlp@hlp:~/code/github_code/git_mytest$ vi ~/.oh-my-zsh/themes/robbyrussell.zsh-theme
修改后的配置文件:hlp@hlp:~/code/github_code/git_mytest$ cat ~/.oh-my-zsh/themes/robbyrussell.zsh-theme
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
配置文件生效查看:hlp@hlp:~/code/github_code/git_mytest$ zsh➜  git_mytest git:(master) ls    

zsh主题修改:查看自带默认主题:hlp@hlp:~/code/github_code/git_mytest$ ls ~/.oh-my-zsh/themes -----》这里没有输出显示结果

修改主题:hlp@hlp:~/code/github_code/git_mytest$ vi ~/.zshrchlp@hlp:~/code/github_code/git_mytest$ cat ~/.zshrc# If you come from bash you might have to change your $PATH.# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.  export ZSH="/home/hlp/.oh-my-zsh"

# Set name of the theme to load. Optionally, if you set this to "random"# it'll load a random theme each time that oh-my-zsh is loaded.# See https://github.com/robbyrussell/oh-my-zsh/wiki/ThemesZSH_THEME="robbyrussell"     ------》修改该字段即可修改主题,相关主题可以参考:https://github.com/robbyrussell/oh-my-zsh/wiki/Themes

# Set list of themes to load# Setting this variable when ZSH_THEME=random# cause zsh load theme from this variable instead of
zsh插件修改:(zsh默认只有git插件)
查看系统默认插件:hlp@hlp:~/.oh-my-zsh/plugins$ ls ~/.oh-my-zsh/plugins

修改插件配置文件:hlp@hlp:~/code/github_code/git_mytest$ vi ~/.zshrchlp@hlp:~/code/github_code/git_mytest$ cat ~/.zshrc
。。。。。。# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/# Example format: plugins=(rails git textmate ruby lighthouse)# Add wisely, as too many plugins slow down shell startup.plugins=(  git wd web-search history history-substring-search  ------》增加想要的插件,插件介绍:https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins)。。。。。

除此之外,~/.zshrc文件中其他注释掉的配置信息,可以参考相关文档自行修改达到自己想要的效果。例如给history增加时间:
  1. $ vim ~/.zshrc
  2. HIST_STAMPS="yyyy-mm-dd"
  3. source ~/.zshrc
卸载:直接在终端中,运行uninstall_oh_my_zsh既可以卸载。

3:参考文献:(有照抄的嫌疑,太详细了)

主要参考:http://www.mamicode.com/info-detail-2163847.html

        https://blog.csdn.net/czg13548930186/article/details/72858289

4:声明:

该博文只是为了规范自己的习惯,总结遇到过的问题,如有问题或者建议,请谅解。

5:遗留小问题(待处理):

  进入zsh终端后,我用git branch查看分支的时候,发现会打开新的界面显示结果,使用很不方便。

转载于:https://www.cnblogs.com/yun6853992/p/9348829.html

ubuntu使用git时,终端不显示git分支。相关推荐

  1. 终端中显示git分支名称的方法

    终端中显示git分支名称的方法   大家好,我叫亓官劼(qí guān jié ),在CSDN中记录学习的点滴历程,时光荏苒,未来可期,加油~博客地址为:亓官劼的博客,B站昵称为:亓官劼,地址为亓官劼 ...

  2. Ubuntu系统新建用户时终端只显示$符号

    Ubuntu系统新建用户时终端只显示$符号 问题:在新建用户的时候切换到新建用户的终端,只是显示$符号. 解决方法: 1.使用命令切换到root用户: $ su root 2.然后使用命令绑定bash ...

  3. git branch -a无法显示远程分支解决办法

    阅文时长 | 0.2分钟 字数统计 | 330.4字符 主要内容 | 1.引言&背景 2.git fetch拓展 3.声明与参考资料 『git branch -a无法显示远程分支解决办法』 编 ...

  4. 无法在终端中显示Git树

    Killswitchcollective.com的旧文章,2009年6月30日 ,有以下输入和输出 git co master git merge [your_branch] git pushupst ...

  5. git之配置在Terminal显示git分支

    1. 编辑环境变量 subl ~/.bashrc # 或者 sudo gedit ~/.bashrc 2. 追加以下内容 # show git branch in terminal function ...

  6. Ubuntu14.04 64位上配置终端显示git分支名称

    之前在Ubuntu14.04上在终端上显示git分支名称基本上都使用oh-my-zsh,可以参考 https://blog.csdn.net/fengbingchun/article/details/ ...

  7. mac 上搭建gitlabel_在mac终端中使用git(适用于github、gitlabel)

    一.升级安装git 使用终端升级指令: git clone https://github.com/git/git 二.SSH-Keys准备 使用终端生成.ssh文件 1.判断电脑是否已存在.ssh文件 ...

  8. 深入浅出Git教程+一个小时学会Git(转载)(堪称完美)

    转载自: https://www.cnblogs.com/best/p/7474442.html#!comments 目录 一个小时学会Git 一.版本控制概要 工作区 暂存区 本地仓库 远程仓库 1 ...

  9. git常用命令_10、Git常用命令

    Git常用命令 Git作为我们最常用的版本控制工具,多了解并熟悉一些命令,将能节省很多时间 关于git,首先需要了解几个名词,如下: Workspace:工作区 Index / Stage:暂存区 R ...

最新文章

  1. 物联网是怎样把世界联系起来的
  2. ZooKeeper概述
  3. DSP 的双缓冲串口程序设计
  4. 细数网络上十七种安全威胁
  5. ionic助手 v1.9.0 一键式开发环境工具(告别命令行,超强功能)
  6. android 个推打开页面,个推android客户端点击跳到指定activity
  7. BlueHost怎样创建MySQL数据库
  8. SQL注入攻击及防御详解
  9. uni-app框架介绍
  10. 第四章 使用OpenCV探测来至运动的结构——Chapter 4:Exploring Structure from Motion Using OpenCV 标签: SFM3D重建 2015-01-15
  11. python用turtle画一个苹果
  12. 用时一个半个月,七月刚入职字节跳动的测试开发面试题,内附答案
  13. Windows PE探秘
  14. 基于百度飞桨PaddleOCR的图片文字识别
  15. CBS基于冲突的搜索算法流程和核心
  16. VB 数据库交互(二)——经典五实例总结
  17. 大数据和java的区别
  18. background-size的几种取值
  19. UI设计入门:五种基本APP界面类型【萧蕊冰】
  20. JetBrains 在中国被频繁破解,官方是如何看待的

热门文章

  1. mysql 版本太高_mysql创建新库以及解决版本过高8.0以上导致navicat无法连接的问题...
  2. 学计算机专业能上国家电网吗,高考结束后,选择什么专业能进入国家电网?这些专业考生应该知道...
  3. linux下编程语言,linux下各种编程语言安装
  4. 2020.2idea怎么创建html项目_如何为IDEA项目创建GitHub存储库和本地Git存储库
  5. Advanced techniques: creating sound, sequencing, timing, scheduling
  6. 编程语言对比 条件控制语句
  7. Numpy 字符串处理
  8. Pandas dtypes(数据类型)
  9. VCSA 6.5 HA配置 之四 开启vCenter HA
  10. 压测学习总结(2)——Jmeter 基本知识入门