Fossil SCM

Update the www/fossil_prompt.sh demonstration script to the latest version used by the lead SQLite developer.

drh 2025-11-20 00:40 trunk
Commit 077430469f6bc2ca4dadd6440f90bfb1cb712e7b1eb6ebfff5d890bf91f072f8
1 file changed +12 -54
--- www/fossil_prompt.sh
+++ www/fossil_prompt.sh
@@ -1,56 +1,14 @@
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
6
-# checkout. Variables are populated based on the output of the [fossil info]
7
-# command.
8
-#
9
-# If the current directory is not part of a fossil checkout, set global
10
-# variable $fossil_info_project_name to an empty string and return.
11
-#
12
-function get_fossil_data() {
13
- fossil_info_project_name=""
14
- eval `get_fossil_data2`
15
-}
16
-function get_fossil_data2() {
17
- fossil info 2> /dev/null |tr '\042\047\140' _|grep "^[^ ]*:" |
18
- while read LINE ; do
19
- local field=`echo $LINE | sed 's/:.*$//' | sed 's/-/_/'`
20
- local value=`echo $LINE | sed 's/^[^ ]*: *//'`
21
- echo fossil_info_${field}=\"${value}\"
22
- done
23
-}
24
-
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
-#
361
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
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
-
2
+ case `fossil status -b` in
3
+ clean)
4
+ PS1="\[\e[1;32m\]\u@\h\[\e[0m\]:\[\e[1;36m\]\w\$\[\e[0m\] "
5
+ ;;
6
+ dirty)
7
+ PS1="\[\e[1;32m\]\u@\h\[\e[0m\]:\[\e[38;5;202m\]\w\$\[\e[0m\] "
8
+ ;;
9
+ *)
10
+ PS1="\[\e[1;32m\]\u@\h\[\e[0m\]:\w\$ "
11
+ ;;
12
+ esac
13
+}
5614
PROMPT_COMMAND=set_prompt
5715
--- www/fossil_prompt.sh
+++ www/fossil_prompt.sh
@@ -1,56 +1,14 @@
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
6 # checkout. Variables are populated based on the output of the [fossil info]
7 # command.
8 #
9 # If the current directory is not part of a fossil checkout, set global
10 # variable $fossil_info_project_name to an empty string and return.
11 #
12 function get_fossil_data() {
13 fossil_info_project_name=""
14 eval `get_fossil_data2`
15 }
16 function get_fossil_data2() {
17 fossil info 2> /dev/null |tr '\042\047\140' _|grep "^[^ ]*:" |
18 while read LINE ; do
19 local field=`echo $LINE | sed 's/:.*$//' | sed 's/-/_/'`
20 local value=`echo $LINE | sed 's/^[^ ]*: *//'`
21 echo fossil_info_${field}=\"${value}\"
22 done
23 }
24
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
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
--- www/fossil_prompt.sh
+++ www/fossil_prompt.sh
@@ -1,56 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1 function set_prompt() {
2 case `fossil status -b` in
3 clean)
4 PS1="\[\e[1;32m\]\u@\h\[\e[0m\]:\[\e[1;36m\]\w\$\[\e[0m\] "
5 ;;
6 dirty)
7 PS1="\[\e[1;32m\]\u@\h\[\e[0m\]:\[\e[38;5;202m\]\w\$\[\e[0m\] "
8 ;;
9 *)
10 PS1="\[\e[1;32m\]\u@\h\[\e[0m\]:\w\$ "
11 ;;
12 esac
13 }
 
 
 
 
 
 
 
14 PROMPT_COMMAND=set_prompt
15

Keyboard Shortcuts

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