From 2973749097cd6b6c60acd96a2440d131aa4a4495 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sun, 15 Jun 2008 08:36:08 +0300 Subject: also added raw head disp --- prompt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'prompt') diff --git a/prompt b/prompt index d10ac3b..7b4a5dd 100755 --- a/prompt +++ b/prompt @@ -276,8 +276,6 @@ PROMPT_COMMAND=' " ` - - ### OP unset op @@ -325,16 +323,17 @@ PROMPT_COMMAND=' eval git_color="\${git_$status}" ### head - set `git-name-rev HEAD` - head="$2" + head=`git-name-rev --name-only HEAD 2>/dev/null` + head_rev=`git-rev-parse HEAD 2>/dev/null` + head_rev=${head_rev:0:6} ### compose local label [[ $clean == "clean" ]] || sep=":" - tail_local="$head${op+/$op}$sep$git_added$git_added_files$git_modified$git_modified_files$git_untracked$git_untracked_files$git_color" + tail_local="($head $white$head_rev${op+ / $op}$git_color)$sep$git_added$git_added_files$git_modified$git_modified_files$git_untracked$git_untracked_files$git_color" - ### fringes + ### fringes (added depended on location) head_local="${head_local+$git_color $head_local\n}" - tail_local="${tail_local+$git_color ($tail_local)}${dir_color}" + tail_local="${tail_local+$git_color $tail_local}${dir_color}" unset branch status git_color clean added modified untracked sep unset git_modified_files @@ -346,7 +345,7 @@ PROMPT_COMMAND=' # PS1="$label$rc'$color_who_where$dir_color'${head:10*(${#PWD}max)*(${#PWD}-max):max}> '$colors_reset'" - PS1="$head_local$colors_reset$label$rc'$color_who_where$dir_color'\w$tail_local'$dir_color' > '$colors_reset'" + PS1="$head_local$colors_reset$label$rc'$color_who_where$dir_color'\w$tail_local'$dir_color'> '$colors_reset'" unset head_local tail_local ' -- cgit v1.2.3 From 6adfbbd669b812fac340f84d7e12e6c49c1c790c Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sun, 15 Jun 2008 09:56:28 +0300 Subject: file list composition refactored --- prompt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'prompt') diff --git a/prompt b/prompt index 7b4a5dd..92d7266 100755 --- a/prompt +++ b/prompt @@ -321,6 +321,7 @@ PROMPT_COMMAND=' # at least one should be set : ${status?prompt internal error: git status} eval git_color="\${git_$status}" + git_color=${git_color:-$WHITE} ### head head=`git-name-rev --name-only HEAD 2>/dev/null` @@ -328,14 +329,20 @@ PROMPT_COMMAND=' head_rev=${head_rev:0:6} ### compose local label - [[ $clean == "clean" ]] || sep=":" - tail_local="($head $white$head_rev${op+ / $op}$git_color)$sep$git_added$git_added_files$git_modified$git_modified_files$git_untracked$git_untracked_files$git_color" + + unset file_list + file_list+="${git_added_files+$git_added$git_added_files }" + file_list+="${git_modified_files+$git_modified$git_modified_files }" + file_list+="${git_untracked_files+$git_untracked$git_untracked_files }" + [[ $file_list ]] && file_list=":${file_list}" # ${+ does not works (?) + + tail_local="($head $white$head_rev${op+ / $op}$git_color)${file_list}" ### fringes (added depended on location) head_local="${head_local+$git_color $head_local\n}" tail_local="${tail_local+$git_color $tail_local}${dir_color}" - unset branch status git_color clean added modified untracked sep + unset branch status git_color clean added modified untracked sep file_list unset git_modified_files unset git_untracked_files unset git_added_files -- cgit v1.2.3 From c1fed1895a54fe85d8d1027772378c80da380513 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sun, 15 Jun 2008 11:09:34 +0300 Subject: commented out code for remote session detection --- prompt | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'prompt') diff --git a/prompt b/prompt index 92d7266..092e18e 100755 --- a/prompt +++ b/prompt @@ -170,20 +170,21 @@ export -f set_shell_title ########################################################### HOST ### we don't display home host/domain $SSH_* set by SSHD or keychain - # is sshd our perent? - if [[ "$SSH_AUTH_SOCK" ]] || - for ((pid=$$; $pid != 1 ; pid=`ppid_of $pid`)); do ps h -o command -p $pid; done | grep -q sshd - then + # I give up. How to find out if session is local or remote? Working with "su -", ssh-agent, and so on ? + ## is sshd our perent? + # if { for ((pid=$$; $pid != 1 ; pid=`ps h -o pid --ppid $pid`)); do ps h -o command -p $pid; done | grep -q sshd } + #then host=${HOSTNAME} #host=`hostname --short` - #host=`echo ${host%$default_host} | tr a-z A-Z` - host=`echo ${host} | tr a-z A-Z` - eval host_color=\$${host}_host_color - else - host="" - fi - - eval host_color="\$$host_color" + host=`echo ${host%$default_host} | tr a-z A-Z` + #host=`echo ${host} | tr a-z A-Z` + host_color=${host}_host_color + host_color=${!host_color} + #else + # host="" + #fi + + host_color=${!host_color} # we already should have short host name, but just in case host=${host%.localdoman} -- cgit v1.2.3 From 64664a721a0094a3cde406862ea0a53988171b45 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sun, 15 Jun 2008 11:21:46 +0300 Subject: eval-s are replaced with modern ${!....}, (some $ bugs probably are fixed) --- prompt | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'prompt') diff --git a/prompt b/prompt index 092e18e..14dd047 100755 --- a/prompt +++ b/prompt @@ -78,12 +78,12 @@ # replace symbolic colors names to raw treminfo strings - eval git_modified="\$$git_modified" - eval git_untracked="\$$git_untracked" - eval git_clean="\$$git_clean" - eval git_added="\$$git_added" - eval git_op="\$$git_op" - eval git_mixed="\$$git_mixed" + git_modified=${!git_modified} + git_untracked=${!git_untracked} + git_clean=${!git_clean} + git_added=${!git_added} + git_op=${!git_op} + git_mixed=${!git_mixed} ##################################################################### LC_ALL=C @@ -162,9 +162,9 @@ export -f set_shell_title esac - eval dir_color="\$$dir_color" - eval rc_color="\$$rc_color" - eval root_id_color="\$$root_id_color" + dir_color=${!dir_color} + rc_color=${!rc_color} + root_id_color=${!root_id_color} ########################################################### HOST @@ -248,12 +248,6 @@ PROMPT_COMMAND=' git_dir=`git-rev-parse --git-dir 2> /dev/null` if [[ $git_dir ]]; then - ### status - # clean(blue) nothing to commit (working directory clean) - # modified(red) # Changed but not updated: - # added(green) # Changes to be committed: - # untracked(yellow) # Untracked files: - eval `git status | sed -n " s/^# On branch /branch=/p @@ -321,7 +315,7 @@ PROMPT_COMMAND=' status=${status:-$untracked} # at least one should be set : ${status?prompt internal error: git status} - eval git_color="\${git_$status}" + eval git_color=\${git_$status} git_color=${git_color:-$WHITE} ### head -- cgit v1.2.3 From c4020579dcfbcabbca38b2f03f42aa3440634fbe Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sun, 15 Jun 2008 11:29:10 +0300 Subject: display of "master" replaced with "m" --- prompt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'prompt') diff --git a/prompt b/prompt index 14dd047..38694a6 100755 --- a/prompt +++ b/prompt @@ -331,7 +331,7 @@ PROMPT_COMMAND=' file_list+="${git_untracked_files+$git_untracked$git_untracked_files }" [[ $file_list ]] && file_list=":${file_list}" # ${+ does not works (?) - tail_local="($head $white$head_rev${op+ / $op}$git_color)${file_list}" + tail_local="(${head/master/m} $white$head_rev${op+ / $op}$git_color)${file_list}" ### fringes (added depended on location) head_local="${head_local+$git_color $head_local\n}" -- cgit v1.2.3 From 95d7c0cb51b10514010f4b234dc9aa3de151e252 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sun, 15 Jun 2008 11:39:02 +0300 Subject: bug: new files added files were not exteracted - fixed --- prompt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'prompt') diff --git a/prompt b/prompt index 38694a6..0b7fed9 100755 --- a/prompt +++ b/prompt @@ -267,6 +267,7 @@ PROMPT_COMMAND=' /^# Changes to be committed:/,/^# [A-Z]/ { s/^# Changes to be committed:/added=added/p s/# modified: /git_added_files+=\" \"/p + s/# new file: /git_added_files+=\" \"/p } " ` @@ -315,12 +316,13 @@ PROMPT_COMMAND=' status=${status:-$untracked} # at least one should be set : ${status?prompt internal error: git status} - eval git_color=\${git_$status} + eval git_color="\${git_$status}" git_color=${git_color:-$WHITE} ### head head=`git-name-rev --name-only HEAD 2>/dev/null` head_rev=`git-rev-parse HEAD 2>/dev/null` + head_rev=${head_rev/HEAD/} head_rev=${head_rev:0:6} ### compose local label -- cgit v1.2.3