Questions tagged [compgen]

A bash built-in command to generate command completions.

compgen is a built-in command used to define automatic tab-completion behaviour for options, filenames and other positional arguments to shell commands.

It's intended to be used from within a shell function generating possible completions, which is then used by the complete builtin to define a completion specification or compspec.

See also: Bash Reference Manual: Programmable Completion

28 questions
1
vote
0 answers

Creating a bash completion from a list with @-signs (compgen)

I want to do a custom bash completion. In the completion are "@"-signs and I don't know how to escape them. The completion works until the @ occurs and then stops the completion. I would be glad for some help. _foo() { local cur prev…
Chris
  • 11
  • 1
1
vote
1 answer

Can I use linux builtin utility compgen within PHP function exec()?

I need to get completion variants for Linux commands using PHP function exec(). I try this: $c = exec('compgen -c pyt'); I except getting something like this python3.5m python3.5 python2.7 python2 python3 python3m python But instead I get an…
hungl
  • 101
  • 8
1
vote
1 answer

compgen does not descend into directories

I have defined a bash_completion script. There are certain cases in which I want to fallback to the basic file-based completion that happens by default for most commands. To do this I am using compgen, but I can't get it to descend into…
Viper Bailey
  • 11,518
  • 5
  • 22
  • 33
1
vote
1 answer

Bash : Autocompletion, echo and cursor movement

I am trying to code an autocomplete script. It should also outputs some description. I have one function that manage the autocompletation AND the fetching of the description. The autocompletion related part works fine but i have an issue when i want…
Koller14
  • 11
  • 1
0
votes
0 answers

How to add "free" user input to bash auto complete script?

I wrote a CLI using bash script to enable the user the option of using TAB to auto complete commands. My issue is that I want to incorporate the use of flags with free input from the user, i.e.: the user may choose a command from a given list of…
AHM
  • 15
  • 3
0
votes
1 answer

Bash compgen not parsing wildcard correctly

My goal is to list all files matching foo/** whereas this folder contains files (1 and 2) and subdirectories (bar) with files: foo/ ├── 1 └── bar └── 2 Bash has a build-in called compgen. I found out about this function in this answer. Using…
0
votes
0 answers

compgen not displaying all expected suggestions

I need to add some bash shell completion with words read from a json file: ... { 'bundle': 'R20_B1002_ORDERSB1_FROMB1', 'version':'0.1', 'envs': ['DEV','QUAL','PREPROD2'], }, { 'bundle': 'R201_QA069_ETIQETTENS_FROMSAP', …
Loko
  • 120
  • 9
0
votes
1 answer

How to use bash `compgen` with my own script options?

I am new to compgen and want to use it for a script I am working on. This script can have "commands" and "options" as arguments like so: script add "value" script --path "/a/file/path" add "value" # and others I wrote a completion script that looks…
TimFinnegan
  • 583
  • 5
  • 17
0
votes
0 answers

display available options without completing

I was wondering if it's possible to make compgen (complete) only display possible options without completing. for example with COMPREPLY=( $( compgen -W "--option1 --option2" -- $cur )) --option1 --option2 will be suggested but -- will be added to…
Tor Tor
  • 35
  • 6
0
votes
1 answer

Access bash tab completions from script

You normally interact with bash completion by pressing the tab key in your terminal. I would like to interact with it within a script of mine. Essentially, I would like a function/command that answers the question "If I pressed tab with text xyz…
Drew
  • 12,578
  • 11
  • 58
  • 98
0
votes
1 answer

Spaces and suffixes in bash complete()

I have two difficulties with compgen shell builtin. I try show it in simple bash _filedir-like (using ls) code: _myfiledir(){ path="$cur" prefix=`echo /$path | grep -o "[0-9a-Z\-+_/]*/"` sufix=`echo /$path | grep "/[0-9a-Z\-+_]*$" | grep -o…
Stepan Loginov
  • 1,667
  • 4
  • 22
  • 49
0
votes
2 answers

Bash: compgen How to get rid of Warning message [option may not work as you expect]?

I am making a simple bash completion program using compgen however when using compgen -F option, the warning message keep prompt out and break my list of work I am using Ubuntu 12.04. How can I get rid of this or debug it?…
TheOneTeam
  • 25,806
  • 45
  • 116
  • 158
-1
votes
1 answer

Compgen and make: is there a way to compgen the make recipes?

I am running compgen -c make in BASH on mac and am getting the following return values: makepqg makepqg makepqg make makeinfo makepqg makepqg But what I want and should? be getting (and do get when completing) is: foo bar biz baz Which represent…
Chris
  • 28,822
  • 27
  • 83
  • 158
1
2