[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exclude builtins from command completion

From: František Kučera
Subject: Re: Exclude builtins from command completion
Date: Sat, 18 Jan 2020 20:06:54 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2

Dne 09. 01. 20 v 21:17 kaycee gb napsal(a):
> After playing with options for complete -b/-c, compgen -b/-c, these commands 
> are
> still displayed when I type first 2 letters then <TAB><TAB>
> # sh<TAB><TAB>
> shift shopt show
> I want that it matches just the last one. 


I am dealing with a similar issue. I need a bash-completion that suggest only 
commands from a special path variable (similar to $PATH, may also contain 
multiple directories) and I need to get rid of shell builtins and function 
names i.e. return only executable files on my path.

My current solution is:

while read c; do PATH="$MY_PATH" type -P "$c" &>/dev/null && echo $c; done < 
<(PATH="$MY_PATH" compgen -A command -- "$input")

It is bit complicated but does exactly what I need.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]