magicmonty / bash-git-prompt Goto Github PK
View Code? Open in Web Editor NEWAn informative and fancy bash prompt for Git users
License: BSD 2-Clause "Simplified" License
An informative and fancy bash prompt for Git users
License: BSD 2-Clause "Simplified" License
If you look at the right-hand terminal, you can see the chars have squashed together. I am using terminator on Ubuntu 14.04.
I fixed this before on my own branch about a year ago but never pushed upstream.
- GIT_PROMPT_STAGED="${Red}● " # the number of staged files/directories
+ GIT_PROMPT_STAGED="${Red}●" # the number of staged files/directories
GIT_PROMPT_CONFLICTS="${Red}✖ " # the number of files in conflict
GIT_PROMPT_CHANGED="${Blue}✚ " # the number of changed files
- GIT_PROMPT_REMOTE=" " # the remote branch name (if any)
- GIT_PROMPT_UNTRACKED="${Cyan}… " # the number of untracked files/dirs
+
+ GIT_PROMPT_REMOTE=" " # the remote branch name (if any) and the symbols for ahead an
+ GIT_PROMPT_UNTRACKED="${Cyan}…" # the number of untracked files/dirs
GIT_PROMPT_STASHED="${BoldBlue}⚑ " # the number of stashed files/dir
- GIT_PROMPT_CLEAN="${BoldGreen}✔ " # a colored flag indicating a "clean" repo
+ GIT_PROMPT_CLEAN="${BoldGreen}✔" # a colored flag indicating a "clean" repo
i.e. I added a space after the icons (that don't seem to want to obey monospacing or something). I assume this is only a problem with certain fonts/terminals and doesn't affect Terminal.app?
I use Stacked Git a lot and have been trying to think of a good way to incorporate it into bash-git-prompt.
Possible Unicode symbols to represent StGit-applied patches:
This is a great idea and I quite like it, but I'd like to mix the git prompt with "classic" debian style (user@host and pwd)
I tried to add bits of the original PS1 to PROMPT_END, but I'm not a bash wizard and my syntax is never completely correct.
Any suggestions?
Reference: Debian .bashrc:
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
I installed this script on my CentOS server and it's working fine except that it's printing _LAST_COMMAND_INDICATOR_
in the output of my prompt after the actual last command indicator. For example:
✔ _LAST_COMMAND_INDICATOR_ ~/.bash-git-prompt [master|✚ 1]
09:30 #
✘-127 _LAST_COMMAND_INDICATOR_ ~/.bash-git-prompt [master|✚ 1]
09:34 #
I'm not sure how to fix this!
Consider changing the last line of gitprompt.sh to
PROMPT_COMMAND=$PROMPT_COMMAND;setGitPrompt
This would allow previous PROMPT_COMMAND:s to for example set window title.
With GIT_PROMPT_SHOW_LAST_COMMAND_INDICATOR=1
, I added the following setting:
GIT_PROMPT_START="\n"
my intention being to have one blank line between any previous output and the current prompt.
However, the contents of GIT_PROMPT_START
(a newline character in this case) are inserted after the last command indicator (whether ✔ or ✘), not before, as I would expect.
✘
~ [master|✚ 1]
20:18 $
I consider this a bug, as by "prompt start" I understand a position before any other prompt contents, including the last command indicator.
I tried to do this
GIT_PROMPT_START= echo "[Server]" # uncomment for custom prompt start sequence
Did not work
The gitstatus.sh file contains these:
# change those symbols to whatever you prefer
symbols_ahead='↑·'
symbols_behind='↓·'
symbols_prehash=':'
It would be very handful if those var could be customizable like GIT_PROMPT_START
or GIT_PROMPT_END
(and some others) which are customizable adding them in a .git-prompt-colors.sh
file.
When outside a git repository leave the prompt as the default prompt. Currently it overrides it and shows no path info. Just the time which is something I'd never expect to see and doesn't really provide anything useful.
Before i'm starting working with bash-git-prompt in my ~/.bashrc file
export WORKON_HOME="$HOME/.virtualenvs"
source /usr/local/bin/virtualenvwrapper.sh
All works ok, but then i add bash-git-prompt in my ~/.bashrc file virtualenvwrapper can't work normally.
For example i can't see current selected virtualenv in my bash prompt. I think bash-git-prompt override it not correctly.
GIT_PROMPT_ONLY_IN_REPO=1
source ~/.bash-git-prompt/gitprompt.sh
export WORKON_HOME="$HOME/.virtualenvs"
source /usr/local/bin/virtualenvwrapper.sh
I try to move bash-git-prompt after virtualenvwrapper, but get same problem.
Now i'm using last version of bash-git-prompt from master brunch.
On standard bash in OS X:
GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)
Copyright (C) 2007 Free Software Foundation, Inc.
This appears now when loading bash prompt:
-bash: declare: -g: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: declare: -g: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: declare: -g: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: declare: -g: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: declare: -g: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: declare: -g: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: declare: -g: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: declare: -g: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: declare: -g: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: declare: -g: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: declare: -g: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
The new read me says "Please see the updated git-prompt-colors.sh in the installation directory!"
However, I looking around I don't see this updated file. I have looked in /usr/local/Cellar/bash-git-prompt/2.2/share/ where there is a prompt.colors.sh, but that does not seem to be it.
-- Christopher Allen
In case of a new repo, there is no remote ref and so the "git fetch --quiet" on line 108 of gitprompt.sh generates an error:
fatal: No remote repository specified. Please, specify either a URL or a
remote name from which new revisions should be fetched.
~/tmp [master|✔]
I'm not git-savvy enough to be sure of the best way to prevent this; perhaps test for non-null from "git remote show"?
[[ -n $(git remote show) ]] && git fetch --quiet
This is a question, not an issue. When I create a new branch I see an L
next to the branch name. What does this L
mean? Thanks.
Running fresh install of Ubuntu 13.04. When revert back to PROMPT_COMMAND=setGitPrompt
, everything works fine.
Here's what I got to work:
if [ -z "$PROMPT_COMMAND" ]; then
PROMPT_COMMAND=setGitPrompt
else
PROMPT_COMMAND="$PROMPT_COMMAND;setGitPrompt"
fi
This code uses quotes to properly concatenate existing commands, but also checks if the there is no prior-defined commands and skips the concatenation.
I am using GitHub with the SSH access method, which I don't understand in the least, but I know how to follow directions, and I followed the directions given to me in the Git Workflow document for the project I am working on. I find that when using bash-git-prompt, the prompt sometimes adds the phrase "Enter passphrase for key ..." followed by the name of the file containing the SSH key for GitHub. It doesn't always appear, but seems kind of random - like once every 10 prompts or so. I guess something done in gitstatus.sh is executing a command that triggers this but isn't successfully filtering it out. Seems harmless - the command isn't actually waiting for input, and the prompt doesn't look malformed otherwise. but it is kind of annoying.
I realize that's practically no information to go on, but still, I'd love to see this fixed.
The RPM spec is outdated. As I currently cannot do it by myself, someone should update the bash-git-prompt.spec
to reflect the changes with the themes
Do you know easy way to disable prompt only for home directory or another workaround? I use this repo to sync config between the laptops. It is very annoying see prompt in every directory under $HOME. It even happens that i'm going to create new project, for example, at night, have created $HOME/repos/project, have started working on it( haven't initialized yet), and on next day seeing that repository clean and when i'm ready to add/commit, do this action on wrong "home config" repo. Sorry, if example is not very good.
I like that I can now put my prompt under brew install bash-git-prompt
control, however, I found it difficult to figure out how to make it work with the solarized-dark and solarized-light themes that I use in my terminal. As these colors are very popular, can you offer an alternative prompt-color.sh & git-prompt-color.sh that are solarized?
Thanks!
-- Christopher Allen
If the remote repo is accessed via ssh and requests an login, then the checkUpstream will not work.
So, either the checkUpstream should be disabled if there is a login request or there should be documentation about this and how to avoid it (eg by creating a ssh key to login).
Hey.
Every time I cd
into a new repository or just press return
, it takes too long to show me the prompt. It seems that it is fetching the remote repository.
Is it normal to be that slow or just happens with me?
I have a feature request. The Git prompt should show a tick or a cross based on the exit value of the last command that has been run. Something like this: http://fazlearefin.blogspot.com.au/2014/06/customizing-bash-prompt-to-show-tick-or.html
A glance at the prompt can tell whether the last command ran successfully. Thanks.
The bash git prompt is extremely slow for large repositories. Its taking about 10 seconds after I press enter.
Is there a way to modify/disable prompt for certain repositories using .bash-git-rc ? I tried adding GIT_PROMPT_FETCH_REMOTE_STATUS=0 but its still extremely slow.
This script compares between local and origin. How do I change it to compare to a different remote? Thanks!
Sometimes commands complete and spit out the following to the screen.
[1]+ Done { $1 >&/dev/null; }
This seems to only have happened after the latest merge.
What about the local repos?
Any variable within themes for that? :D
At the moment I see a uppercase letter 'L' , which is generated from gitstatus.sh
if [[ "$has_remote_tracking" == "0" ]] ; then
remote='L'
fi
It would be great to have a variable also for that
My prompt is something along the lines of:
my_current_path [master L|✔]
What is the meaning of "L" in this instance? Do I understand correctly that it indicates that the remote branch is neither ahead of nor behind the local branch?
Many thanks.
I changed in gitprompt.sh
file from
local Time12a="$(date +%H:%M)"
#local Time12a="($(date +%H:%M:%S))"
to
#local Time12a="$(date +%H:%M)"
local Time12a="($(date +%H:%M:%S))"
I executed this git_prompt_reset
(as said in https://github.com/magicmonty/bash-git-prompt#further-customizations, in the last point), and restarted my terminal, but I am still getting the old prompt. I should have seen the updated prompt with seconds as expected.
The check always returns true, even if the file is readable:
if [[ !(-r $__GIT_PROMPT_THEME_FILE) ]]; then
GIT_PROMPT_THEME="Default"
__GIT_PROMPT_THEME_FILE=$DEFAULT_THEME_FILE
fi
My bash version is GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin13). It is quite fishy to me, but it is fixed by dropping a space between ! and ( tokens.
if [[ ! (-r $__GIT_PROMPT_THEME_FILE) ]]; then
GIT_PROMPT_THEME="Default"
__GIT_PROMPT_THEME_FILE=$DEFAULT_THEME_FILE
fi
Hello,
I created a custom theme, then in my .bash_profile
:
# .bash_profile
GIT_PROMPT_THEME=Mine
GIT_PROMPT_ONLY_IN_REPO=1
source ~/bash-git-prompt/gitprompt.sh
then in my theme Mine.bgptheme
:
# ~/bash-git-prompt/themes/Mine.bgptheme
GIT_PROMPT_SYMBOLS_AHEAD="↑"
GIT_PROMPT_SYMBOLS_BEHIND="↓"
GIT_PROMPT_SYMBOLS_PREHASH=":"
The whole theme seems working, however I still get the default ahead and behind simbols with the dot:
# original
# Please do not add colors to these symbols
GIT_PROMPT_SYMBOLS_AHEAD="↑·" # The symbol for "n versions ahead of origin"
GIT_PROMPT_SYMBOLS_BEHIND="↓·" # The symbol for "n versions behind of origin"
GIT_PROMPT_SYMBOLS_PREHASH=":" # Written before hash of commit, if no name could be found
My aim is to remove those dots within my theme and seems it's not working.
Any hint? Is this a bug?
Hi
Before installing the virtualenv name was visible but after installing its missing.
Colors counts toward the total length of a command unless you wrap them in [ ]
This describes the issue:
http://askubuntu.com/questions/111840/ps1-problem-messing-up-cli
BTW, very well done prompt!
Sometimes when pressing ctrl-z to suspend vim to do some terminal work, I get the following message:
[1]+ Stopped vim src/networking/remoteserverbridge.cpp
bash: warning: deleting stopped job 1 with process group 15512
When trying to resume vim using fg after that, I get this:
02:26 $ fg
bash: fg: job has terminated
[2]+ Done { $1 &>/dev/null; }
This doesn't happen every single time I suspend it, but I can't even develop for 10 min before it happens, and it started to happen this evening which is the first evening I've been using bash-git-prompt and it has never ever happened before.
My system is Debian sid.
Put line to the end of my ~/.bashrc
~/.bash-git-prompt/gitprompt.sh
Got error:
/home/larionov/.bash-git-prompt/gitprompt.sh: 3: /home/larionov/.bash-git-prompt/gitprompt.sh: Syntax error: "(" unexpected
So I changed a line !#/bin/sh to !#/bin/bash and it's still doesn't work, but without any error messages.
I am running this on my ubuntu, running perfectly. But I also have a Centos running on my machine on a virtualbox. When I implement this tool I can only the time stamp but not the git branch name or anything.
Is that tested with Centos. Can you please tell me what can be the reason.
For that reason I am using another solution for my Centos box, but I really wanted this one to work for me.
This is what happnes:
admin@muhammadr ~/.bash-git-prompt (master) $ ll
total 64
-rwxr--r-- 1 admin admin 2962 Oct 1 15:49 gitprompt.fish
-rwxr--r-- 1 admin admin 22550 Oct 1 15:49 gitprompt.png
-rw-r--r-- 1 admin admin 5181 Oct 8 16:01 gitprompt.sh
-rwxr--r-- 1 admin admin 2767 Oct 1 15:49 gitstatus.py
-rwxr--r-- 1 admin admin 2430 Oct 1 15:49 README.md
admin@muhammadr ~/.bash-git-prompt (master) $ source gitprompt.sh
~/.bash-git-prompt
10:47 $
If I scroll back through my bash history then come back to the most recent command there are some extra characters added to the front of the string.
09:35 $ ruecho "test" test
Once I've picked up the extra characters, i'm unable to delete them. I can however ctrl-C to get rid of them.
Note that the command actually executes without the ru characters interfering.
I did a git pull this morning and my custom prompt no longer works.
The behavior I see is that when I'm in a git repo, the prompt works fine, but when I'm not in a repo my prompt loses the GIT_PROMPT_END setting.
Screenshot of good and bad prompts:
After doing a git bitsect to find the commit that broke the prompt, I got this:
ff7575ccdcc556e5ffb591bff85b8b7ac4e2f985 is the first bad commit
commit ff7575ccdcc556e5ffb591bff85b8b7ac4e2f985
Author: Martin Goldhahn <[email protected]>
Date: Sun Aug 4 19:06:28 2013 +0200
apply git prompt only on directories belonging to a git repository
:000000 100644 0000000000000000000000000000000000000000 e7683df559d8d3dd9e7761a01777940608f18654 A .gitignore
:100644 100644 f9e5c69e6ab45c171994beaef04c9a24559efd10 cb7254dbf6efebbcafb9efae5c58ab862996702b M gitprompt.sh
Here's my custom prompt setup:
PS1="\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]"
GIT_PROMPT_START=$PS1
GIT_PROMPT_END="\n[\t]$ "
source ~/.bash/bash-git-prompt/gitprompt.sh
Steps to reproduce:
git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt
source ~/.bash-git-prompt/gitprompt.sh
to ~/.bashrc
source ~/.bashrc
cp ~/.bash-git-prompt/git-prompt-colors ~/.git-prompt-colors.sh
~/.git-prompt-colors.sh
source ~/.bashrc
Changes do not appear.
I believe this is because here the __GIT_PROMPT_COLORS_FILE variable is set to ~/.bash-git-prompt/git-prompt-colors.sh
on the first run, when ~/.git-prompt-colors.sh
doesn't exist.
Then ~/.git-prompt-colors.sh
is created, but is never read when re-sourcing because this uses the old variable.
The only way to get the changes to appear is to manually set the environment variable or close out of the terminal.
Not sure if this is worth fixing, but perhaps it is worth mentioning as it took me a bit to figure out why my changes weren't appearing (normally I get something up and working before making config changes).
hi,
even if i set
GIT_PROMPT_SHOW_LAST_COMMAND_INDICATOR=1
just before i source ~/.bash-git-prompt/gitprompt.sh
the pompt always give mi success prompt and never failure even if the last command gives not 0.
anyway it'd be also useful in case of failure the last return value would be printed eg:
✘-1
I was wondering if it would be possible to have a function that I can call from within my PS1 to make customization easier. For example, something like:
PS1='\u@\h:\W\[\033[01;33m\]$(__git_prompt)\[\033[00m\]$ '
This is the error on load terminal
.bash/gitprompt.sh: 6: /home/user/.bash/gitprompt.sh: Bad substitution
Environment:
Bash version 4.2.45(1)-release (x86_64-pc-linux-gnu)
S.O. Ubuntu 13.04 raring
Teminal Emulatos Terminator | Xfce Terminal | Xterm
As I don't use the fish shell, I have no experience in fish scripting.
The gitprompt.fish
is way behind the gitprompt.sh
in functionality.
If you accept the challenge, your task is, to update the gitprompt.fish
to the same functionality as the gitprompt.sh
Right you now say:
==> Caveats
You should add the following to your .bashrc (or equivalent):
source /usr/local/opt/bash-git-prompt/share/gitprompt.sh
Instead I suggest:
if [ -f $(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh ]; then
source $(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh
fi
or if you prefer a single line:
if [ -f $(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh ]; then source $(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh ; fi
Two reasons:
-- Christopher Allen
Hello! Would you consider adding this to @Homebrew for Mac?
According to installation, after clone we need to copy files to ".bash" folder, we also need to "source /home/%USER%/.bash/gitprompt.sh" to ~/.bashrc file.
if $PROMPT_START $PROMPT_END are changed by user it will be not that simple as "git pull" to update to latest version of bash-git-prompt.
Expected: $PROMPT_START $PROMPT_END variables have to be defined to default only if not defined before.
that will allow define all in ~/.bashrc file
if [ "$PROMPT_START" = "" ] ; then
PROMPT_START="$Yellow$PathShort$ResetColor"
fi
if [ "$PROMPT_END" = "" ] ; then
PROMPT_END=" \n$WHITE$Time12a$ResetColor $ "
fi
Do you know if it is possible to code this so that the the prompt is displayed immediately, and then later display the git info when it has been pulled down from the network? The delay for displaying the prompt can be quite large (a few seconds) and it is enough to be annoying. I imagine it is even worse on a slow connection. This is the nicest prompt I've ever seen, so it would be great if it could work in this manner. My knowledge of bash is very limited, but I would be happy to work on this if you believe it is possible without breaking the UI.
Cheers
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.