博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Displaying git branch name in prompt does not work in screen
阅读量:4285 次
发布时间:2019-05-27

本文共 964 字,大约阅读时间需要 3 分钟。

轉載自

 

Show the current git branch in your bash prompt

 is the current hotness in source control. One of its main strengths is cheap and easy branching and merging. As a result, git users tend to use branches often. This is a good thing. However, when working on multiple repositories with multiple branches, it can be easy to lose track of your current branch.

While a simple git status will yield the current branch, it is often convenient to have the current branch displayed in your prompt. The magical incantation to add to your PS1 variable is $(__git_ps1). This function is defined in/etc/bash_completion.d/git. If you don’t have access to that file, you can find it in contrib/completion/git-completion.bash after cloning this repo:

git://git.kernel.org/pub/scm/git/git.git

Here is a snippet from a .bashrc file for displaying the current git branch in your bash prompt:

source /etc/bash_completion.d/gitexport PS1='\w$(__git_ps1 "(%s)") > '

转载地址:http://hqsgi.baihongyu.com/

你可能感兴趣的文章
Bootstrap3 datetimepicker控件之smalot的使用
查看>>
小程序Canvas隐藏问题处理
查看>>
小程序scroll-view组件使用简介(转)
查看>>
Visual Studio Code设置中文包/配置中文语言
查看>>
Git重置登录密码问题,Git-remote Incorrect username or password ( access token )
查看>>
C#时间点字符串转换为日期,当天时间点判断
查看>>
Visual Studio Code v1.28.2发布
查看>>
js计算时间差示例
查看>>
VSCode中Vue插件使用整理
查看>>
Cordova 生成慢问题,卡在Gradle:Download https://services.gradle.org/
查看>>
谷歌浏览器如何隐藏控制台的警告内容打印console.warn()
查看>>
JavaScript数据类型
查看>>
JavaScript内置对象
查看>>
VSCode 开发Cordova应用调试整理
查看>>
VSCode修改插件的安装启动位置
查看>>
ueditor编辑器asp.net版本任意上传漏洞处理
查看>>
C#如何获取今天零点的时间
查看>>
EF 根据绝对值排序处理
查看>>
asp.net 跨子域名域Session丢失问题
查看>>
jquery.cookie.js 使用整理(一)
查看>>