File: prompting.template

package info (click to toggle)
dotfile 1%3A2.4-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,472 kB
  • ctags: 523
  • sloc: tcl: 14,072; sh: 918; makefile: 177; lisp: 18; ansic: 7
file content (159 lines) | stat: -rw-r--r-- 4,482 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
### Copyright (C) 1996,97 Per Zacho
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; either version 2 of the License, or
### (at your option) any later version.
###
### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
### GNU General Public License for more details.
###
### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

proc promptGen {} {
    # User<->Bash interface / Prompting / General

    Desc "This configuration page will help you to setup options related to"\
    "prompting."

    ShortDesc "Prompting--general setup"

    ### Prompt options ###

    Header head1 -text "Prompt options"\
	    -background gray\
	    -help "Options concerning preprompt commands and how prompt variables are to be handled."

    Entry promptCommandEntry -text "command"\
	    -help "A single command to execute. A delimiter (\;) will be added between each command."

    ExtEntry promptCommand -text "Command(s) to execute before primary prompt"\
	    -entries {promptCommandEntry}\
	    -help "Commands listet here will be executed prior to issuing each primary prompt."\
	    -packFrame:fill x

    Line line1

    CheckBox pvars -text "Expansion of prompting variables"\
	    -default 1\
	    -help "If set, prompt strings undergo variable and parameter expansion after being"\
	    "expanded. This option is chosen by default, and is also why you can display"\
	    "username, time, date, etc. or contents of other variables in your prompt."\
	    "(This option is available in Bash version 2.0 only)"

    ShowPage {
	if {[set version@bash(index)]} {
	    Enable pvars
	} {
	    Disable pvars
	}
    }

    Save {
	set temp ""
	forevery promptCommand {
	    if {$promptCommandEntry != ""} {
		append temp "$promptCommandEntry\;"
	    }
	}
	set temp [string trim $temp ";"]
	if {$temp != ""} {
	    print "export PROMPT_COMMAND='$temp'"
	} {
	    if {$generateDefault} {
		print "unset PROMPT_COMMAND"
	    }
	}

	if {($pvars != 1 || $generateDefault) && [set version@bash(index)]} {
	    print "shopt -[pick $pvars s u] promptvars"
	}
    }
}

proc primprompt {} {
    # User<->Bash interface / Prompting / Primary prompt

    Desc "This configuration page will help you"\
	    "configuring the primary prompt. This is the prompt Bash will print before"\
	    "reading your commands."

    ShortDesc "Primary prompt"

    ### Primary prompt ###

    promptWidget "%shell%%supusr% " {{Primary prompt} {Setup of options regarding the primary prompt}}

    Save {
	if {$prompt != ""} {
	    print "export PS1=\"$prompt\""
	}
    }
}

proc secprompt {} {
    # User<->Bash interface / Prompting / Secondary prompt

    Desc "This configuration page will help you"\
	    "configuring the secondary prompt. This is the prompt Bash will print if the"\
	    "commandline is stretched over more than one line."

    ShortDesc "Secondary prompt"

    ### Secondary prompt ###

    promptWidget "> " {{Secondary prompt} {Setup of options regarding the secondary prompt}}

    Save {
	if {$prompt != ""} {
	    print "export PS2=\"$prompt\""
	}
    }
}

proc thrdprompt {} {
    # User<->Bash interface / Prompting / Prompt 3

    Desc "This configuration page will help you"\
	    "configuring prompt 3. This is the prompt Bash will print when the builtin"\
	    "command \"select\" is awaiting your choice."

    ShortDesc "Prompt 3"

    ### Third prompt ###

    promptWidget "\#? " {{Prompt 3} {Setup of options regarding the third prompt}}

    Save {
	if {$prompt != ""} {
	    print "export PS3=\"$prompt\""
	}
    }
}

proc frthprompt {} {
    # User<->Bash interface / Prompting / Prompt 4

    Desc "This configuration page will help you"\
	    "configuring prompt 4. This is the prompt Bash will print when tracing shell"\
	    "scripts/commands with \"xtrace\" (see User<->Bash interface / Commandline:"\
	    "Command/script handling)."

    ShortDesc "Prompt 4"

    ### Fourth prompt ###

    promptWidget "+" {{Prompt 4} {Setup of options regarding the fourth prompt}}

    Save {
	if {$prompt != ""} {
	    print "export PS4=\"$prompt\""
	}
    }
}