@@ -30,22 +30,27 @@ make check # optional, requires dejagnu and tcllib
3030make install # as root
3131```
3232
33- These commands installs the completions and helpers, as well as a
34- profile.d script that loads ` bash_completion ` where appropriate. If
35- your system does not use the profile.d directory (usually below
36- ` /etc ` ) mechanism, i.e. does not automatically source shell scripts in
37- it, you can source the ` $sysconfdir/profile.d/bash_completion.sh `
33+ These commands install the completions and helpers, as well as a
34+ ` profile.d ` script that loads ` bash_completion ` where appropriate.
35+
36+ If your system does not use the ` profile.d ` directory (usually below
37+ ` /etc ` ) mechanism—i.e. does not automatically source shell scripts in
38+ it—you can source the ` $sysconfdir/profile.d/bash_completion.sh `
3839script in ` /etc/bashrc ` or ` ~/.bashrc ` .
3940
40- The profile.d script provides a configuration file hook that can be
41+ The ` profile.d ` script provides a configuration file hook that can be
4142used to prevent loading ` bash_completion ` on per user basis when it's
42- installed system wide. To do this, turn off programmable completion
43- with ` shopt -u progcomp ` in ` $XDG_CONFIG_HOME/bash_completion `
44- (` ~/.config/bash_completion ` if ` $XDG_CONFIG_HOME ` is not set), and
45- turn it back on for example in ` ~/.bashrc ` if you want to use
46- programmable completion for other purposes.
43+ installed system wide. To do this:
44+
45+ 1 . Turn off programmable completion with ` shopt -u progcomp ` in
46+ ` $XDG_CONFIG_HOME/bash_completion ` (or ` ~/.config/bash_completion `
47+ if ` $XDG_CONFIG_HOME ` is not set)
48+ 2 . Turn it back on (for example in ` ~/.bashrc ` ) if you want to use
49+ programmable completion for other purposes.
50+
51+ ### macOS (OS X)
4752
48- If you're using MacOS X , ` /etc/bashrc ` is apparently not sourced at
53+ If you're using macOS (formerly OS X) , ` /etc/bashrc ` is apparently not sourced at
4954all. In that case, you can put the ` bash_completion ` file in ` /sw/etc `
5055and add the following code to ` ~/.bash_profile ` :
5156
@@ -73,62 +78,65 @@ tracing on in it before doing anything else there.
7378
7479## Known problems
7580
76- 1 . There seems to be some issue with using the bash built-in cd within
81+ 1 . There seems to be some issue with using the bash built-in ` cd ` within
7782 Makefiles. When invoked as ` /bin/sh ` within ` Makefile ` s, bash seems
7883 to have a problem changing directory via the ` cd ` command. A
7984 work-around for this is to define ` SHELL=/bin/bash ` within your
8085 ` Makefile ` . This is believed to be a bug in bash.
8186
82872 . Many of the completion functions assume GNU versions of the various
83- text utilities that they call (e.g. grep, sed and awk). Your
88+ text utilities that they call (e.g. ` grep ` , ` sed ` , and ` awk ` ). Your
8489 mileage may vary.
8590
86913 . If you are seeing 'unbound variable' warnings from bash when
87- hitting \< Tab>, this is because you have either ` set -u ` or `set -o
88- nounset` somewhere in your start-up files. This causes bash to flag
89- the use of any uninitialised shell variables as an error.
92+ hitting < kbd > & lt ; Tab></ kbd > , this is because you have either ` set -u `
93+ or ` set -o nounset` somewhere in your start-up files. This causes bash
94+ to flag the use of any uninitialised shell variables as an error.
9095
9196 Whilst we try to avoid references to uninitialised variables in the
9297 code, there seem to be at least some cases where bash issues this
9398 warning even though the variable in question has been initialised.
9499
95100 One place this appears to occur is within the ` _muttconffiles() `
96- helper function used by mutt completion, where the function calls
101+ helper function used by ` mutt ` completion, where the function calls
97102 itself recursively. This seems to confuse bash and it issues
98103 spurious warnings if ` nounset ` is set.
99104
100105
101106## FAQ
102107
103- Q. The bash completion code inhibits some commands from completing on
108+ ** Q. The bash completion code inhibits some commands from completing on
104109 files with extensions that are legitimate in my environment. Do I
105110 have to disable completion for that command in order to complete on
106- the files that I need to?
111+ the files that I need to?**
107112
108113A. No. Use ` M-/ ` to (in the words of the bash man page) attempt file
109114 name completion on the text to the left of the cursor. This will
110115 circumvent any file type restrictions put in place by the bash
111116 completion code.
112117
113- Q. How can I insert my own local completions without having to
114- reinsert them every time you issue a new release?
118+ ** Q. How can I insert my own local completions without having to
119+ reinsert them every time you issue a new release?**
115120
116121A. Put them in ` ~/.bash_completion ` , which is parsed at the end of the
117122 main completion script. See also the next question.
118123
119- Q. I author/maintain package X and would like to maintain my own
124+ ** Q. I author/maintain package X and would like to maintain my own
120125 completion code for this package. Where should I put it to be sure
121- that interactive bash shells will find it and source it?
126+ that interactive bash shells will find it and source it?**
122127
123128A. Install it in one of the directories pointed to by
124- bash-completion's pkgconfig file variables. There are two
125- alternatives: the recommended one is ` completionsdir ` (get it with
126- ` pkg-config --variable=completionsdir bash-completion ` ) from which
127- completions are loaded on demand based on invoked commands' names,
129+ bash-completion's ` pkgconfig ` file variables. There are two
130+ alternatives:
131+
132+ - The recommended directory is ` completionsdir ` , which you can get with
133+ ` pkg-config --variable=completionsdir bash-completion ` . From this
134+ directory, completions are loaded on-demand based on invoked commands' names,
128135 so be sure to name your completion file accordingly, and to include
129- for example symbolic links in case the file provides completions
130- for more than one command. The other one which is present for
131- backwards compatibility reasons is ` compatdir ` (get it with
136+ (for example) symbolic links in case the file provides completions
137+ for more than one command.
138+ - The other directory (which only present for backwards compatibility)
139+ is ` compatdir ` (get it with
132140 ` pkg-config --variable=compatdir bash-completion ` ) from which files
133141 are loaded when ` bash_completion ` is loaded.
134142
@@ -166,39 +174,39 @@ A. Install it in one of the directories pointed to by
166174 ${BASH_COMPLETION_COMPLETIONSDIR})
167175 ```
168176
169- Q. I use CVS in combination with passwordless SSH access to my remote
177+ ** Q. I use CVS in combination with passwordless SSH access to my remote
170178 repository. How can I have the ` cvs ` command complete on remotely
171- checked-out files where relevant?
179+ checked-out files where relevant?**
172180
173181A. Define ` $COMP_CVS_REMOTE ` . Setting this to anything will result in
174182 the behaviour you would like.
175183
176- Q. When I'm running a ` ./configure ` script and completion returns a list
184+ ** Q. When I'm running a ` ./configure ` script and completion returns a list
177185 of long options to me, some of these take a parameter,
178- e.g. ` --this-option=DESCRIPTION ` .
186+ e.g. ` --this-option=DESCRIPTION ` .**
179187
180- Running ` ./configure --help ` lists these descriptions, but
188+ ** Running ` ./configure --help ` lists these descriptions, but
181189 everything after the ` = ` is stripped when returning completions, so
182190 I don't know what kind of data is expected as a given option's
183- parameter.
191+ parameter.**
184192
185- Is there a way of getting ` ./configure ` completion to return the
193+ ** Is there a way of getting ` ./configure ` completion to return the
186194 entire option string, so that I can see what kind of data is
187195 required and then simply delete the descriptive text and add my own
188- data?
196+ data?**
189197
190198A. Define ` $COMP_CONFIGURE_HINTS ` . Setting this to anything will
191199 result in the behaviour you would like.
192200
193- Q. When doing tar completion on a file within a tar file like this:
201+ ** Q. When doing tar completion on a file within a tar file like this:**
194202
195203 ```
196204 tar tzvf foo.tar.gz <Tab>
197205 ```
198206
199- the pathnames contained in the tar file are not displayed
200- correctly. The slashes are removed and everything looks like it's
201- in a single directory. Why is this?
207+ ** the pathnames contained in the tar file are not displayed
208+ correctly. The slashes are removed, and everything looks like it's
209+ in a single directory. Why is this?**
202210
203211A. It's a choice we had to make. bash's programmable completion is
204212 limited in how it handles the list of possible completions it
@@ -218,8 +226,9 @@ A. It's a choice we had to make. bash's programmable completion is
218226 contents, define ` $COMP_TAR_INTERNAL_PATHS ` * before* sourcing
219227 ` bash_completion ` .
220228
221- Q. When completing on a symlink to a directory, bash does not append
222- the trailing ` / ` and I have to hit \< Tab> again. I don't like this.
229+ ** Q. When completing on a symlink to a directory, bash does not append
230+ the trailing ` / ` and I have to hit <kbd >< ; Tab></kbd > again.
231+ I don't like this.**
223232
224233A. This has nothing to do with ` bash_completion ` . It's the default for
225234 completing symlinks to directories since bash 2.05a, and was added
@@ -230,8 +239,8 @@ A. This has nothing to do with `bash_completion`. It's the default for
230239 mark-symlinked-directories on` in your ` /etc/inputrc` or
231240 ` ~/.inputrc ` file.
232241
233- Q. Completion goes awry when I try to complete on something that contains
234- a colon.
242+ ** Q. Completion goes awry when I try to complete on something that contains
243+ a colon.**
235244
236245A. This is actually a 'feature' of bash. bash recognises a colon as
237246 starting a new completion token, which is often what you want when
@@ -258,7 +267,7 @@ A. This is actually a 'feature' of bash. bash recognises a colon as
258267 Unfortunately, there's no way to turn this off. The only thing you
259268 can do is escape the colons with a backslash.
260269
261- Q. Why is ` rpm ` completion so slow with ` -q ` ?
270+ ** Q. Why is ` rpm ` completion so slow with ` -q ` ?**
262271
263272A. Probably because the database is being queried every time and this uses a
264273 lot of memory.
@@ -281,17 +290,17 @@ A. Probably because the database is being queried every time and this uses a
281290 unless it detects that the database has changed since the file was created,
282291 in which case it will still use the database to ensure accuracy.
283292
284- Q. bash-completion interferes with my ` command_not_found_handler ` function!
293+ ** Q. bash-completion interferes with my ` command_not_found_handler ` function!**
285294
286295A. If your ` command_not_found_handler ` function is not intended to
287296 address (possibly missing) commands invoked during bash
288- programmable completion functions, you can take that into account
289- in your function for example by testing if the ` $COMP_ ` * variables
290- are set and taking appropriate bypass or other action.
297+ programmable completion functions, you can account for this
298+ by, for example, testing if the ` $COMP_ ` \ * variables are set and
299+ taking appropriate bypass or other action.
291300
292- Q. Can tab completion be made even easier?
301+ ** Q. Can tab completion be made even easier?**
293302
294- A. The readline(3) library offers a few settings that can make tab
303+ A. The ` readline(3) ` library offers a few settings that can make tab
295304 completion easier (or at least different) to use.
296305
297306 For example, try putting the following in either ` /etc/inputrc ` or
@@ -309,7 +318,7 @@ A. The readline(3) library offers a few settings that can make tab
309318 ```
310319
311320 This will suffix each returned file completion with a character
312- denoting its type, in a similar way to ls(1) with ` -F ` or ` --classify ` .
321+ denoting its type, in a similar way to ` ls(1) ` with ` -F ` or ` --classify ` .
313322
314323 ```
315324 set page-completions off
@@ -318,7 +327,7 @@ A. The readline(3) library offers a few settings that can make tab
318327 This turns off the use of the internal pager when returning long
319328 completion lists.
320329
321- Q. Is bash the be-all-and-end-all of completion as far as shells go?
330+ ** Q. Is bash the be-all-and-end-all of completion as far as shells go?**
322331
323332A. Absolutely not. zsh has an extremely sophisticated completion system
324333 that offers many features absent from the bash implementation. Its
0 commit comments