Questions tagged [bash-completion]

Questions about command completion in the Bash Unix shell.

310 questions
4
votes
1 answer

bash completion for git custom subcommands?

Say I have a git-cc executable in PATH. If git-cc supports --help, then it is easy to provide adequate completion with complete -F _longopt git-cc This makes $ git-cc -- complete (as per help output). But git cc -- won't complete (even…
usretc
  • 723
  • 4
  • 9
4
votes
2 answers

How to tell `complete` to fall-back to its default?

I'm using the complete bash-builtinin to enable arbitrary auto-completion for my python script. I set it up with: complete -C './script.py --compgen "$@"' ./script.py Such that whenever bash attempts to auto-complete it invokes my script with a…
bitmask
  • 32,434
  • 14
  • 99
  • 159
4
votes
1 answer

kubectl bash completion for alias with options

I have several kubectl aliases configured: alias k='kubectl' alias kn='kubectl -n' alias ks='kubectl -n kube-system' alias ka='kubectl get --all-namespaces' Bash completion works fine for kubectl and I got it working for most of the aliases as…
DonGiovanni
  • 891
  • 1
  • 7
  • 15
4
votes
1 answer

Prevent bash completion from printing the reply twice

I am having difficulties making my bash completion script behave as expected. Below is the most simplified version of what I am trying to do, and a screencast of the problem. Everything works great, with the exception of one case: When there is one…
DannyB
  • 12,810
  • 5
  • 55
  • 65
4
votes
1 answer

autocomplete boost program options

after hours of search I ended up writing my first stackoverflow question. I want to create a completion function for a bash script, so far so good ;). This bash script calls other executables that have their own autocompletion. Example: $ my_script…
4
votes
1 answer

Hints for custom bash completion

I am developing a custom bash completion command to capture job IDs from a scheduling system (LSF, PBS, SLURM). I've got the basic functionality, but I would like to extend it now with "hints" that I've seen when running zsh. For instance when I…
4
votes
1 answer

Custom Bash Autocomplete with File Path Completion

I'm working on bash auto-completion for a project I'm the maintainer of. You can find the script here. I've cobbled this together with some hacking on my own, and with the help of some contributors who understand that completion APIs better than I…
Alana Storm
  • 164,128
  • 91
  • 395
  • 599
4
votes
2 answers

Bash completion sometimes meshes up my terminal when the completion function reads a file

So I've been having a problem with some cli programs. Sometimes when I kill the running process with Ctrl+C, it leaves the terminal in a weird state (e.g. echo is turned off). Now that is to be expected for many cases, as killing a process does not…
safsaf32
  • 1,517
  • 2
  • 13
  • 18
4
votes
1 answer

Bash completion for Camel.CaseNames (cd CCN => cd Camel.CaseName)

I'm looking for a way to implement completion for file/directory names of the kind Foo.Bar.Baz/ Foo.Bar.QuickBrown.Fox/ Foo.Bar.QuickBrown.Interface/ Foo.Bar.Query.Impl/ where the completion would work like ~ $ cd…
arhzu
  • 550
  • 3
  • 13
4
votes
2 answers

bash [: too many arguments greater than symbol

This isn't really a question (though I have one at the end), but rather a solution to a problem that I wanted to share in case it helps someone else. For the longest time I had been getting bash: [: too many arguments when opening a new terminal…
Brett Ryland
  • 1,045
  • 1
  • 9
  • 17
4
votes
1 answer

Tab completion doesn't complete paths with escaped space

For a while now I'm experiencing an annoying bash-completion problem, namely it doesn't work when a path contains an escaped space. For example, I am in /cygdrive/c and type $ cd Pro pressing Tab key completes to "cd Program", pressing twice shows…
Piotr
  • 572
  • 5
  • 22
4
votes
2 answers

how to add non-latin gnu/make targets to completion list?

gnu/make supports non-latin identifiers (f.e., targets) in makefile. example: $ cat GNUmakefile test: @echo test тест: @echo test in russian $ make test тест test test in russian but the bash-completion with this example completes only one…
aleksandr barakin
  • 521
  • 1
  • 13
  • 42
4
votes
1 answer

Bash completion: Allow flags once

I have a basic complete function: _my_complete () { local cur prev opts opts2; COMPREPLY=(); cur="${COMP_WORDS[COMP_CWORD]}"; prev="${COMP_WORDS[COMP_CWORD-1]}"; opts="foo bar"; opts2="-f -s"; case ${COMP_CWORD} in …
Maxim_united
  • 1,911
  • 1
  • 14
  • 23
4
votes
1 answer

Suppress syntax error or warning in bash_completion every time new terminal is opened?

I enabled bash_completion in my .bashrc file. Now every time I start a terminal, it shows me this warning: bash: [: too many arguments bash: [: =: unary operator expected bash: [: =: unary operator expected bash: [: too many arguments For more…
udiboy1209
  • 1,472
  • 1
  • 15
  • 33
4
votes
4 answers

Python or Bash print output to command line ready to be executed

I'm trying to write a Python or Bash script that outputs a bash command directly to the command line (i.e. as if I just typed it and could then hit enter to execute it). How can I output the command in this fashion?
RCCola
  • 373
  • 1
  • 12