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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
|
### Copyright (C) 1996 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 commHist {} {
# User<->Bash interface / Command history
Desc "This configuration page will help you to setup options relating to"\
"the history function of the Bash shell."
ShortDesc "Command history"
### Command history options ###
Header head1 -text "Command history options"\
-background gray\
-help "Choose where and how much of command history to save."
File-Dir-Browser histfile -text "History file (to place previous commands)"\
-exist 1\
-showHidden 1\
-default "~/.bash_history"
foreach elm {frame_histfile histfile com_histfile} {
Help $elm "To which file should Bash save command history when"\
"exiting the shell"
}
CheckBox histapp -text "Append to an existing history file"\
-default 1\
-help "When appending to an existing history file, commands from previous"\
"shells are not necessarily overwritten. (This option is"\
"available in Bash version 2.0 only)"
Line line1
Menu histcontr -text "Commands to ignore when memorizing "\
-defaultIndex 0\
-entryhelp {"none" "Memorize all commands entered."\
"prepending spaces" "Do not memorize commands starting with a space."\
"duplicate of previous" "Do not memorize commands that match the previous command."\
"both" "Combination of the above two options."}\
-help "With this option you can prevent consecutive duplicate commands from"\
"filling up the history list, as well as you deliberately can prevent Bash from"\
"memorizing commands with a prefix space."\
-button:width 20
Int histsize -text "Size of history list in memory"\
-default 500\
-help "How many commands to memorize in shell memory."
Int histfisi -text "... in history file (in lines)"\
-default 500\
-help "How many commands to file when exiting shell. The value should"\
"not exceed the number of commands in memory."
Frame frame2 -entries {histsize histfisi}\
-packFrame:fill x
Line line2
Radio quest1 -text "With the builtin 'fc' you can edit commands from the history list"\
-defaultIndex 0\
-entryhelp {"Use default editor" "Use the default editor."\
"Use different editor" "Choose another editor for command editing with 'fc'."}\
-help "If you prefere another editor than the default, you can specify"\
"it below, with the complete path and name of editor. The default editor you can"\
"specify on page \"User interface/Commandline\"."\
-packFrame:fill x
File-Dir-Browser fcedit -text "Location of prefered editor"\
-exist 1
foreach elm {frame_fcedit fcedit com_fcedit} {
Help $elm "Please remember to write the complete path and name of editor. If in"\
"doubt, try \"whereis\" command with name of editor. Then cut'n'paste"\
"information after the colon (:)"
}
### History file options ###
Header head2 -text "History file options"\
-background gray\
-help "How is the history file to be build."
CheckBox commorhi -text "Save multiple-line commands in one entry"\
-default 0\
-help "If set, Bash will try to save multiple-line commands in a single"\
"line in the history file."
Radio lithist -text "Command delimiter when saving multiple-line commands"\
-defaultIndex 0\
-entryhelp {"semicolon" "Use semicolon (\;) as command delimiter."\
"newline" {Use newline (\\n) as command delimiter.}}\
-packFrame:anchor center\
-packFrame:fill x\
-help "When Bash save multiple-line commands, you can specify how commands"\
"are saved in history file. It is more comfortable to edit many lines with"\
"\"newline\" (\\n) as delimiter, when using an editor, as to scroll for- and backwards"\
"through commands. (This option is available in Bash version 2.0 only)"
### Interactive history options ###
Header head3 -text "Interactive history options"\
-background gray\
-help "The following options controls how command history is to be handled"\
"in relation to the interactive shell."
CheckBox markmod -text "Mark modified history lines"\
-default 0\
-help "When recalling and modifieng a history entry, the shell will display"\
"an asterisk at the very beginning of the command line, to indicate the"\
"command line origins from history list, but not yet been executed."
CheckBox histedit -text "Allow re-edit of failed history substitution"\
-default 0\
-help "If set, and readline is being used, you will be given the opportunity to re-edit"\
"a failsed history substitution. (This option is available in Bash version 2.0 only)"
Label histLabel -text "History character for"\
-help "In an interactive shell, you have access to previous commands. These characters"\
"will lead to history expansion/substitution according to what function chosen. Please"\
"bear in mind, that you should not choose characters used for other purposes, in order"\
"to avoid misunderstandings."
Entry histExpand -text "expansion"\
-width 2\
-default "!"\
-help "This character signals the start of a history expansion. For further information"\
"please consult your manual."
Entry histSubst -text "substitution"\
-width 2\
-default "^"\
-help "This character will cause a substitution of one string for another in a command."\
"For further information please consult your manual."
Entry histComment -text "\"comment\""\
-width 2\
-default "\#"\
-help "This character signifies, if placed as the first character of a word, that the"\
"remainding of the line is a comment. The history comment character causes history"\
"substitution to be skipped, but it does not necessarily cause the shell to treat"\
"the rest of the line as a comment."
Frame frame4 -entries {histLabel histExpand histSubst histComment}\
-orient left
ShowPage {
if [set version@bash(index)] {
Enable histapp
Enable histedit
Enable lithist
} {
Disable histapp
Disable histedit
Disable lithist
}
}
Change {
if $quest1(index) {Enable frame_fcedit} {Disable frame_fcedit}
if {$commorhi && [set version@bash(index)]} {
Enable lithist
} {
Disable lithist
}
}
PageEnd {
### Make sure no more commands saved to disk, than in memory
if {$histfisi > $histsize} {
error "The number of commands saved when exiting shell exceeds number of commands in shell memory"
}
if {$histfisi < 0 || $histsize < 0} {
error "History list in memory or file must be a positive number"
}
### Ignore user defined editor, if none is chosen
if {$quest1(index) && $fcedit == ""} {
set quest1(index) 0
Disable fcedit
}
### History characters ###
if {[string length $histExpand] != 1} {
error "You have to specify a (single) history expansion character"
}
if {[string length $histSubst] != 1} {
error "You have to specify a (single) history substitution character"
}
if {[string length $histComment] > 1} {
error "You have to specify a single history comment character"
}
}
Save {
### Command history options ###
if {$histfile != "~/.bash_history" || $generateDefault} {
print "export HISTFILE=$histfile"
}
if {($histapp == 0 || $generateDefault) && [set version@bash(index)]} {
print "shopt -[pick $histapp s u] histappend"
}
if {$histcontr(index) || $generateDefault} {
switch $histcontr(index) {
0 {set temp ""}
1 {set temp "ignorespace"}
2 {set temp "ignoredups"}
3 {set temp "ignoreboth"}
}
if {$temp != ""} {
print "export HISTCONTROL=$temp"
} {
print "unset HISTCONTROL"
}
}
if {$histsize != 500 || $generateDefault} {
print "export HISTSIZE=$histsize"
}
if {$histfisi != 500 || $generateDefault} {
print "export HISTFILESIZE=$histfisi"
}
if {$quest1(index) || $generateDefault} {
print "[pick $quest1(index) "export FCEDIT=$fcedit" "unset FCEDIT"]"
}
### History file options ###
if {$commorhi || $generateDefault} {
if [set version@bash(index)] {
print "shopt -[pick $commorhi s u] cmdhist"
} {
print "[pick $commorhi "export command_oriented_history=on" "unset command_oriented_history"]"
}
}
if {($lithist(index) || $generateDefault) && [set version@bash(index)]} {
if $commorhi {
print "shopt -[pick $lithist(index) s u] lithist"
}
}
### Interactive history options ###
if {$markmod || $generateDefault} {
print -file inputrc "set mark-modified-lines [pick $markmod on off]"
}
if {($histedit || $generateDefault) && [set version@bash(index)]} {
print "shopt -[pick $histedit s u] histreedit"
}
if {($histExpand != "!" || $histSubst != "^") || $generateDefault} {
print "export histchars='$histExpand$histSubst$histComment'"
}
}
}
|