Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an account on a shared machine, and cannot access /usr/bin, where there are many programs which I never use.

I'd like tabbing to ignore many of these programs. For example, I'd like on<TAB> to complete to oneprog, but there are other matches.

~> on
on_ac_power           oneprog          onto2vocabularyclass

Is there a way to hide the other two matches, short of creating a mirror of /usr/bin?

share|improve this question
    
If you can't access /usr/bin just remove it from your $PATH and then bash shouldn't autocomplete from it – Josh Nov 15 '15 at 16:41
up vote 1 down vote accepted

Assuming Bash...

You can define your own autocomplete rules for options/arguments, using complete. You can define filename suffices that are ignored in arguments by exporting variable $FIGNORE.

However, I don't think you can alter the way Bash resolves program names.

You could, of course, alias the program you want to run, so you don't have to type so much:

[me@host ~]$ alias on=oneprog
[me@host ~]$ on

You could (if you were feeling silly) alias the Bash builtin, command and use complete to define the arguments it will accept (your list of nice programs), and then always remember to type your alias before your real command.

[me@host ~]$ alias run=command
[me@host ~]$ complete -W "ls cd" run
[me@host ~]$ run ls

See also How to have autocomplete ignore a specific completion.

share|improve this answer
    
Thanks, that link was especially useful. As much as I'd normally keep pushing, my reaction to "don't do it, just use an alias" seems to be identical to the author of the linked question, who eventually accepted the answer. – Gyppo Apr 24 '14 at 10:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.