From 81d5c3130895f6ddb9fc52fa0e67a5af926602d4 Mon Sep 17 00:00:00 2001 From: Sergey Shepelev Date: Tue, 6 Apr 2010 09:51:54 +0800 Subject: Lowercase letters in 'vim:' prefix for files currently opened in vim. Uppercase is too much drama. --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index c262f9c..99cf6ba 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -584,7 +584,7 @@ parse_vcs_status() { [[ ${added_files[0]} ]] && file_list+=" "$added_vcs_color${added_files[@]} [[ ${modified_files[0]} ]] && file_list+=" "$modified_vcs_color${modified_files[@]} [[ ${untracked_files[0]} ]] && file_list+=" "$untracked_vcs_color${untracked_files[@]} - [[ ${vim_files} ]] && file_list+=" "${RED}VIM:${vim_files} + [[ ${vim_files} ]] && file_list+=" "${RED}vim:${vim_files} file_list=${file_list:+:$file_list} if [[ ${#file_list} -gt $max_file_list_length ]] ; then -- cgit v1.2.3 From 29166a64b83b15185d58fbc44e07214dff46d8c4 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Wed, 11 Aug 2010 20:52:13 +0300 Subject: -- minore docs --- git-prompt.sh | 4 ++-- index.txt | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index a4c7216..07a2186 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -510,7 +510,7 @@ parse_git_status() { ### compose vcs_info if [[ $init ]]; then - vcs_info=M$white=init + vcs_info=${white}init else if [[ "$detached" ]] ; then @@ -604,7 +604,7 @@ disable_set_shell_label() { trap - DEBUG >& /dev/null } -# enable stuffing currently executed command displays in label +# show currently executed command in label enable_set_shell_label() { disable_set_shell_label # check for BASH_SOURCE being empty, no point running set_shell_label on every line of .bashrc diff --git a/index.txt b/index.txt index a0c3b84..d8dd50b 100644 --- a/index.txt +++ b/index.txt @@ -11,7 +11,7 @@ image:screenshot-prompt-basic.png[basic usage] Digit [red]*1* on 3rd line is `false(1)` exit code. Also on non-zero exit code -terminal bell is sounded. Bell is turnned off by default (to set softer +terminal bell is sounded. Bell is turned off by default (to set softer terminal bell use `setterm`). @@ -68,11 +68,11 @@ caption always "%{= kw}%-w%{= bw}%n %t%{-}%+w %-= @%H - %LD %d %LM - %c" == Simple AutoJump AutoJump is python script from Joel Schaerer providing shortcuts for jumping -to directories you once visited. Git-prompt have builtin, simplified -autojump. It is only about 10 lines of code (vs original 100+ LOC), there is -no database. It remembers only directories from current session. It selects -not most frequent dir, but last visited. Matches are done from beginning of of -dir name (not path name). +to directories you once visited. Git-prompt have built-in, simplified +autojump. It is only about 10 lines of bash code (vs original 100+ python +LOC), there is no database. It remembers only directories from current +session. It selects not most frequent dir, but last visited. Matches are done +from beginning of of dir name (not path name). ----------------- cd /tmp -- cgit v1.2.3 From c9a2fdb4adf4cc87beb77a4179873a623ae12b3b Mon Sep 17 00:00:00 2001 From: Gustavo Delfino Date: Sun, 4 Jul 2010 12:30:20 +0800 Subject: File lists now work under Mac OS X In the file_regex, the ? (for zero or one) repetitions was not being recognized by the sed included in my Mac OS X 10.6 machine. This is now fixed. --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index 88db6bc..f951623 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -414,7 +414,7 @@ parse_git_status() { parse_git_complete ########################################################## GIT STATUS - file_regex='\([^/]*\/\?\).*' + file_regex='\([^/]*\/\{0,1\}\).*' added_files=() modified_files=() untracked_files=() -- cgit v1.2.3 From 4625e6372e182dde1338fd70c4c97bef0548b9a6 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sat, 29 Jan 2011 08:55:57 +0200 Subject: -- docs --- index.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.txt b/index.txt index d8dd50b..61b68ea 100644 --- a/index.txt +++ b/index.txt @@ -27,8 +27,8 @@ image:screenshot-prompt-git.png[git module screenshot] | *Branch* | *File* | *Meaning* | [darkblue]#dark blue# | | Clean repo | [green]#green# | [green]#green# | Modified or new file. Modifications are in index but not in repo yet. -| [#cc0000]#dark red# | [#cc0000]#dark red# | Modified and tracked by repo, but modifications not added to index yet. -| [blue]#light blue# | [blue]#light blue# | Untracked file. +| [darkred]#dark red# | [darkred]#dark red# | Modified and tracked by repo, but modifications not added to index yet. +| [lightblue]#light blue# | [lightblue]#light blue# | Untracked file. | [red]#light red# | | Detached Head | [magenta]#magenta# | | In middle of doing something |================================================================ -- cgit v1.2.3 From 26399ed27e357b1bcd1bbd47182fcc474ebb52e9 Mon Sep 17 00:00:00 2001 From: Dan Bravender Date: Tue, 3 Aug 2010 11:25:48 +0800 Subject: My TERM is xterm-256color even under screen for some reason --- git-prompt.sh | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index f951623..3b8cc4c 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -220,22 +220,25 @@ set_shell_label() { # FIXME $STY not inherited though "su -" [ "$STY" ] && screen -S $STY -X title "$*" } + if [[ -n "$STY" ]]; then + screen_label "$*" + else + case $TERM in - case $TERM in + screen*) + screen_label "$*" + ;; - screen*) - screen_label "$*" - ;; - - xterm* | rxvt* | gnome-terminal | konsole | eterm | wterm ) - # is there a capability which we can to test - # for "set term title-bar" and its escapes? - xterm_label "$plain_who_where $@" - ;; + xterm* | rxvt* | gnome-terminal | konsole | eterm | wterm ) + # is there a capability which we can to test + # for "set term title-bar" and its escapes? + xterm_label "$plain_who_where $@" + ;; - *) - ;; - esac + *) + ;; + esac + fi } export -f set_shell_label -- cgit v1.2.3 From 06a20ea0cf53246a140af7863bd3906c2a18ef28 Mon Sep 17 00:00:00 2001 From: Robert Wahler Date: Mon, 29 Nov 2010 23:59:21 +0800 Subject: unset tty on cygwin under console2 --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index 3b8cc4c..21f3610 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -264,7 +264,7 @@ set_shell_label() { # we don't need tty name under X11 case $TERM in - xterm* | rxvt* | gnome-terminal | konsole | eterm | wterm ) unset tty ;; + xterm* | rxvt* | gnome-terminal | konsole | eterm | wterm | cygwin) unset tty ;; *);; esac -- cgit v1.2.3 From 8d45f1fc7acdedc21d6ad141b281ecdd19a859ea Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sat, 29 Jan 2011 15:29:51 +0200 Subject: removed bash completion for git-prompt bash git completion can be enabled from .bash_profile. Put something following in your profile: [[ -f "/etc/bash_completion.d/git" ]] && . /etc/bash_completion.d/git [[ -f "/usr/share/bash-completion/git" ]] && . /usr/share/bash-completion/git --- git-prompt.sh | 20 +------------------- index.txt | 10 ---------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 21f3610..021000f 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -15,6 +15,7 @@ conf=~/.config/git-prompt.conf; [[ -r $conf ]] && . $conf unset conf + ##### set defaults if not set git_module=${git_module:-on} @@ -384,24 +385,6 @@ parse_hg_status() { } -parse_git_complete() { - if [ "${BASH_VERSION%.*}" \< "3.0" ]; then - # echo "You will need to upgrade 'bash' to version 3.0 \ - # for full programmable completion features (bash complete) \ - # Please install bash-completion packet like: $ yum -y install bash-completion" - return - fi - - complete -f -W "$( - echo `git branch -a | sed -e s/[\ \*]//g | cut -f 1 -d ' ' | uniq`; \ - echo `git remote | sed -e s/[\ \*]//g | cut -f 1 -d ' ' | uniq`; \ - echo `git | tail -23 | head -21 | cut -d ' ' -f 4`; \ - echo '--help'; \ - echo '--staged'; \ - echo 'remote'; \ - echo 'help'; \ - )" g git -} parse_git_status() { @@ -414,7 +397,6 @@ parse_git_status() { [[ -n ${git_dir/./} ]] || return 1 vcs=git - parse_git_complete ########################################################## GIT STATUS file_regex='\([^/]*\/\{0,1\}\).*' diff --git a/index.txt b/index.txt index d8dd50b..ab786ba 100644 --- a/index.txt +++ b/index.txt @@ -87,16 +87,6 @@ j .*3 # same as cd "~/long dir mp3" ------------- -== Bash Completion - -Completion can be done for git subcommands, branches and remotes: - ---------------------- -git ch # expands to git checkout -git checkout ma # expands to git checkout master --------------------- - - == Install Download link:git-prompt.sh[] or get it with GIT: -- cgit v1.2.3 From 13c986f650c1f165402b412a8bd2611f0f9f4f26 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sat, 29 Jan 2011 16:27:02 +0200 Subject: BSD's hostname understands only "-s" --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index 021000f..341182b 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -284,7 +284,7 @@ set_shell_label() { #then host=${HOSTNAME} - #host=`hostname --short` + #host=`hostname -s` host=${host#$default_host} uphost=`echo ${host} | tr a-z A-Z` if [[ $upcase_hostname = "on" ]]; then -- cgit v1.2.3 From 947179b9ccec126fd6d89f93d079d402a9d5994f Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sat, 29 Jan 2011 16:46:46 +0200 Subject: file regex change: get filename up to first space --- git-prompt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 341182b..7646eec 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -399,7 +399,7 @@ parse_git_status() { vcs=git ########################################################## GIT STATUS - file_regex='\([^/]*\/\{0,1\}\).*' + file_regex='\([^/ ]*\/\{0,1\}\).*' added_files=() modified_files=() untracked_files=() @@ -612,7 +612,7 @@ j (){ fi done echo '?' -} + } alias jumpstart='echo ${aj_dir_list[@]}' @@ -644,7 +644,7 @@ prompt_command_function() { PS1="$colors_reset$rc$head_local$color_who_where$dir_color$cwd$tail_local$dir_color$prompt_char $colors_reset" unset head_local tail_local pwd -} + } PROMPT_COMMAND=prompt_command_function -- cgit v1.2.3 From 75ccb53a6ccc5c40e8d46e4f78fa3ad891ef9c2f Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sat, 29 Jan 2011 16:46:46 +0200 Subject: file regex change: get filename up to first space --- git-prompt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 341182b..7646eec 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -399,7 +399,7 @@ parse_git_status() { vcs=git ########################################################## GIT STATUS - file_regex='\([^/]*\/\{0,1\}\).*' + file_regex='\([^/ ]*\/\{0,1\}\).*' added_files=() modified_files=() untracked_files=() @@ -612,7 +612,7 @@ j (){ fi done echo '?' -} + } alias jumpstart='echo ${aj_dir_list[@]}' @@ -644,7 +644,7 @@ prompt_command_function() { PS1="$colors_reset$rc$head_local$color_who_where$dir_color$cwd$tail_local$dir_color$prompt_char $colors_reset" unset head_local tail_local pwd -} + } PROMPT_COMMAND=prompt_command_function -- cgit v1.2.3 From 1b3fecb0ec15d93df942b4a99d35fd6b992e160a Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Thu, 3 Mar 2011 14:49:15 +0200 Subject: -- docs --- index.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/index.txt b/index.txt index 3c816e2..b9b8cff 100644 --- a/index.txt +++ b/index.txt @@ -158,12 +158,8 @@ dependencies are standard unix utils. == Todo -* Subshells number indicator. Don't know how to do this. There is bash - `"\j"`, but let say I want `">>"` after path instead of `">"` when I have 2 jobs - running. Running `+++`jobs | ... `+++` is extra bash fork, hate to do this. * VIM module needs to be moved out of GIT module - include::../volnitsky.com/project/howto-submit-patch.txt[] Nobody will use git-prompt if there will be delay in prompt display. -- cgit v1.2.3 From 5dc647adfd86ab719efe146f2dfbd11fecdfff46 Mon Sep 17 00:00:00 2001 From: Thomas Geffert Date: Wed, 2 Mar 2011 19:08:08 +0800 Subject: added count_only option --- git-prompt.conf | 2 +- git-prompt.sh | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/git-prompt.conf b/git-prompt.conf index dd88fd0..414c3d6 100644 --- a/git-prompt.conf +++ b/git-prompt.conf @@ -10,7 +10,7 @@ # error_bell=off # sound terminal bell when command return code is not zero. (use setterm to set pitch and duration) # max_file_list_length=100 # in characters - +# count_only=off # off - display file list; on - display file count ############################################################ MODULES diff --git a/git-prompt.sh b/git-prompt.sh index 7646eec..e4eb9f6 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -55,6 +55,7 @@ max_file_list_length=${max_file_list_length:-100} upcase_hostname=${upcase_hostname:-on} + count_only=${count_only:-off} aj_max=20 @@ -566,9 +567,15 @@ parse_vcs_status() { ### file list unset file_list - [[ ${added_files[0]} ]] && file_list+=" "$added_vcs_color${added_files[@]} - [[ ${modified_files[0]} ]] && file_list+=" "$modified_vcs_color${modified_files[@]} - [[ ${untracked_files[0]} ]] && file_list+=" "$untracked_vcs_color${untracked_files[@]} + if [[ $count_only = "on" ]] ; then + [[ ${added_files[0]} ]] && file_list+=" "${added_vcs_color}+${#added_files[@]} + [[ ${modified_files[0]} ]] && file_list+=" "${modified_vcs_color}*${#modified_files[@]} + [[ ${untracked_files[0]} ]] && file_list+=" "${untracked_vcs_color}?${#untracked_files[@]} + else + [[ ${added_files[0]} ]] && file_list+=" "$added_vcs_color${added_files[@]} + [[ ${modified_files[0]} ]] && file_list+=" "$modified_vcs_color${modified_files[@]} + [[ ${untracked_files[0]} ]] && file_list+=" "$untracked_vcs_color${untracked_files[@]} + fi [[ ${vim_files} ]] && file_list+=" "${RED}vim:${vim_files} file_list=${file_list:+:$file_list} -- cgit v1.2.3 From 47b70d6de513aaa8f32911c92f1f3508c76c6f53 Mon Sep 17 00:00:00 2001 From: Thomas Geffert Date: Wed, 2 Mar 2011 19:12:15 +0800 Subject: added rawhex_len option to set length of displayed git revision id --- git-prompt.conf | 1 + git-prompt.sh | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/git-prompt.conf b/git-prompt.conf index 414c3d6..c136964 100644 --- a/git-prompt.conf +++ b/git-prompt.conf @@ -11,6 +11,7 @@ # error_bell=off # sound terminal bell when command return code is not zero. (use setterm to set pitch and duration) # max_file_list_length=100 # in characters # count_only=off # off - display file list; on - display file count +# rawhex_len=6 # length of git rawhex revision id display (use 0 to hide it) ############################################################ MODULES diff --git a/git-prompt.sh b/git-prompt.sh index e4eb9f6..81bca6c 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -56,6 +56,7 @@ max_file_list_length=${max_file_list_length:-100} upcase_hostname=${upcase_hostname:-on} count_only=${count_only:-off} + rawhex_len=${rawhex_len:-6} aj_max=20 @@ -483,9 +484,13 @@ parse_git_status() { #### GET GIT HEX-REVISION - rawhex=`git rev-parse HEAD 2>/dev/null` - rawhex=${rawhex/HEAD/} - rawhex=${rawhex:0:6} + if [[ $rawhex_len -gt 0 ]] ; then + rawhex=`git rev-parse HEAD 2>/dev/null` + rawhex=${rawhex/HEAD/} + rawhex="$white=${rawhex:0:$rawhex_len}" + else + rawhex="" + fi #### branch branch=${branch/master/M} @@ -511,7 +516,7 @@ parse_git_status() { fi #branch="<$branch>" fi - vcs_info="$branch$white=$rawhex" + vcs_info="$branch$rawhex" fi } -- cgit v1.2.3 From 14b6abff6494f74b653ff161c1bb1069ec8e09e1 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Thu, 7 Apr 2011 16:37:26 +0300 Subject: -- --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index 81bca6c..bd874af 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -592,7 +592,7 @@ parse_vcs_status() { fi - head_local="(${vcs_info}$vcs_color${file_list}$vcs_color)" + head_local="$vcs_color(${vcs_info}$vcs_color${file_list}$vcs_color)" ### fringes head_local="${head_local+$vcs_color$head_local }" -- cgit v1.2.3 From 171249d55e676dbf5e26c590955d3dc273cba1bb Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Fri, 22 Apr 2011 05:58:20 +0300 Subject: rev-number (hex) now in dim (half-bright) color --- git-prompt.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index bd874af..30ca64e 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -43,7 +43,7 @@ prompt_char=${prompt_char:-'>'} root_prompt_char=${root_prompt_char:-'>'} - #### vcs state colors + #### vcs colors init_vcs_color=${init_vcs_color:-WHITE} # initial clean_vcs_color=${clean_vcs_color:-blue} # nothing to commit (working directory clean) modified_vcs_color=${modified_vcs_color:-red} # Changed but not updated: @@ -52,6 +52,7 @@ untracked_vcs_color=${untracked_vcs_color:-BLUE} # Untracked files: op_vcs_color=${op_vcs_color:-MAGENTA} detached_vcs_color=${detached_vcs_color:-RED} + hex_vcs_color=${hex_vcs_color:-dim} max_file_list_length=${max_file_list_length:-100} upcase_hostname=${upcase_hostname:-on} @@ -97,6 +98,7 @@ ### if term support colors, then use color prompt, else bold black='\['`tput sgr0; tput setaf 0`'\]' + dim='\['`tput sgr0; tput setaf p1`'\]' # half-bright red='\['`tput sgr0; tput setaf 1`'\]' green='\['`tput sgr0; tput setaf 2`'\]' yellow='\['`tput sgr0; tput setaf 3`'\]' @@ -130,6 +132,7 @@ op_vcs_color=${!op_vcs_color} addmoded_vcs_color=${!addmoded_vcs_color} detached_vcs_color=${!detached_vcs_color} + hex_vcs_color=${!hex_vcs_color} unset PROMPT_COMMAND @@ -487,7 +490,7 @@ parse_git_status() { if [[ $rawhex_len -gt 0 ]] ; then rawhex=`git rev-parse HEAD 2>/dev/null` rawhex=${rawhex/HEAD/} - rawhex="$white=${rawhex:0:$rawhex_len}" + rawhex="$hex_vcs_color=${rawhex:0:$rawhex_len}" else rawhex="" fi -- cgit v1.2.3 From bd894d9ffb776563ad4ffdbef2df3f4576761233 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Fri, 22 Apr 2011 06:24:30 +0300 Subject: fixied: clean repo detection; new hexlen default=5; removed ":" before file list --- git-prompt.conf | 3 ++- git-prompt.sh | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/git-prompt.conf b/git-prompt.conf index c136964..986e6af 100644 --- a/git-prompt.conf +++ b/git-prompt.conf @@ -11,7 +11,7 @@ # error_bell=off # sound terminal bell when command return code is not zero. (use setterm to set pitch and duration) # max_file_list_length=100 # in characters # count_only=off # off - display file list; on - display file count -# rawhex_len=6 # length of git rawhex revision id display (use 0 to hide it) +# rawhex_len=5 # length of git rawhex revision id display (use 0 to hide it) ############################################################ MODULES @@ -85,6 +85,7 @@ # untracked_vcs_color=BLUE # Untracked files: # op_vcs_color=MAGENTA # detached_vcs_color=RED +# hex_vcs_color=dim # :vim:ft=sh ts=8 sw=8 et: diff --git a/git-prompt.sh b/git-prompt.sh index 30ca64e..95559b8 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -6,8 +6,9 @@ ##### read config file if any. - unset dir_color rc_color user_id_color root_id_color init_vcs_color clean_vcs_color - unset modified_vcs_color added_vcs_color addmoded_vcs_color untracked_vcs_color op_vcs_color detached_vcs_color + unset dir_color rc_color user_id_color root_id_color init_vcs_color clean_vcs_color + unset modified_vcs_color added_vcs_color addmoded_vcs_color untracked_vcs_color op_vcs_color detached_vcs_color hex_vcs_color + unset rawhex_len conf=git-prompt.conf; [[ -r $conf ]] && . $conf conf=/etc/git-prompt.conf; [[ -r $conf ]] && . $conf @@ -57,7 +58,7 @@ max_file_list_length=${max_file_list_length:-100} upcase_hostname=${upcase_hostname:-on} count_only=${count_only:-off} - rawhex_len=${rawhex_len:-6} + rawhex_len=${rawhex_len:-5} aj_max=20 @@ -415,7 +416,7 @@ parse_git_status() { git status 2>/dev/null | sed -n ' s/^# On branch /branch=/p - s/^nothing to commit (working directory clean)/clean=clean/p + s/^nothing to commit/clean=clean/p s/^# Initial commit/init=init/p /^# Changes to be committed:/,/^# [A-Z]/ { @@ -585,7 +586,6 @@ parse_vcs_status() { [[ ${untracked_files[0]} ]] && file_list+=" "$untracked_vcs_color${untracked_files[@]} fi [[ ${vim_files} ]] && file_list+=" "${RED}vim:${vim_files} - file_list=${file_list:+:$file_list} if [[ ${#file_list} -gt $max_file_list_length ]] ; then file_list=${file_list:0:$max_file_list_length} -- cgit v1.2.3 From 1d6eb2013f78a6d9419259e1846c3bfd8c54261d Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sat, 23 Apr 2011 15:12:43 +0300 Subject: fixed: sed parsing broken dependent on git status output (verbose or not) --- git-prompt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 95559b8..d77c5cb 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -416,8 +416,8 @@ parse_git_status() { git status 2>/dev/null | sed -n ' s/^# On branch /branch=/p - s/^nothing to commit/clean=clean/p - s/^# Initial commit/init=init/p + s/^nothing to commi.*/clean=clean/p + s/^# Initial commi.*/init=init/p /^# Changes to be committed:/,/^# [A-Z]/ { s/^# Changes to be committed:/added=added;/p -- cgit v1.2.3 From 28b208c552a247acfd1316d52cbabbb67da2220d Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sun, 24 Apr 2011 16:21:58 +0300 Subject: vim module display change if mutilple files edited: display vim:* --- git-prompt.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index d77c5cb..2708eb6 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -564,12 +564,17 @@ parse_vcs_status() { eval $old_nullglob if [[ $vim_glob ]]; then - vim_file=${vim_glob#.} - vim_file=${vim_file/.sw?/} + set $vim_glob + #vim_file=${vim_glob#.} + if [[ $# > 1 ]] ; then + vim_files="*" + else + vim_file=${1#.} + vim_file=${vim_file/.sw?/} + [[ .${vim_file}.swp -nt $vim_file ]] && vim_files=$vim_file + fi # if swap is newer, then this is unsaved vim session - #[[ .${vim_file}.swp -nt $vim_file ]] && vim_files=$vim_file # [temoto custom] if swap is older, then it must be deleted, so show all swaps. - vim_files=$vim_file fi fi -- cgit v1.2.3 From 85a0e20e4f02bb489f1518865b666cc1a42bba83 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Mon, 25 Apr 2011 07:23:20 +0300 Subject: changed vim file color to magenta --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index 2708eb6..f2ce55f 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -590,7 +590,7 @@ parse_vcs_status() { [[ ${modified_files[0]} ]] && file_list+=" "$modified_vcs_color${modified_files[@]} [[ ${untracked_files[0]} ]] && file_list+=" "$untracked_vcs_color${untracked_files[@]} fi - [[ ${vim_files} ]] && file_list+=" "${RED}vim:${vim_files} + [[ ${vim_files} ]] && file_list+=" "${MAGENTA}vim:${vim_files} if [[ ${#file_list} -gt $max_file_list_length ]] ; then file_list=${file_list:0:$max_file_list_length} -- cgit v1.2.3 From f376f95b775f850d37a38a70fa2ab116b75069d8 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Wed, 27 Apr 2011 08:31:34 +0300 Subject: reverting dim hex color for non linux OS-es Under OSX iTerm2 and Terminal do not support dim or BLACK colors. My guess that other OS-es do not support it also. --- git-prompt.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git-prompt.sh b/git-prompt.sh index f2ce55f..efa26c3 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -53,7 +53,13 @@ untracked_vcs_color=${untracked_vcs_color:-BLUE} # Untracked files: op_vcs_color=${op_vcs_color:-MAGENTA} detached_vcs_color=${detached_vcs_color:-RED} + + if [[ $OSTYPE == "linux-gnu" ]] ; then # no linux OSs do not support extra colors hex_vcs_color=${hex_vcs_color:-dim} + else + hex_vcs_color=${hex_vcs_color:-colors_reset} + fi + max_file_list_length=${max_file_list_length:-100} upcase_hostname=${upcase_hostname:-on} -- cgit v1.2.3 From 7fceeab3e50e14af2876e1a31a55ed703c3c732a Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Thu, 28 Apr 2011 16:01:53 +0300 Subject: test --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index 2817ace..0937cc0 100644 --- a/README +++ b/README @@ -2,3 +2,4 @@ GIT Prompt for BASH Screenshots and docs are at: http://volnitsky.com/project/git-prompt + -- cgit v1.2.3 From c9cf30461956b9f3fa101495cffb375d5f88ec10 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Thu, 28 Apr 2011 18:29:21 +0300 Subject: Indicator for when you branch is ahead of origin --- git-prompt.conf | 1 + git-prompt.sh | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/git-prompt.conf b/git-prompt.conf index 986e6af..9f59e8f 100644 --- a/git-prompt.conf +++ b/git-prompt.conf @@ -62,6 +62,7 @@ # prompt_char='>' # root_prompt_char='>' ## prompt_char='$' +## prompt_char='➔' ## root_prompt_char='#' ##### Per host color diff --git a/git-prompt.sh b/git-prompt.sh index efa26c3..907f058 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -105,7 +105,6 @@ ### if term support colors, then use color prompt, else bold black='\['`tput sgr0; tput setaf 0`'\]' - dim='\['`tput sgr0; tput setaf p1`'\]' # half-bright red='\['`tput sgr0; tput setaf 1`'\]' green='\['`tput sgr0; tput setaf 2`'\]' yellow='\['`tput sgr0; tput setaf 3`'\]' @@ -120,9 +119,11 @@ YELLOW='\['`tput setaf 3; tput bold`'\]' BLUE='\['`tput setaf 4; tput bold`'\]' MAGENTA='\['`tput setaf 5; tput bold`'\]' - CYAN='\['`tput setaf 6; tput bold`'\]' # why 14 doesn't work? + CYAN='\['`tput setaf 6; tput bold`'\]' WHITE='\['`tput setaf 7; tput bold`'\]' + dim='\['`tput sgr0; tput setaf p1`'\]' # half-bright + bw_bold='\['`tput bold`'\]' on='' @@ -415,6 +416,7 @@ parse_git_status() { added_files=() modified_files=() untracked_files=() + freshness="$dim=" unset branch status modified added clean init added mixed untracked op detached # quoting hell @@ -424,6 +426,7 @@ parse_git_status() { s/^# On branch /branch=/p s/^nothing to commi.*/clean=clean/p s/^# Initial commi.*/init=init/p + s/^# Your branch is ahead of .[/[:alnum:]]\+. by [[:digit:]]\+ commit\./freshness=${WHITE}↑/p /^# Changes to be committed:/,/^# [A-Z]/ { s/^# Changes to be committed:/added=added;/p @@ -497,7 +500,7 @@ parse_git_status() { if [[ $rawhex_len -gt 0 ]] ; then rawhex=`git rev-parse HEAD 2>/dev/null` rawhex=${rawhex/HEAD/} - rawhex="$hex_vcs_color=${rawhex:0:$rawhex_len}" + rawhex="$hex_vcs_color${rawhex:0:$rawhex_len}" else rawhex="" fi @@ -526,7 +529,7 @@ parse_git_status() { fi #branch="<$branch>" fi - vcs_info="$branch$rawhex" + vcs_info="$branch$freshness$rawhex" fi } -- cgit v1.2.3 From ef34c7d46fe97d6f92cefcb6e3a51a71871fa283 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Thu, 28 Apr 2011 18:46:36 +0300 Subject: Indicator if your branch is behind origin --- git-prompt.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index 907f058..9429743 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -426,7 +426,8 @@ parse_git_status() { s/^# On branch /branch=/p s/^nothing to commi.*/clean=clean/p s/^# Initial commi.*/init=init/p - s/^# Your branch is ahead of .[/[:alnum:]]\+. by [[:digit:]]\+ commit\./freshness=${WHITE}↑/p + s/^# Your branch is ahead of .[/[:alnum:]]\+. by [[:digit:]]\+ commit.*/freshness=${WHITE}↑/p + s/^# Your branch is behind .[/[:alnum:]]\+. by [[:digit:]]\+ commit.*/freshness=${YELLOW}↓/p /^# Changes to be committed:/,/^# [A-Z]/ { s/^# Changes to be committed:/added=added;/p -- cgit v1.2.3 From a84b534c409fcfa7e485b250c8f9db4e50779d3e Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Thu, 28 Apr 2011 21:55:51 +0300 Subject: fixed: autojump was selecting oldest (not most recent) dirs --- git-prompt.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 9429743..6d000ba 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -634,8 +634,7 @@ enable_set_shell_label() { j (){ : ${1? usage: j dir-beginning} # go in ring buffer starting from current index. cd to first matching dir - for (( i=(aj_idx+1)%aj_max; i != aj_idx%aj_max; i=++i%aj_max )) ; do - #echo == ${aj_dir_list[$i]} == $i + for (( i=(aj_idx-1)%aj_max; i != aj_idx%aj_max; i=(--i+aj_max)%aj_max )) ; do if [[ ${aj_dir_list[$i]} =~ ^.*/$1[^/]*$ ]] ; then cd "${aj_dir_list[$i]}" return -- cgit v1.2.3 From 286e406f2c5e7e098efdd45c9df1ddfb2ba6b404 Mon Sep 17 00:00:00 2001 From: Tibor Simko Date: Fri, 13 May 2011 03:38:31 +0800 Subject: parse_git_status: recognise "Changes not staged for commit" Recognise "Changes not staged for commit" section when parsing git status. This fixes the display of modified but unstaged files in the prompt when using git v1.7 (e.g. Debian Wheezy). --- git-prompt.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git-prompt.sh b/git-prompt.sh index 6d000ba..559e3c3 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -444,6 +444,12 @@ parse_git_status() { s/^# unmerged: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p } + /^# Changes not staged for commit:/,/^# [A-Z]/ { + s/^# Changes not staged for commit:/modified=modified;/p + s/^# modified: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p + s/^# unmerged: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p + } + /^# Untracked files:/,/^[^#]/{ s/^# Untracked files:/untracked=untracked;/p s/^# '"$file_regex"'/ [[ \" ${untracked_files[*]} ${modified_files[*]} ${added_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p -- cgit v1.2.3 From a68fd801346f54ee020d777a7552701209816a33 Mon Sep 17 00:00:00 2001 From: Tibor Simko Date: Fri, 13 May 2011 03:41:19 +0800 Subject: parse_git_status: recognise "Unmerged paths" Recognise "Unmerged paths" section when parsing git status. This fixes the display of files with merge conflicts in the prompt when using git v1.7 (e.g. Debian Wheezy). --- git-prompt.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/git-prompt.sh b/git-prompt.sh index 559e3c3..9cb4f87 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -450,6 +450,11 @@ parse_git_status() { s/^# unmerged: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p } + /^# Unmerged paths:/,/^[^#]/ { + s/^# Unmerged paths:/modified=modified;/p + s/^# both modified:\s*'"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p + } + /^# Untracked files:/,/^[^#]/{ s/^# Untracked files:/untracked=untracked;/p s/^# '"$file_regex"'/ [[ \" ${untracked_files[*]} ${modified_files[*]} ${added_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p -- cgit v1.2.3 From c3d5e2f4498f63130f0e4cce588bc1a60a8eea11 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Thu, 12 May 2011 23:51:38 +0300 Subject: -- --- git-prompt.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git-prompt.sh b/git-prompt.sh index 6d000ba..f05165a 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -631,6 +631,12 @@ enable_set_shell_label() { } # autojump (see http://wiki.github.com/joelthelion/autojump) + +# TODO reverse the line order of a file +#awk ' { line[NR] = $0 } +# END { for (i=NR;i>0;i--) +# print line[i] }' listlogs + j (){ : ${1? usage: j dir-beginning} # go in ring buffer starting from current index. cd to first matching dir -- cgit v1.2.3 From 839ec9913b1c4e93f2814675b4e6ffbda39d3b4c Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Fri, 13 May 2011 00:00:26 +0300 Subject: divergent upstream/local indictor --- git-prompt.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git-prompt.sh b/git-prompt.sh index 460d8e3..a7022d2 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -426,8 +426,10 @@ parse_git_status() { s/^# On branch /branch=/p s/^nothing to commi.*/clean=clean/p s/^# Initial commi.*/init=init/p + s/^# Your branch is ahead of .[/[:alnum:]]\+. by [[:digit:]]\+ commit.*/freshness=${WHITE}↑/p s/^# Your branch is behind .[/[:alnum:]]\+. by [[:digit:]]\+ commit.*/freshness=${YELLOW}↓/p + s/^# Your branch and .[/[:alnum:]]\+. have diverged.*/freshness=${YELLOW}↕/p /^# Changes to be committed:/,/^# [A-Z]/ { s/^# Changes to be committed:/added=added;/p -- cgit v1.2.3 From f1627bab037d2ce5abb7fc86235b785874d79e02 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Fri, 13 May 2011 09:15:41 +0300 Subject: -- docs --- index.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.txt b/index.txt index b9b8cff..4ed975b 100644 --- a/index.txt +++ b/index.txt @@ -176,6 +176,12 @@ time consuming ops in postconfig which is executed only once. - Martin httpx://github.com/jerrywho[] - Alexander Goldstein (emacs-shell, prompt chars) httpx://github.com/alexg0[] - Dmitry (bash completion) +- Sergey Shepelev +- Robert Wahler +- Gustavo Delfino +- Dan Bravender +- Thomas Geffert +- Tibor Simko [bibliography] -- cgit v1.2.3 From 2accfceef451d50e3a16334c51bf732302a5f5cd Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Tue, 17 May 2011 08:29:31 +0300 Subject: -- commit test --- git-prompt.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index a7022d2..3025f95 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -317,7 +317,6 @@ set_shell_label() { # we might already have short host name host=${host%.$default_domain} - #################################################################### WHO_WHERE # [[user@]host[-tty]] -- cgit v1.2.3 From 2c2c88288fd282569c88397aa0b6ffab053fa1b0 Mon Sep 17 00:00:00 2001 From: Clint Howarth Date: Tue, 17 May 2011 09:24:46 +0800 Subject: add short hostname option --- git-prompt.conf | 2 ++ git-prompt.sh | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/git-prompt.conf b/git-prompt.conf index 9f59e8f..81ddec9 100644 --- a/git-prompt.conf +++ b/git-prompt.conf @@ -37,6 +37,8 @@ # Some don't like hostname in uppercase # upcase_hostname=on # =off +# Some don't like long hostname +# short_hostname=off # =on # Do not do VCS parsing for listed directories # useful for directories for which it is difficult to maintain .gitignore so diff --git a/git-prompt.sh b/git-prompt.sh index a7022d2..7ac5c3d 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -62,7 +62,8 @@ max_file_list_length=${max_file_list_length:-100} - upcase_hostname=${upcase_hostname:-on} + short_hostname=${short_hostname:-off} + upcase_hostname=${upcase_hostname:-on} count_only=${count_only:-off} rawhex_len=${rawhex_len:-5} @@ -297,7 +298,9 @@ set_shell_label() { #then host=${HOSTNAME} - #host=`hostname -s` + if [[ $short_hostname = "on" ]]; then + host=`hostname -s` + fi host=${host#$default_host} uphost=`echo ${host} | tr a-z A-Z` if [[ $upcase_hostname = "on" ]]; then -- cgit v1.2.3 From c8e5b8273a0d63b4c2450743e460cf51410445fb Mon Sep 17 00:00:00 2001 From: Clint Howarth Date: Tue, 17 May 2011 09:54:38 +0800 Subject: short hostname cleanup --- git-prompt.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 7ac5c3d..837fc81 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -63,7 +63,7 @@ max_file_list_length=${max_file_list_length:-100} short_hostname=${short_hostname:-off} - upcase_hostname=${upcase_hostname:-on} + upcase_hostname=${upcase_hostname:-on} count_only=${count_only:-off} rawhex_len=${rawhex_len:-5} @@ -298,9 +298,9 @@ set_shell_label() { #then host=${HOSTNAME} - if [[ $short_hostname = "on" ]]; then - host=`hostname -s` - fi + if [[ $short_hostname = "on" ]]; then + host=`hostname -s` + fi host=${host#$default_host} uphost=`echo ${host} | tr a-z A-Z` if [[ $upcase_hostname = "on" ]]; then -- cgit v1.2.3 From 2b136d3264fdd235dc2e5958bf948ba1861a6e53 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Tue, 28 Jun 2011 11:05:18 +0300 Subject: changed hex color again: bright-black (makes gray) too maney terminals to not support DIM color --- git-prompt.conf | 2 +- git-prompt.sh | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/git-prompt.conf b/git-prompt.conf index 81ddec9..36f4e84 100644 --- a/git-prompt.conf +++ b/git-prompt.conf @@ -88,7 +88,7 @@ # untracked_vcs_color=BLUE # Untracked files: # op_vcs_color=MAGENTA # detached_vcs_color=RED -# hex_vcs_color=dim +# hex_vcs_color=BLACK # git version id: bright black - should be displayed as gray # :vim:ft=sh ts=8 sw=8 et: diff --git a/git-prompt.sh b/git-prompt.sh index 28e2de6..f122038 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -54,11 +54,7 @@ op_vcs_color=${op_vcs_color:-MAGENTA} detached_vcs_color=${detached_vcs_color:-RED} - if [[ $OSTYPE == "linux-gnu" ]] ; then # no linux OSs do not support extra colors - hex_vcs_color=${hex_vcs_color:-dim} - else - hex_vcs_color=${hex_vcs_color:-colors_reset} - fi + hex_vcs_color=${hex_vcs_color:-BLACK} # gray max_file_list_length=${max_file_list_length:-100} -- cgit v1.2.3 From 5ab913bea284fc5e4386ddb6fe6e9b5beee51d26 Mon Sep 17 00:00:00 2001 From: Peter Kristensen Date: Thu, 19 May 2011 20:20:50 +0800 Subject: Don't show = when rawhex_len=0 --- git-prompt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index f122038..e329e21 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -414,7 +414,7 @@ parse_git_status() { added_files=() modified_files=() untracked_files=() - freshness="$dim=" + freshness="$dim" unset branch status modified added clean init added mixed untracked op detached # quoting hell @@ -512,7 +512,7 @@ parse_git_status() { if [[ $rawhex_len -gt 0 ]] ; then rawhex=`git rev-parse HEAD 2>/dev/null` rawhex=${rawhex/HEAD/} - rawhex="$hex_vcs_color${rawhex:0:$rawhex_len}" + rawhex="=$hex_vcs_color${rawhex:0:$rawhex_len}" else rawhex="" fi -- cgit v1.2.3 From 849e68964e007f1b2686da47282b7c4ecdde1141 Mon Sep 17 00:00:00 2001 From: Peter Kristensen Date: Thu, 19 May 2011 20:27:09 +0800 Subject: Newer emacsen uses `eterm-color` as $TERM name --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index e329e21..ee025a1 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -275,7 +275,7 @@ set_shell_label() { # we don't need tty name under X11 case $TERM in - xterm* | rxvt* | gnome-terminal | konsole | eterm | wterm | cygwin) unset tty ;; + xterm* | rxvt* | gnome-terminal | konsole | eterm* | wterm | cygwin) unset tty ;; *);; esac -- cgit v1.2.3 From 8c907119a4a7af4a218d06c0f33352a5b65a2970 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Fri, 1 Jul 2011 08:42:14 +0300 Subject: -- --- git-prompt.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-prompt.conf b/git-prompt.conf index 36f4e84..e26793c 100644 --- a/git-prompt.conf +++ b/git-prompt.conf @@ -69,7 +69,7 @@ ##### Per host color -### Per host color. If not set, color will be derived from name of host checksum). +### Per host color. If not set, color will be derived from hostname checksum). ### Variable name is uppercase-short-hostname with appended "_host_color" ### Example per-host-color config: @@ -88,7 +88,7 @@ # untracked_vcs_color=BLUE # Untracked files: # op_vcs_color=MAGENTA # detached_vcs_color=RED -# hex_vcs_color=BLACK # git version id: bright black - should be displayed as gray +# hex_vcs_color=BLACK # git revision id: bright black (makes gray) # :vim:ft=sh ts=8 sw=8 et: -- cgit v1.2.3 From 89501c0a430438c58617adbe7d3282a972d5fb84 Mon Sep 17 00:00:00 2001 From: JuanPablo Date: Sun, 26 Jun 2011 17:56:00 -0400 Subject: begin monitoring of remotes branchs --- git-prompt.sh | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index ee025a1..7743927 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -506,7 +506,31 @@ parse_git_status() { # branch="$(git describe --exact-match HEAD 2>/dev/null)" || \ # branch="$(cut -c1-7 "$git_dir/HEAD")..." fi - + # TODO : make this a module on/off + # hourly checks new commits in remotes + fetchUpdate=3600 + remotes=() + for remote in $(git remote) + do + if [[ ! -e $git_dir/FETCH_HEAD ]]; then + git fetch $remote >& /dev/null & + else + fetchDate=$(date --utc --reference=.git/FETCH_HEAD +%s) + now=$(date --utc +%s) + delta=$(( $now - $fetchDate )) + # if last update to .git/FETCH_HEAD file + if [[ $delta -gt $fetchUpdate ]]; then + git fetch $remote >& /dev/null & + fi + fi + if [[ $(git branch -a | grep $remote) != "" ]]; then + if [[ -f $git_dir/FETCH_HEAD && $(git log --oneline HEAD..$remote/master) != "" ]]; then + remotes+=" "$remote:$(git log --oneline HEAD..$remote/master | wc -l) + fi + else + git fetch $remote >& /dev/null & + fi + done #### GET GIT HEX-REVISION if [[ $rawhex_len -gt 0 ]] ; then @@ -621,7 +645,7 @@ parse_vcs_status() { fi - head_local="$vcs_color(${vcs_info}$vcs_color${file_list}$vcs_color)" + head_local="$vcs_color(${vcs_info}$vcs_color${file_list}$vcs_color$remotes)" ### fringes head_local="${head_local+$vcs_color$head_local }" -- cgit v1.2.3 From d6a18a480d09a45edc114c8235ebd9ffb4491cd4 Mon Sep 17 00:00:00 2001 From: JuanPablo Date: Sun, 26 Jun 2011 18:26:33 -0400 Subject: when remote is origin show o: --- git-prompt.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 7743927..d6306bf 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -524,8 +524,13 @@ parse_git_status() { fi fi if [[ $(git branch -a | grep $remote) != "" ]]; then - if [[ -f $git_dir/FETCH_HEAD && $(git log --oneline HEAD..$remote/master) != "" ]]; then - remotes+=" "$remote:$(git log --oneline HEAD..$remote/master | wc -l) + nRemoteCommit=$(git log --oneline HEAD..$remote/master | wc -l) + if [[ -f $git_dir/FETCH_HEAD && $nRemoteCommit != "0" ]]; then + if [[ $remote == "origin" ]]; then + remotes+=" o:"$nRemoteCommit + else + remotes+=" "$remote:$nRemoteCommit + fi fi else git fetch $remote >& /dev/null & -- cgit v1.2.3 From d6b5c32da05eb47d5bc37b1911937cb81de1478d Mon Sep 17 00:00:00 2001 From: JuanPablo Date: Sun, 26 Jun 2011 19:35:36 -0400 Subject: unset remotes --- git-prompt.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/git-prompt.sh b/git-prompt.sh index d6306bf..a6508c5 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -9,6 +9,7 @@ unset dir_color rc_color user_id_color root_id_color init_vcs_color clean_vcs_color unset modified_vcs_color added_vcs_color addmoded_vcs_color untracked_vcs_color op_vcs_color detached_vcs_color hex_vcs_color unset rawhex_len + unset remotes conf=git-prompt.conf; [[ -r $conf ]] && . $conf conf=/etc/git-prompt.conf; [[ -r $conf ]] && . $conf -- cgit v1.2.3 From d6d99d33c143e52b2bb20cedba6fa19be4d887b8 Mon Sep 17 00:00:00 2001 From: JuanPablo Date: Sun, 26 Jun 2011 20:00:58 -0400 Subject: unset remotes;changed position --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index a6508c5..2832729 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -9,7 +9,6 @@ unset dir_color rc_color user_id_color root_id_color init_vcs_color clean_vcs_color unset modified_vcs_color added_vcs_color addmoded_vcs_color untracked_vcs_color op_vcs_color detached_vcs_color hex_vcs_color unset rawhex_len - unset remotes conf=git-prompt.conf; [[ -r $conf ]] && . $conf conf=/etc/git-prompt.conf; [[ -r $conf ]] && . $conf @@ -583,6 +582,7 @@ parse_vcs_status() { unset vcs vcs_info unset status modified untracked added init detached unset file_list modified_files untracked_files added_files + unset remotes [[ $vcs_ignore_dir_list =~ $PWD ]] && return -- cgit v1.2.3 From 69ee6831250751192a8fa75f7b7fc2773c7acd27 Mon Sep 17 00:00:00 2001 From: JuanPablo Date: Sun, 26 Jun 2011 20:12:10 -0400 Subject: fixed bad route to .git --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index 2832729..781c62e 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -515,7 +515,7 @@ parse_git_status() { if [[ ! -e $git_dir/FETCH_HEAD ]]; then git fetch $remote >& /dev/null & else - fetchDate=$(date --utc --reference=.git/FETCH_HEAD +%s) + fetchDate=$(date --utc --reference=$git_dir/FETCH_HEAD +%s) now=$(date --utc +%s) delta=$(( $now - $fetchDate )) # if last update to .git/FETCH_HEAD file -- cgit v1.2.3 From 72a4c8c7fe64c4b784dc5664e406f0f8cd0126cd Mon Sep 17 00:00:00 2001 From: JuanPablo Date: Sun, 26 Jun 2011 22:10:49 -0400 Subject: remote origin o --- git-prompt.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 781c62e..2b2869b 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -526,11 +526,7 @@ parse_git_status() { if [[ $(git branch -a | grep $remote) != "" ]]; then nRemoteCommit=$(git log --oneline HEAD..$remote/master | wc -l) if [[ -f $git_dir/FETCH_HEAD && $nRemoteCommit != "0" ]]; then - if [[ $remote == "origin" ]]; then - remotes+=" o:"$nRemoteCommit - else - remotes+=" "$remote:$nRemoteCommit - fi + remotes+=" "${remote/origin/o}:$nRemoteCommit fi else git fetch $remote >& /dev/null & -- cgit v1.2.3 From 77262324dd7baada4fe4c5bfb4e25cb4b95aa793 Mon Sep 17 00:00:00 2001 From: JuanPablo Date: Sun, 26 Jun 2011 22:31:28 -0400 Subject: only in the master branch --- git-prompt.sh | 55 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 2b2869b..69f3c4a 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -506,32 +506,35 @@ parse_git_status() { # branch="$(git describe --exact-match HEAD 2>/dev/null)" || \ # branch="$(cut -c1-7 "$git_dir/HEAD")..." fi - # TODO : make this a module on/off - # hourly checks new commits in remotes - fetchUpdate=3600 - remotes=() - for remote in $(git remote) - do - if [[ ! -e $git_dir/FETCH_HEAD ]]; then - git fetch $remote >& /dev/null & - else - fetchDate=$(date --utc --reference=$git_dir/FETCH_HEAD +%s) - now=$(date --utc +%s) - delta=$(( $now - $fetchDate )) - # if last update to .git/FETCH_HEAD file - if [[ $delta -gt $fetchUpdate ]]; then - git fetch $remote >& /dev/null & - fi - fi - if [[ $(git branch -a | grep $remote) != "" ]]; then - nRemoteCommit=$(git log --oneline HEAD..$remote/master | wc -l) - if [[ -f $git_dir/FETCH_HEAD && $nRemoteCommit != "0" ]]; then - remotes+=" "${remote/origin/o}:$nRemoteCommit - fi - else - git fetch $remote >& /dev/null & - fi - done + if [[ $branch == "master" ]]; then + # Only work with master branch + # TODO : make this a module on/off + # hourly checks new commits in remotes + fetchUpdate=3600 + remotes=() + for remote in $(git remote) + do + if [[ ! -e $git_dir/FETCH_HEAD ]]; then + git fetch $remote >& /dev/null & + else + fetchDate=$(date --utc --reference=$git_dir/FETCH_HEAD +%s) + now=$(date --utc +%s) + delta=$(( $now - $fetchDate )) + # if last update to .git/FETCH_HEAD file + if [[ $delta -gt $fetchUpdate ]]; then + git fetch $remote >& /dev/null & + fi + fi + if [[ $(git branch -a | grep $remote) != "" ]]; then + nRemoteCommit=$(git log --oneline HEAD..$remote/master | wc -l) + if [[ -f $git_dir/FETCH_HEAD && $nRemoteCommit != "0" ]]; then + remotes+=" "${remote/origin/o}:$nRemoteCommit + fi + else + git fetch $remote >& /dev/null & + fi + done + fi #### GET GIT HEX-REVISION if [[ $rawhex_len -gt 0 ]] ; then -- cgit v1.2.3 From d747bd8d3708ba28165fc3ef0d8ee87485691895 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Fri, 1 Jul 2011 10:42:07 +0300 Subject: reverted accidantal merge of remote-watch --- git-prompt.sh | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 69f3c4a..ee025a1 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -506,35 +506,7 @@ parse_git_status() { # branch="$(git describe --exact-match HEAD 2>/dev/null)" || \ # branch="$(cut -c1-7 "$git_dir/HEAD")..." fi - if [[ $branch == "master" ]]; then - # Only work with master branch - # TODO : make this a module on/off - # hourly checks new commits in remotes - fetchUpdate=3600 - remotes=() - for remote in $(git remote) - do - if [[ ! -e $git_dir/FETCH_HEAD ]]; then - git fetch $remote >& /dev/null & - else - fetchDate=$(date --utc --reference=$git_dir/FETCH_HEAD +%s) - now=$(date --utc +%s) - delta=$(( $now - $fetchDate )) - # if last update to .git/FETCH_HEAD file - if [[ $delta -gt $fetchUpdate ]]; then - git fetch $remote >& /dev/null & - fi - fi - if [[ $(git branch -a | grep $remote) != "" ]]; then - nRemoteCommit=$(git log --oneline HEAD..$remote/master | wc -l) - if [[ -f $git_dir/FETCH_HEAD && $nRemoteCommit != "0" ]]; then - remotes+=" "${remote/origin/o}:$nRemoteCommit - fi - else - git fetch $remote >& /dev/null & - fi - done - fi + #### GET GIT HEX-REVISION if [[ $rawhex_len -gt 0 ]] ; then @@ -581,7 +553,6 @@ parse_vcs_status() { unset vcs vcs_info unset status modified untracked added init detached unset file_list modified_files untracked_files added_files - unset remotes [[ $vcs_ignore_dir_list =~ $PWD ]] && return @@ -650,7 +621,7 @@ parse_vcs_status() { fi - head_local="$vcs_color(${vcs_info}$vcs_color${file_list}$vcs_color$remotes)" + head_local="$vcs_color(${vcs_info}$vcs_color${file_list}$vcs_color)" ### fringes head_local="${head_local+$vcs_color$head_local }" -- cgit v1.2.3 From ecd0a5e3a7733be761f37867a22f0123b1595317 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sat, 27 Aug 2011 22:44:38 +0300 Subject: fixes: Issue #15 -- truncates shall label to 200 chars --- git-prompt.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index ee025a1..e851fd9 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -222,7 +222,10 @@ cwd_truncate() { set_shell_label() { - xterm_label() { echo -n "]2;${@}" ; } # FIXME: replace hardcodes with terminfo codes + xterm_label() { + local args="$*" + echo -n "]2;${args:0:200}" ; # FIXME: replace hardcodes with terminfo codes + } screen_label() { # FIXME: run this only if screen is in xterm (how to test for this?) -- cgit v1.2.3 From 24a1f3b02de1d5b22c4ab7c1c1408211c32ce546 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sat, 27 Aug 2011 22:48:00 +0300 Subject: fix for enable/disable_set_shell_label I do not understand what it does. From Issue 15: Also, in exploring this problem I noticed that disable_set_shell_label doesn't work correctly for me. I fixed this problem by declaring disable_set_shell_label and enable_set_shell_label to have the "trace" attribute in bash. This is done by adding: declare -ft disable_set_shell_label and declare -ft enable_set_shell_label after the definitions of those functions in git-prompt.sh. --- git-prompt.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/git-prompt.sh b/git-prompt.sh index e851fd9..41aa587 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -644,6 +644,9 @@ enable_set_shell_label() { set_shell_label $BASH_COMMAND' DEBUG >& /dev/null } +declare -ft disable_set_shell_label +declare -ft enable_set_shell_label + # autojump (see http://wiki.github.com/joelthelion/autojump) # TODO reverse the line order of a file -- cgit v1.2.3 From 6abb8987a92b0abfc617320d047c1a9b22ef16f7 Mon Sep 17 00:00:00 2001 From: JuanPablo Date: Sat, 10 Sep 2011 00:33:57 -0300 Subject: hostname in cygwin --- git-prompt.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index 41aa587..4178de5 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -298,7 +298,11 @@ set_shell_label() { host=${HOSTNAME} if [[ $short_hostname = "on" ]]; then - host=`hostname -s` + if [[ "$(uname)" =~ "CYGWIN" ]]; then + host=`hostname` + else + host=`hostname -s` + fi fi host=${host#$default_host} uphost=`echo ${host} | tr a-z A-Z` -- cgit v1.2.3 From f1992e9d328407f6abd7b8a9a1569979412ff00a Mon Sep 17 00:00:00 2001 From: Jean Parpaillon Date: Fri, 23 Sep 2011 17:49:08 +0200 Subject: * Print Python virtualenv: (in green, by default) --- git-prompt.conf | 2 ++ git-prompt.sh | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/git-prompt.conf b/git-prompt.conf index e26793c..dee3c0c 100644 --- a/git-prompt.conf +++ b/git-prompt.conf @@ -19,6 +19,7 @@ # svn_module=off # hg_module=on # vim_module=on +# virtualenv_module=on ########################################################### DEFAULT OBJECTS @@ -53,6 +54,7 @@ # if [[ -n "$cols" && $cols -ge 8 ]]; then # if terminal supports colors # dir_color=CYAN # rc_color=red + # virtualenv_color=green # user_id_color=blue # root_id_color=magenta # else # B/W terminal diff --git a/git-prompt.sh b/git-prompt.sh index 41aa587..cdc3d05 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -23,6 +23,7 @@ svn_module=${svn_module:-off} hg_module=${hg_module:-on} vim_module=${vim_module:-on} + virtualenv_module=${virtualenv_module:-on} error_bell=${error_bell:-off} cwd_cmd=${cwd_cmd:-\\w} @@ -32,6 +33,7 @@ if [[ -n "$cols" && $cols -ge 8 ]]; then # if terminal supports colors dir_color=${dir_color:-CYAN} rc_color=${rc_color:-red} + virtualenv_color=${virtualenv_color:-green} user_id_color=${user_id_color:-blue} root_id_color=${root_id_color:-magenta} else # only B/W @@ -284,6 +286,7 @@ set_shell_label() { dir_color=${!dir_color} rc_color=${!rc_color} + virtualenv_color=${!virtualenv_color} user_id_color=${!user_id_color} root_id_color=${!root_id_color} @@ -632,6 +635,17 @@ parse_vcs_status() { #tail_local="${tail_local+$vcs_color $tail_local}${dir_color}" } +parse_virtualenv_status() { + unset virtualenv + + [[ $virtualenv_module = "on" ]] || return 1 + + if [[ -n "$VIRTUAL_ENV" ]] ; then + virtualenv=`basename $VIRTUAL_ENV` + rc="$rc $virtualenv_color<$virtualenv> " + fi + } + disable_set_shell_label() { trap - DEBUG >& /dev/null } @@ -682,6 +696,7 @@ prompt_command_function() { cwd=${PWD/$HOME/\~} # substitute "~" set_shell_label "${cwd##[/~]*/}/" # default label - path last dir + parse_virtualenv_status parse_vcs_status # autojump -- cgit v1.2.3 From 88c2d0f0df007a83d1faa4313b527bb0b2cf5a36 Mon Sep 17 00:00:00 2001 From: Amir Yalon Date: Thu, 29 Dec 2011 11:50:27 +0200 Subject: Fix Git freshness check with special chars --- git-prompt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 41aa587..14be89d 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -428,9 +428,9 @@ parse_git_status() { s/^nothing to commi.*/clean=clean/p s/^# Initial commi.*/init=init/p - s/^# Your branch is ahead of .[/[:alnum:]]\+. by [[:digit:]]\+ commit.*/freshness=${WHITE}↑/p - s/^# Your branch is behind .[/[:alnum:]]\+. by [[:digit:]]\+ commit.*/freshness=${YELLOW}↓/p - s/^# Your branch and .[/[:alnum:]]\+. have diverged.*/freshness=${YELLOW}↕/p + s/^# Your branch is ahead of \(.\).\+\1 by [[:digit:]]\+ commit.*/freshness=${WHITE}↑/p + s/^# Your branch is behind \(.\).\+\1 by [[:digit:]]\+ commit.*/freshness=${YELLOW}↓/p + s/^# Your branch and \(.\).\+\1 have diverged.*/freshness=${YELLOW}↕/p /^# Changes to be committed:/,/^# [A-Z]/ { s/^# Changes to be committed:/added=added;/p -- cgit v1.2.3 From 48d325ef728a89e350acd7310d0451e32401f6ac Mon Sep 17 00:00:00 2001 From: Ronan Amicel Date: Wed, 4 Jan 2012 12:17:04 +0100 Subject: Fixed Mercurial repository detection --- git-prompt.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 41aa587..a63830b 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -375,8 +375,7 @@ parse_svn_status() { parse_hg_status() { # ☿ - - [[ -d ./.hg/ ]] || return 1 + hg_root=`hg root 2>/dev/null` || return 1 vcs=hg -- cgit v1.2.3 From 3a9d158cc9f413591263738e08f1f5a10c627a48 Mon Sep 17 00:00:00 2001 From: Ronan Amicel Date: Wed, 4 Jan 2012 12:20:30 +0100 Subject: Show current bookmark in Mercurial --- git-prompt.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/git-prompt.sh b/git-prompt.sh index a63830b..d71d9b4 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -393,8 +393,13 @@ parse_hg_status() { branch=`hg branch 2> /dev/null` + [[ -f $hg_root/.hg/bookmarks.current ]] && bookmark=`cat "$hg_root/.hg/bookmarks.current"` + [[ -z $modified ]] && [[ -z $untracked ]] && [[ -z $added ]] && clean=clean vcs_info=${branch/default/D} + if [[ "$bookmark" ]] ; then + vcs_info+=/$bookmark + fi } -- cgit v1.2.3 From 8546ca362c7a42aff5ff963c26ce22d0bd2f73ea Mon Sep 17 00:00:00 2001 From: Tom Hoover Date: Fri, 2 Mar 2012 22:03:23 -0600 Subject: added quotation marks around $git_dir/HEAD to prevent "detached" message from appearing in the prompt when $git_dir includes space character(s) For example, assume a git repository located at /Volumes/Macintosh HD/Users/tom/src/myrepository: - this bug does not appear when the working directory is the root of the git repository ( e.g. /Volumes/Macintosh HD/Users/tom/src/myrepository ), as $git_dir returns ".git" - the bug only appears if the directory is changed to one other than the root of the repository ( e.g. /Volumes/Macintosh HD/Users/tom/src/myrepository/DIRECTORY ), as $git_dir will then return the full path "/Volumes/Macintosh HD/Users/tom/src/myrepository/.git". The space between "Macintosh" and "HD" will cause 'grep "^ref:" $git_dir/HEAD' to fail. Adding quotation marks around $git_dir/HEAD allows the grep test to succeed, even when the path includes space character(s). --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index 41aa587..02e6c5a 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -465,7 +465,7 @@ parse_git_status() { ' )" - if ! grep -q "^ref:" $git_dir/HEAD 2>/dev/null; then + if ! grep -q "^ref:" "$git_dir/HEAD" 2>/dev/null; then detached=detached fi -- cgit v1.2.3 From e50e3126c75bc2bfff0c7b31aecdae2ebd2b0fd9 Mon Sep 17 00:00:00 2001 From: Olivier Refalo Date: Wed, 25 Apr 2012 11:12:13 -0300 Subject: host_color: modulo calculation is wrong --- git-prompt.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 41aa587..8e6b08c 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -1,4 +1,3 @@ - # don't set prompt if this is not interactive shell [[ $- != *i* ]] && return @@ -309,7 +308,7 @@ set_shell_label() { host_color=${uphost}_host_color host_color=${!host_color} if [[ -z $host_color && -x /usr/bin/cksum ]] ; then - cksum_color_no=`echo $uphost | cksum | awk '{print $1%7}'` + cksum_color_no=`echo $uphost | cksum | awk '{print $1%6}'` color_index=(green yellow blue magenta cyan white) # FIXME: bw, color-256 host_color=${color_index[cksum_color_no]} fi -- cgit v1.2.3 From f2fd61de186cd32c448cb7ad55bad371453cb26d Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Fri, 6 Jul 2012 16:59:07 +0300 Subject: -- --- index.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.txt b/index.txt index 4ed975b..eaaa6cd 100644 --- a/index.txt +++ b/index.txt @@ -2,6 +2,9 @@ = GIT Prompt +* Repo: httpx://github.com/lvv/scc[GitHub], httpx://bitbucket.org/lvv/scc[BitBucket] + +* License: httpx://www.gnu.org/licenses/gpl-3.0.html[GPL3] + :v-p: http://volnitsky.com/project :compact-option: compact @@ -158,6 +161,9 @@ dependencies are standard unix utils. == Todo +* httpx://jonisalonen.com/2012/your-bash-prompt-needs-this/[] +* httpx://tldp.org/HOWTO/Bash-Prompt-HOWTO/x810.html[Beep after long running command] +* httpx://briancarper.net/blog/248/[Sync bash history] * VIM module needs to be moved out of GIT module include::../volnitsky.com/project/howto-submit-patch.txt[] -- cgit v1.2.3 From 38d69296430ae47f584d92b77c8c5f1e11273523 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Fri, 6 Jul 2012 19:09:13 +0300 Subject: get file status from "git status --porcelain" --- git-prompt.sh | 43 ++++++++++++------------------------------- index.txt | 10 +++++++++- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 41aa587..fae87a8 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -420,7 +420,7 @@ parse_git_status() { freshness="$dim" unset branch status modified added clean init added mixed untracked op detached - # quoting hell + # info not in porcelain status eval " $( git status 2>/dev/null | sed -n ' @@ -431,40 +431,21 @@ parse_git_status() { s/^# Your branch is ahead of .[/[:alnum:]]\+. by [[:digit:]]\+ commit.*/freshness=${WHITE}↑/p s/^# Your branch is behind .[/[:alnum:]]\+. by [[:digit:]]\+ commit.*/freshness=${YELLOW}↓/p s/^# Your branch and .[/[:alnum:]]\+. have diverged.*/freshness=${YELLOW}↕/p + ' + )" - /^# Changes to be committed:/,/^# [A-Z]/ { - s/^# Changes to be committed:/added=added;/p - - s/^# modified: '"$file_regex"'/ [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p - s/^# new file: '"$file_regex"'/ [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p - s/^# renamed:[^>]*> '"$file_regex"'/ [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p - s/^# copied:[^>]*> '"$file_regex"'/ [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p - } - - /^# Changed but not updated:/,/^# [A-Z]/ { - s/^# Changed but not updated:/modified=modified;/p - s/^# modified: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p - s/^# unmerged: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p - } - - /^# Changes not staged for commit:/,/^# [A-Z]/ { - s/^# Changes not staged for commit:/modified=modified;/p - s/^# modified: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p - s/^# unmerged: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p - } - - /^# Unmerged paths:/,/^[^#]/ { - s/^# Unmerged paths:/modified=modified;/p - s/^# both modified:\s*'"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p - } - - /^# Untracked files:/,/^[^#]/{ - s/^# Untracked files:/untracked=untracked;/p - s/^# '"$file_regex"'/ [[ \" ${untracked_files[*]} ${modified_files[*]} ${added_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p - } + # porcelain file list + # TODO: sed-less -- http://tldp.org/LDP/abs/html/arrays.html -- Example 27-5 + eval " $( + git status --porcelain 2>/dev/null | + sed -n ' + s/^[MARC]. \(.*\)/ added=added; [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p + s/^.[MAU] \(.*\)/ modified=modified; [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p + s/^?? \(.*\)/ untracked=untracked; [[ \" ${untracked_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p ' )" + if ! grep -q "^ref:" $git_dir/HEAD 2>/dev/null; then detached=detached fi diff --git a/index.txt b/index.txt index eaaa6cd..b75ae0a 100644 --- a/index.txt +++ b/index.txt @@ -108,7 +108,15 @@ Some distros also have `/etc/bashrc` or `/etc/bash/bashrc` with distro default prompt. -== Config +////////////////////////////// +== Git config + +git config [--global] core.quotepath off +git config [--global] --unset svn.pathnameencoding +git config [--global] --unset i18n.logoutputencoding +/////////////////////////////////// + +== Git-print config [[config]] Is optional. If config file is not found then git-prompt uses defaults. -- cgit v1.2.3 From d9c8684498d88d75c0cbc64bcde635eda4211c1c Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Fri, 6 Jul 2012 19:18:38 +0300 Subject: -- docs --- index.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/index.txt b/index.txt index b75ae0a..a48ab80 100644 --- a/index.txt +++ b/index.txt @@ -108,15 +108,19 @@ Some distros also have `/etc/bashrc` or `/etc/bash/bashrc` with distro default prompt. -////////////////////////////// -== Git config +== GIT config + +GIT-PROMPT requires following GIT's option to be set: + +------------------------- git config [--global] core.quotepath off git config [--global] --unset svn.pathnameencoding git config [--global] --unset i18n.logoutputencoding -/////////////////////////////////// +----------------------------- + -== Git-print config +== GIT-PROMPT config [[config]] Is optional. If config file is not found then git-prompt uses defaults. -- cgit v1.2.3 From ca9ddab21023b34389affeaf392fafffca17e0c2 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Fri, 6 Jul 2012 20:21:59 +0300 Subject: removed sCRn marker --- git-prompt.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 8bdbb3f..b84fda2 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -149,7 +149,6 @@ fi #################################################################### MARKERS - screen_marker="sCRn" if [[ $LC_CTYPE =~ "UTF" && $TERM != "linux" ]]; then elipses_marker="…" else @@ -228,7 +227,7 @@ set_shell_label() { screen_label() { # FIXME: run this only if screen is in xterm (how to test for this?) - xterm_label "$screen_marker $plain_who_where $@" + xterm_label "$plain_who_where $@" # FIXME $STY not inherited though "su -" [ "$STY" ] && screen -S $STY -X title "$*" -- cgit v1.2.3 From a599ae86440035ca15052b67f44238c81bf3001e Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Fri, 6 Jul 2012 20:54:33 +0300 Subject: fixed: filesnames with spaces, quotes and other special chars --- git-prompt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 7d09948..c819227 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -444,9 +444,9 @@ parse_git_status() { eval " $( git status --porcelain 2>/dev/null | sed -n ' - s/^[MARC]. \(.*\)/ added=added; [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p - s/^.[MAU] \(.*\)/ modified=modified; [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p - s/^?? \(.*\)/ untracked=untracked; [[ \" ${untracked_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p + s/^[MARC]. \(.*\)/ added=added; [[ \" ${added_files[*]} \" =~ \1 ]] || added_files[${#added_files[@]}]=\1/p + s/^.[MAU] \(.*\)/ modified=modified; [[ \" ${modified_files[*]} \" =~ \1 ]] || modified_files[${#modified_files[@]}]=\1/p + s/^?? \(.*\)/ untracked=untracked; [[ \" ${untracked_files[*]} \" =~ \1 ]] || untracked_files[${#untracked_files[@]}]=\1/p ' )" -- cgit v1.2.3 From c439a12b77584317fa354ff9df0f151716f49974 Mon Sep 17 00:00:00 2001 From: dfalk Date: Wed, 29 Feb 2012 23:13:19 -0500 Subject: Fixing host color bug by replacing invalid bash variable characters with underscores --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index c908c62..cac1897 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -306,7 +306,7 @@ set_shell_label() { fi fi host=${host#$default_host} - uphost=`echo ${host} | tr a-z A-Z` + uphost=`echo ${host} | tr a-z-. A-Z_` if [[ $upcase_hostname = "on" ]]; then host=${uphost} fi -- cgit v1.2.3 From 1907461b055934d828f164c41a633da71e32feee Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Fri, 6 Jul 2012 21:37:59 +0300 Subject: enable setting the xterm_label also in TERM=gnome-256color --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index cac1897..1879a77 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -243,7 +243,7 @@ set_shell_label() { screen_label "$*" ;; - xterm* | rxvt* | gnome-terminal | konsole | eterm | wterm ) + xterm* | rxvt* | gnome-* | konsole | eterm | wterm ) # is there a capability which we can to test # for "set term title-bar" and its escapes? xterm_label "$plain_who_where $@" -- cgit v1.2.3 From daf9258a85be1689b200bffc8d474a9d3d392c42 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Fri, 6 Jul 2012 21:40:50 +0300 Subject: -- trailing white space --- git-prompt.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 1879a77..271326c 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -201,7 +201,7 @@ cwd_truncate() { # trunc middle if over limit if [[ ${#path_middle} -gt $(( $cwd_middle_max + ${#elipses_marker} + 5 )) ]]; then - + # truncate middle_tail=${path_middle:${#path_middle}-${cwd_middle_max}} @@ -225,7 +225,7 @@ set_shell_label() { xterm_label() { local args="$*" echo -n "]2;${args:0:200}" ; # FIXME: replace hardcodes with terminfo codes - } + } screen_label() { # FIXME: run this only if screen is in xterm (how to test for this?) @@ -301,7 +301,7 @@ set_shell_label() { if [[ $short_hostname = "on" ]]; then if [[ "$(uname)" =~ "CYGWIN" ]]; then host=`hostname` - else + else host=`hostname -s` fi fi @@ -517,7 +517,7 @@ parse_git_status() { ### compose vcs_info - if [[ $init ]]; then + if [[ $init ]]; then vcs_info=${white}init else @@ -578,7 +578,7 @@ parse_vcs_status() { if [[ $vim_glob ]]; then set $vim_glob #vim_file=${vim_glob#.} - if [[ $# > 1 ]] ; then + if [[ $# > 1 ]] ; then vim_files="*" else vim_file=${1#.} -- cgit v1.2.3 From 40464f39c5c94e20fc3f534663a6b17acf2e227a Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sat, 7 Jul 2012 08:51:28 +0300 Subject: better UTF detection --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-prompt.sh b/git-prompt.sh index 271326c..a206eaa 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -151,7 +151,7 @@ fi #################################################################### MARKERS - if [[ $LC_CTYPE =~ "UTF" && $TERM != "linux" ]]; then + if [[ "$LC_CTYPE $LC_ALL" =~ "UTF" && $TERM != "linux" ]]; then elipses_marker="…" else elipses_marker="..." -- cgit v1.2.3 From be207fd5f3665c8299158853d7b5913c046e52cf Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sat, 7 Jul 2012 09:17:50 +0300 Subject: substitute branch name "master" for "M" only if it starts with "master" --- git-prompt.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index a206eaa..2853909 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -422,7 +422,6 @@ parse_git_status() { vcs=git ########################################################## GIT STATUS - file_regex='\([^/ ]*\/\{0,1\}\).*' added_files=() modified_files=() untracked_files=() @@ -509,7 +508,7 @@ parse_git_status() { fi #### branch - branch=${branch/master/M} + branch=${branch/#master/M} # another method of above: # branch=$(git symbolic-ref -q HEAD || { echo -n "detached:" ; git name-rev --name-only HEAD 2>/dev/null; } ) -- cgit v1.2.3 From 233c72eaf7e4b77f62fa857f6f2011dbb60a4040 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sat, 7 Jul 2012 09:22:24 +0300 Subject: do not display "=" before rawhex if there is freshness indicator --- git-prompt.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 2853909..cb3c296 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -425,7 +425,8 @@ parse_git_status() { added_files=() modified_files=() untracked_files=() - freshness="$dim" + [[ $rawhex_len -gt 0 ]] && freshness="$dim=" + unset branch status modified added clean init added mixed untracked op detached # info not in porcelain status @@ -502,7 +503,7 @@ parse_git_status() { if [[ $rawhex_len -gt 0 ]] ; then rawhex=`git rev-parse HEAD 2>/dev/null` rawhex=${rawhex/HEAD/} - rawhex="=$hex_vcs_color${rawhex:0:$rawhex_len}" + rawhex="$hex_vcs_color${rawhex:0:$rawhex_len}" else rawhex="" fi -- cgit v1.2.3 From 7bcdb1a7366ef18b3fee5c7a6b26bfc2ff4e66db Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sat, 7 Jul 2012 23:42:43 +0300 Subject: workaround for git status --porcelain quoting bug --- git-prompt.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index cb3c296..7acda17 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -443,13 +443,23 @@ parse_git_status() { )" # porcelain file list - # TODO: sed-less -- http://tldp.org/LDP/abs/html/arrays.html -- Example 27-5 + # TODO: sed-less -- http://tldp.org/LDP/abs/html/arrays.html -- Example 27-5 + + # git bug: (was reported to git@vger.kernel.org ) + # echo 1 > "with space" + # git status --porcelain + # ?? with space <------------ NO QOUTES + # git add with\ space + # git status --porcelain + # A "with space" <------------- WITH QOUTES + eval " $( git status --porcelain 2>/dev/null | sed -n ' s/^[MARC]. \(.*\)/ added=added; [[ \" ${added_files[*]} \" =~ \1 ]] || added_files[${#added_files[@]}]=\1/p s/^.[MAU] \(.*\)/ modified=modified; [[ \" ${modified_files[*]} \" =~ \1 ]] || modified_files[${#modified_files[@]}]=\1/p - s/^?? \(.*\)/ untracked=untracked; [[ \" ${untracked_files[*]} \" =~ \1 ]] || untracked_files[${#untracked_files[@]}]=\1/p + s/^?? \([a-zA-Z_.=:]*\)$/ untracked=untracked; [[ \" ${untracked_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p + s/^?? \(.*\)$/ untracked=untracked; [[ \" ${untracked_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p ' )" -- cgit v1.2.3 From 00a94f5b3dc1cdc7fecf958d33533ebb6cd181e2 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sun, 8 Jul 2012 18:55:37 +0300 Subject: fixed: filenames with special chars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gsp ?? TTTTTT BBBBBBBBB ?? a b/ ?? "a\"b/" ?? a$b/ ?? a&b/ ?? a'b/ ?? ab/ ?? "a\303\251/" ?? brackets/ ?? ext/ ?? t ?? tttt aaaa init TTTTTT BBBBBBBBB a b/ a"b/ a/ a&b/ a'b/ ab/ aé/ brackets/ ext/ t tttt aaaa /…test/fixtures/_filedir> gsp A "TTTTTT BBBBBBBBB" A "a b/i" A "a\"b/d" A a$b/h A a&b/f A a'b/c A ab/e A "a\303\251/g" A brackets/[x] A brackets/x A ext/ee.e1 A ext/ff.e2 A ext/foo/.gitignore A ext/gg.e1 A ext/hh.e2 A ext/ii.E1 A t A "tttt aaaa" init TTTTTT BBBBBBBBB a b/ a"b/ amaster/ a&b/ a'b/ ab/ aé/ brackets/ ext/ t tttt aaaa /…test/fixtures/_filedir> --- git-prompt.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index 7acda17..f99a1d0 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -455,12 +455,14 @@ parse_git_status() { eval " $( git status --porcelain 2>/dev/null | - sed -n ' - s/^[MARC]. \(.*\)/ added=added; [[ \" ${added_files[*]} \" =~ \1 ]] || added_files[${#added_files[@]}]=\1/p - s/^.[MAU] \(.*\)/ modified=modified; [[ \" ${modified_files[*]} \" =~ \1 ]] || modified_files[${#modified_files[@]}]=\1/p - s/^?? \([a-zA-Z_.=:]*\)$/ untracked=untracked; [[ \" ${untracked_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p - s/^?? \(.*\)$/ untracked=untracked; [[ \" ${untracked_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p - ' + sed -n ' + s,^[MARC]. \([^\"][^/]*/\?\).*, added=added; [[ \" ${added_files[@]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\",p + s,^[MARC]. \"\([^/]\+/\?\).*\"$, added=added; [[ \" ${added_files[@]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\",p + s,^.[MAU] \([^\"][^/]*/\?\).*, modified=modified; [[ \" ${modified_files[@]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\",p + s,^.[MAU] \"\([^/]\+/\?\).*\"$, modified=modified; [[ \" ${modified_files[@]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\",p + s,^?? \([^\"][^/]*/\?\).*, untracked=untracked; [[ \" ${untracked_files[@]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\",p + s,^?? \"\([^/]\+/\?\).*\"$, untracked=untracked; [[ \" ${untracked_files[@]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\",p + ' # |tee /dev/tty )" if ! grep -q "^ref:" "$git_dir/HEAD" 2>/dev/null; then -- cgit v1.2.3