From 3c060178ad5bc94d9656e19aa6c5681d4886f09c 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/prompt b/prompt index 17959be..7b4a5dd 100755 --- a/prompt +++ b/prompt @@ -323,8 +323,8 @@ PROMPT_COMMAND=' eval git_color="\${git_$status}" ### head - head=`git-name-rev --name-only HEAD` - head_rev=`git-rev-parse HEAD` + 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 @@ -345,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 6f04a2d02d0e304627d3f5d9e834e0d4b9c524ef 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(-) 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 fb162b58b16046259a2400d55746e445bf1aae48 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(-) 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 4e57a7289c23a0d1056770f8b7aadc388079c3ba 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(-) 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 64e0b518e9dde1498ba3301561367db3a24fec22 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(-) 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 1841fcac0343983f671f8d07fe34457b2c0318e6 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/prompt b/prompt index 38694a6..e96c573 100755 --- a/prompt +++ b/prompt @@ -266,7 +266,8 @@ PROMPT_COMMAND=' /^# Changes to be committed:/,/^# [A-Z]/ { s/^# Changes to be committed:/added=added/p - s/# modified: /git_added_files+=\" \"/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 From 6b3955e220ccb0e875e7eaf742649de1172c82f6 Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sun, 15 Jun 2008 12:11:38 +0300 Subject: color fix --- prompt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/prompt b/prompt index e96c573..8597f8f 100755 --- a/prompt +++ b/prompt @@ -332,8 +332,7 @@ PROMPT_COMMAND=' 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/master/m} $white$head_rev${op+ / $op}$git_color)${file_list}" + tail_local="(${head/master/m} $white$head_rev$git_color${op+ / $op}$git_color${file_list}$git_color)" ### fringes (added depended on location) head_local="${head_local+$git_color $head_local\n}" -- cgit v1.2.3