Skip to content

Commit 41b9976

Browse files
author
Oscar San Jose
committed
Add mercurial info in prompt
1 parent ee33177 commit 41b9976

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

bashrc

+5-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export GIT_CEILING_DIRECTORIES=`echo $HOME | sed 's#/[^/]*$##'` # Either /home(
9292
export HISTFILESIZE=1000000000
9393
export HISTSIZE=1000000
9494
export PROMPT_COMMAND='history -a'
95-
export BROWSER='firefox'
95+
export BROWSER='chromium-browser'
9696
#export LANG='en_US.utf8'
9797
export LANG='C' # Testing: Try out the C locale
9898
if [ -f "$HOME/.inputrc" ]; then
@@ -314,6 +314,8 @@ add_path $HOME/.bash/group/bin
314314
# Set up git completion
315315
source $HOME/.bash/config/git-completion.bash
316316

317+
source $HOME/.bash/config/vcs-completion.bash
318+
317319
###### PROMPT ######
318320
# Set up the prompt colors
319321
source $HOME/.bash/term_colors
@@ -330,7 +332,8 @@ fi
330332
# (5) Color highlight out the current directory because it's important
331333
# (6) The export PS1 is simple to understand!
332334
# (7) If the prev command error codes, the prompt '>' turns red
333-
export PS1="$Y\t$N $W"'$(__git_ps1 "(%s) ")'"$N$PROMPT_COLOR\u@\H$N:$C\w$N\n"'$CURSOR_PROMPT '
335+
export PS1="$Y\t$N $W"'$(__git_ps1 "(%s) ")''$(vcs_summary)'"$N$PROMPT_COLOR\u@\H$N:$C\w$N\n"'$CURSOR_PROMPT '
336+
334337
# TODO: Find out why my $R and $N shortcuts don't work here!!!
335338
export PROMPT_COMMAND='if [ $? -ne 0 ]; then CURSOR_PROMPT=`echo -e "\033[0;31m>\033[0m"`; else CURSOR_PROMPT=">"; fi;'
336339

config/vcs-completion.bash

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# set colors
2+
export CLICOLOR=1
3+
export LSCOLORS=ExFxCxDxBxegedabagacad
4+
5+
# Reads the hg summary line by line, outputs the working branch
6+
# revision number and notifies if there's untracked files or changes
7+
# Inspired by Steve Losh's implementation:
8+
# http://stevelosh.com/blog/2009/03/mercurial-bash-prompts/
9+
# gsub(/ */,"",pieces[split($3,pieces
10+
vcs_summary() {
11+
hg summary 2> /dev/null | \
12+
awk 'BEGIN {RS=""; FS="\n"} {
13+
gsub(/ */,"",$3)
14+
printf ("(\033[0;37m"pieces[split($3,pieces,":")],$0);
15+
printf ("\033[37;0m·r" substr(pieces[split($1,pieces,":")-1],2),$0);
16+
if(match($4, "modified"))
17+
printf ("\033[0;32m!",$0);
18+
else if (match($4, "unknown") && !match($4, "modified"))
19+
printf ("\033[0;32m?",$0);
20+
printf ("\033[37;0m) ",$0)
21+
}'
22+
}

0 commit comments

Comments
 (0)