File: completion.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 (155 lines) | stat: -rw-r--r-- 5,731 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
### 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 completion {} {
    # User<->Bash interface / Completion

    Desc "This configuration page will help you to setup options relating to"\
    "commandline completion and filename globbing."

    ShortDesc "Completion"

    ### Completion options ###

    Header head1 -text "Completion options"\
	    -background gray\
	    -help "Options concerning completion of user input."

    Radio showamb -text "If words have more than one possible completion..."\
	    -defaultIndex 0\
	    -entryhelp {"ring the bell" "If word is ambiguous shell will ring the bell (beep)."\
	    "list all completions" "If word is ambiguous shell will list all possible completions"}\
	    -help "If the command is ambiguous (i.e. there are more than one possible"\
	    "way of completing the sentence), then shell either list the possible"\
	    "completions, or ring the bell."\
	    -packFrame:fill x

    Int compquery -text "Max. number of elements to show without asking"\
	    -default 100\
	    -help "You can specify how many possible completions you would like to see,"\
	    "without shell asking you for verification. This often happens, when trying to"\
	    "auto complete when seed is too general."

    CheckBox exptilde -text "Expand tilde (~) when completing"\
	    -default 0\
	    -help "If enabled Bash will expand tilde (~) to its value. This is most likely"\
	    "the path to your home directory."

    File-Dir-Browser hostfile -text "Hostname file"\
	-exist 1\
	-default "/etc/hosts"

    foreach elm {frame_hostfile hostfile com_hostfile} {
	Help $elm "When Bash is to complete hostname, you can specify where this information"\
	    "is stored. The file must have the same format as /etc/hosts."
    }

    Line line1

    Entry fignoreComponent -text "Filename suffix"\
	    -help "A sufix is the last part of the file name.\nExample: \".o\" is the"\
	    "suffix of \"file.o\" and \"~\" is the suffix of \"file~\"."

    ExtEntry fignore -text "File suffixes to ignore upon filename completion"\
	    -entries fignoreComponent\
	    -help "Here you can construct a list of filename suffixes to ignore upon file"\
	    "name completion."\
	    -packFrame:fill x

    ### Globbing options ###

    Header head2 -text "Globbing options"\
	    -background gray\
	    -help "When Bash tries to translate a filename pattern to a number of physical"\
	    "existing filenames, it is called \"globbing\". Wildcards to be used in Bash is:\n"\
	    "?\tAny single character\n*\tAny string of characters\n\[set\]\tAny character"\
	    "in set\n\[!set\]\tAny character _not_ in set"

    CheckBox noglob -text "Expand wildcards (* and ? in filenames)"\
	    -default 1\
	    -help "Wildcards is often used when handling multiple files. Expanding from"\
	    "wildcards to filenames is the job of the shell (globbing). Disabling this feature"\
	    "disallows you from using this convenience."

    CheckBox nullglob -text "Allow null-string expansion"\
	    -default 0\
	    -help "If no filenames match with the wildcard pattern, then either the pattern"\
	    "will be replaced with a null-string, or Bash will leave the pattern for the program"\
	    "to interpret."

    CheckBox dotglob -text "Include dot-files upon filename globbing"\
	    -default 0\
	    -help "Files with a prefix dot (.) is normally considered hidden--also when"\
	    "globbing filenames from pattern. With this option, you are able to pick dotfiles"\
	    "with wildcards.\nExample: Try to type \"echo *\" in your home directory with and"\
	    "without this option, and see the difference."

    PageEnd {
	if {$compquery < 0} {
	    error "This number has to be a positive number"
	}
    }

    Save {
	### Completion options ###
	if {$showamb(index) || $generateDefault} {
	    print -file inputrc "set show-all-if-ambiguous [pick $showamb(index) on off]"
	}

	if {$compquery != 100 || $generateDefault} {
	    print -file inputrc "set completion-query-items $compquery"
	}

	if {$exptilde || $generateDefault} {
	    print -file inputrc "set expand-tilde [pick $exptilde on off]"
	}

	if {$hostfile != "/etc/hosts" || $generateDefault} {
	    print "[pick {$hostfile != ""} "export HOSTFILE=$hostfile" "unset HOSTFILE"]"
	}
	
	set temp ""
	forevery fignore {
	    if {$fignoreComponent != ""} {
		append temp "$fignoreComponent:"
	    }
	}
	if {$temp != ""} {
	    print "export FIGNORE='[string trim $temp ":"]'"
	}

	### Globbing options ###
	if {$noglob != 1 || $generateDefault} {
	    print "set [pick $noglob + -]o noglob"
	}

	if {$nullglob || $generateDefault} {
	    if [set version@bash(index)] {
		print "shopt -[pick $nullglob s u] nullglob"
	    } {
		print "[pick $nullglob "export allow_null_glob_expansion=on" "unset allow_null_glob_expansion"]"
	    }
	}

	if {$dotglob || $generateDefault} {
	    if [set version@bash(index)] {
		print "shopt -[pick $dotglob s u] dotglob"
	    } {
		print "[pick $dotglob "export glob_dot_filenames=on" "unset glob_dot_filenames"]"
	    }
	}
    }
}