Questions about command completion in the Bash Unix shell.
Questions tagged [bash-completion]
310 questions
5
votes
1 answer
Preserve Bash Completion for all commands that are prepended by a custom command
I have a script which allows to execute Bash processes in the background, i called it "backy". Programs I want to run in background I call like this:
backy long-running-script param1 param2
The problem is now that I loose the Bash completion for…

Wolkenarchitekt
- 20,170
- 29
- 111
- 174
5
votes
1 answer
Escape slashes in bash complete
I try to use the bash complete builtin to show different options for a command.
I have problems when an option contains a path like in -F/dev/null.
Currently I'm using
#!/bin/bash
_xyz-completion ()
{
local cur
COMPREPLY=() # Array…

jeb
- 78,592
- 17
- 171
- 225
5
votes
1 answer
Do not autocomplete certain extensions from file names in shell for vim
I've noticed a really cool feature of bash-completion in bash. Let's say I have a directory with files
a.java
a.class
b.java
b.class
if I start typing vim a Tab , bash will autocomplete a.java. It knows I don't want to edit a.class
I was…

Max Coplan
- 1,111
- 13
- 27
5
votes
3 answers
Where to put bash completion scripts
I have implemented some perl scripts and in some cases i have to pass some command line args into my program.Usability perspective i have decided to add some bash completion script into my project.But now i am stuck on where to put my script to work…

gihan-maduranga
- 4,381
- 5
- 41
- 74
5
votes
1 answer
emergency override of broken command completions in bash?
One of my biggest aggravations with working in bash is the chronically broken command completions.
There are hundreds of programmed command completions, more being written each day, some by the distro (I'm currently using mostly ubuntu linux) or…

Don Hatch
- 5,041
- 3
- 31
- 48
5
votes
1 answer
bash_completion causing a 'command not found' in terminal
I'm using bash_completion in order to hit tab and see branch names and directories. That all works. I placed this into my bash_profile in order to connect bash_completion:
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew…

Spencer Rohan
- 1,759
- 3
- 12
- 23
5
votes
1 answer
kubectl -bash: _init_completion: command not found
Cannot get kubectl bash completion to work on Mac. I installed bash-completion with brew i.e. brew install bash-completion then as per the install notes, added it to the ~/.bash_profile:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
.…

WispyCloud
- 4,140
- 1
- 28
- 31
5
votes
1 answer
nullglob disables pathname tab-completion
I have found that shopt -s nullglob apparently disables tab-completion for files and directories, and shopt -u nullglob restores it. Why does tab-completion for directories apparently rely on nullglob being unset?
I am using Bash 4.2.37(1)-release…

Kyle Strand
- 15,941
- 8
- 72
- 167
5
votes
1 answer
How to give correct suggestions to tab complete when my words contains colons
I am writing a bash tab completion file for a utility that some times requires full URLs on the form: protocol://host:port. This contains two colons, which have proven to be problematic for tab completion. This is because the colons are treated as…

toftis
- 1,070
- 9
- 26
5
votes
3 answers
Set working directory for function arguments
My code is all located in the following directory on my computer /a/b/c/d/e/myCode. I got annoyed of typing make /a/b/c/d/e/myCode/project1 when I wanted to compile project1. To fix this I created a function in my bashrc that looks as…

Benjy Kessler
- 7,356
- 6
- 41
- 69
5
votes
1 answer
specify another directory to compgen for auto completing directories, than using pwd
compgen -d -- $cur will suggest completions for the directories in pwd only right?
Can I get it to suggest directory completions for some dir while being in another dir.
For eg. if I am in /curr_dir, and I want to generate directory completions for…

udiboy1209
- 1,472
- 1
- 15
- 33
5
votes
1 answer
How to use bash completion-functions that are defined on-the-fly?
I try to add a completion for the alias: alias m='man'.
So, I added complete -F _man m to my .bashrc.
The problem is that the function _man used for completing, isn't defined at the start of the bash session but is defined when performing the first…

loxaxs
- 2,149
- 23
- 27
4
votes
2 answers
Install Bash completion together with distutils / pip
I have created a simple Python module and want to distribute it with pip. I also want to install a Bash completion file together with the module.
I'm installing the module with Python 2.7.1+ and pip 0.8.2.
I have this setup.py:
setup(
…

Wolkenarchitekt
- 20,170
- 29
- 111
- 174
4
votes
4 answers
Bash tab completion changed behavior
For a long time, I have been used to being able to type something like:
$opt/foo/m
and so on to navigate my project within different environments. It is really useful: just set up $opt (say, /home/$USER/projects/opt - and go from your dev user, to…

KateYoak
- 1,591
- 3
- 18
- 34
4
votes
2 answers
Bash completion with none space delimited words
I am working on completion for a command that takes argument like "one:two:three".
In the simplest terms, I want ':' to be handled just like a space character is by default. Is there a simple way to do this that I am missing?
I've found the ':' is…

schickb
- 1,889
- 3
- 15
- 19