Fossil SCM

Update the fossil_prompt.sh script so that it keeps the username and hostname part of the prompt green and only changes the path from red to green.

drh 2022-03-17 12:01 trunk
Commit cca805fa894784cc983bea387a6b8844bb8b90d3c1b2dbce77778e7b8baf344f
1 file changed +5 -14
--- www/fossil_prompt.sh
+++ www/fossil_prompt.sh
@@ -1,6 +1,5 @@
1
-
21
#-------------------------------------------------------------------------
32
# get_fossil_data()
43
#
54
# If the current directory is part of a fossil checkout, then populate
65
# a series of global variables based on the current state of that
@@ -26,27 +25,20 @@
2625
#-------------------------------------------------------------------------
2726
# set_prompt()
2827
#
2928
# Set the PS1 variable. If the current directory is part of a fossil
3029
# checkout then the prompt contains information relating to the state
31
-# of the checkout.
30
+# of the checkout.
3231
#
3332
# Otherwise, if the current directory is not part of a fossil checkout, it
3433
# is set to a fairly standard bash prompt containing the host name, user
3534
# name and current directory.
3635
#
3736
function set_prompt() {
3837
get_fossil_data
39
- if [ -n "$fossil_info_project_name" ] ; then
40
- project=$fossil_info_project_name
41
- checkout=`echo $fossil_info_checkout | sed 's/^\(........\).*/\1/'`
42
- date=`echo $fossil_info_checkout | sed 's/^[^ ]* *..//' | sed 's/:[^:]*$//'`
43
- tags=$fossil_info_tags
44
- local_root=`echo $fossil_info_local_root | sed 's/\/$//'`
45
- local=`pwd | sed "s*${local_root}**" | sed "s/^$/\//"`
46
-
47
- # Color the first part of the prompt blue if this is a clean checkout.
38
+ if [ -n "$fossil_info_project_name" ] ; then
39
+ # Color the path part of the prompt blue if this is a clean checkout
4840
# Or red if it has been edited in any way at all. Set $c1 to the escape
4941
# sequence required to change the type to the required color. And $c2
5042
# to the sequence that changes it back.
5143
#
5244
if [ -n "`fossil chang`" ] ; then
@@ -53,13 +45,12 @@
5345
c1="\[\033[1;31m\]" # red
5446
else
5547
c1="\[\033[1;34m\]" # blue
5648
fi
5749
c2="\[\033[0m\]"
58
-
59
- PS1="$c1${project}.${tags}$c2 ${checkout} (${date}):${local}$c1\$$c2 "
50
+ PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:$c1\w\$$c2 "
6051
else
61
- PS1="\u@\h:\w\$ "
52
+ PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\w\$ "
6253
fi
6354
}
6455
6556
PROMPT_COMMAND=set_prompt
6657
--- www/fossil_prompt.sh
+++ www/fossil_prompt.sh
@@ -1,6 +1,5 @@
1
2 #-------------------------------------------------------------------------
3 # get_fossil_data()
4 #
5 # If the current directory is part of a fossil checkout, then populate
6 # a series of global variables based on the current state of that
@@ -26,27 +25,20 @@
26 #-------------------------------------------------------------------------
27 # set_prompt()
28 #
29 # Set the PS1 variable. If the current directory is part of a fossil
30 # checkout then the prompt contains information relating to the state
31 # of the checkout.
32 #
33 # Otherwise, if the current directory is not part of a fossil checkout, it
34 # is set to a fairly standard bash prompt containing the host name, user
35 # name and current directory.
36 #
37 function set_prompt() {
38 get_fossil_data
39 if [ -n "$fossil_info_project_name" ] ; then
40 project=$fossil_info_project_name
41 checkout=`echo $fossil_info_checkout | sed 's/^\(........\).*/\1/'`
42 date=`echo $fossil_info_checkout | sed 's/^[^ ]* *..//' | sed 's/:[^:]*$//'`
43 tags=$fossil_info_tags
44 local_root=`echo $fossil_info_local_root | sed 's/\/$//'`
45 local=`pwd | sed "s*${local_root}**" | sed "s/^$/\//"`
46
47 # Color the first part of the prompt blue if this is a clean checkout.
48 # Or red if it has been edited in any way at all. Set $c1 to the escape
49 # sequence required to change the type to the required color. And $c2
50 # to the sequence that changes it back.
51 #
52 if [ -n "`fossil chang`" ] ; then
@@ -53,13 +45,12 @@
53 c1="\[\033[1;31m\]" # red
54 else
55 c1="\[\033[1;34m\]" # blue
56 fi
57 c2="\[\033[0m\]"
58
59 PS1="$c1${project}.${tags}$c2 ${checkout} (${date}):${local}$c1\$$c2 "
60 else
61 PS1="\u@\h:\w\$ "
62 fi
63 }
64
65 PROMPT_COMMAND=set_prompt
66
--- www/fossil_prompt.sh
+++ www/fossil_prompt.sh
@@ -1,6 +1,5 @@
 
1 #-------------------------------------------------------------------------
2 # get_fossil_data()
3 #
4 # If the current directory is part of a fossil checkout, then populate
5 # a series of global variables based on the current state of that
@@ -26,27 +25,20 @@
25 #-------------------------------------------------------------------------
26 # set_prompt()
27 #
28 # Set the PS1 variable. If the current directory is part of a fossil
29 # checkout then the prompt contains information relating to the state
30 # of the checkout.
31 #
32 # Otherwise, if the current directory is not part of a fossil checkout, it
33 # is set to a fairly standard bash prompt containing the host name, user
34 # name and current directory.
35 #
36 function set_prompt() {
37 get_fossil_data
38 if [ -n "$fossil_info_project_name" ] ; then
39 # Color the path part of the prompt blue if this is a clean checkout
 
 
 
 
 
 
 
40 # Or red if it has been edited in any way at all. Set $c1 to the escape
41 # sequence required to change the type to the required color. And $c2
42 # to the sequence that changes it back.
43 #
44 if [ -n "`fossil chang`" ] ; then
@@ -53,13 +45,12 @@
45 c1="\[\033[1;31m\]" # red
46 else
47 c1="\[\033[1;34m\]" # blue
48 fi
49 c2="\[\033[0m\]"
50 PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:$c1\w\$$c2 "
 
51 else
52 PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\w\$ "
53 fi
54 }
55
56 PROMPT_COMMAND=set_prompt
57

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button