• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

jimeh/git-aware-prompt: Display current Git branch name in your terminal prompt ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

jimeh/git-aware-prompt

开源软件地址:

https://github.com/jimeh/git-aware-prompt

开源编程语言:

Shell 100.0%

开源软件介绍:

Git Aware Prompt

Working with Git and its great branching/merging features is amazing. Constantly switching branches can be confusing though as you have to run git status to see which branch you're currently on.

The solution to this is to have your terminal prompt display the current branch. There's a number of articles available online about how to achieve this. This project is an attempt to make an easy to install/configure solution.

Overview

If you cd to a Git working directory, you will see the current Git branch name displayed in your terminal prompt. When you're not in a Git working directory, your prompt works like normal.

Git Branch in Prompt

Installation

Clone the project to a .bash folder in your home directory:

mkdir ~/.bash
cd ~/.bash
git clone git://github.com/jimeh/git-aware-prompt.git

Edit your ~/.bash_profile or ~/.profile or ~/.bashrc (for Ubuntu) and add the following to the top:

export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"

Configuring

Once installed, there will be new $git_branch and $git_dirty variables available to use in the PS1 environment variable, along with a number of color helper variables which you can see a list of in colors.sh.

If you want to know more about how to customize your prompt, I recommend this article: How to: Change / Setup bash custom prompt (PS1)

Suggested Prompts

Below are a few suggested prompt configurations. Simply paste the code at the end of the same file you pasted the installation code into earlier.

Mac OS X

export PS1="\u@\h \W \[\$txtcyn\]\$git_branch\[\$txtred\]\$git_dirty\[\$txtrst\]\$ "

Optionally, if you want a nice pretty prompt when using sudo -s, also add this line:

export SUDO_PS1="\[$bakred\]\u@\h\[$txtrst\] \w\$ "

Ubuntu

Standard:

export PS1="\${debian_chroot:+(\$debian_chroot)}\u@\h:\w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "

Colorized:

export PS1="\${debian_chroot:+(\$debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "

Windows

export PS1="\[\033]0;$MSYSTEM:\w\007\033[32m\]\u@\h:\[\033[33m\w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\033[0m\]\$ "

Updating

Assuming you followed the default installation instructions and cloned this repo to ~/.bash/git-aware-prompt:

cd ~/.bash/git-aware-prompt
git pull

Usage Tips

To view other user's tips, please check the Usage Tips wiki page. Or if you have tips of your own, feel free to add them :)

License

CC0 1.0 Universal




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap