Skip to main content
improved spelling and punctuation
Source Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

In Bashbash, it's easy enough to set up customized completion of command arguments using the complete built-in. For example, for a hypothetical command with a synopsis of foo --a | --b | --c,

foo --a | --b | --c

you could do complete -W '--a --b --c' foo.

complete -W '--a --b --c' foo

You can also customize the completion you get when you press Tab at an empty prompt using complete -E, for example complete -E -W 'foo bar'. Then, pressing tab at the empty prompt would suggest only foo and bar.

How do I customize command completion at a non-empty prompt? For example, if I write f, how do I customize the completion to make it complete to foo?

(The actual case I'd like is locTABlocalc. And my brother, who prompted me to ask this, wants it with mplayermplayer.)

In Bash, it's easy enough to set up customized completion of command arguments using the complete built-in. For example, for a hypothetical command with a synopsis of foo --a | --b | --c, you could do complete -W '--a --b --c' foo.

You can also customize the completion you get when you press Tab at an empty prompt using complete -E, for example complete -E -W 'foo bar'. Then, pressing tab at the empty prompt would suggest only foo and bar.

How do I customize command completion at a non-empty prompt? For example, if I write f, how do I customize the completion to make it complete to foo?

(The actual case I'd like is locTABlocalc. And my brother, who prompted me to ask this, wants it with mplayer.)

In bash, it's easy enough to set up customized completion of command arguments using the complete built-in. For example, for a hypothetical command with a synopsis of

foo --a | --b | --c

you could do

complete -W '--a --b --c' foo

You can also customize the completion you get when you press Tab at an empty prompt using complete -E, for example complete -E -W 'foo bar'. Then, pressing tab at the empty prompt would suggest only foo and bar.

How do I customize command completion at a non-empty prompt? For example, if I write f, how do I customize the completion to make it complete to foo?

(The actual case I'd like is locTABlocalc. And my brother, who prompted me to ask this, wants it with mplayer.)

In bashBash, it's easy enough to set up customized completion of command arguments using the complete built-in. For example, if, for a hypothetical command with a synopsis of foo --a | --b | --c, you could do complete -W '--a --b --c' foo.

You can also customize the completion you get when you press Tab at an empty prompt using complete -E, e.g., for example complete -E -W 'foo bar'. Then, pressing tab at the empty prompt would suggest only foo and bar.

How do I customize command completion at a non-empty prompt? E.g. How do I customize command completion at a non-empty prompt? For example, if I'm sitting at:

anthony@Zia:~$ f

I write f, how do I customize the completion so pressing tab would alwaysto make it complete to foo?

(The actual case I'd like is locTABlocalc. And my brother, who prompted me to ask this, wants it with mplayer).)

In bash, it's easy enough to set up customized completion of command arguments using the complete built-in. For example, if, for a hypothetical command with a synopsis of foo --a | --b | --c, you could do complete -W '--a --b --c' foo

You can also customize the completion you get when you press Tab at an empty prompt using complete -E, e.g., complete -E -W 'foo bar'. Then pressing tab at the empty prompt would suggest only foo and bar.

How do I customize command completion at a non-empty prompt? E.g., if I'm sitting at:

anthony@Zia:~$ f

how do customize completion so pressing tab would always complete to foo?

(The actual case I'd like is locTABlocalc. And my brother, who prompted me to ask this, wants it with mplayer).

In Bash, it's easy enough to set up customized completion of command arguments using the complete built-in. For example, for a hypothetical command with a synopsis of foo --a | --b | --c, you could do complete -W '--a --b --c' foo.

You can also customize the completion you get when you press Tab at an empty prompt using complete -E, for example complete -E -W 'foo bar'. Then, pressing tab at the empty prompt would suggest only foo and bar.

How do I customize command completion at a non-empty prompt? For example, if I write f, how do I customize the completion to make it complete to foo?

(The actual case I'd like is locTABlocalc. And my brother, who prompted me to ask this, wants it with mplayer.)

Notice removed Reward existing answer by derobert
Bounty Ended with mr.spuratic's answer chosen by derobert
Notice added Reward existing answer by derobert
Bounty Started worth 200 reputation by derobert
Notice removed Draw attention by CommunityBot
Bounty Ended with no winning answer by CommunityBot
Notice added Draw attention by Braiam
Bounty Started worth 50 reputation by Braiam
Tweeted twitter.com/#!/StackUnix/status/496732837325049856
Source Link
derobert
  • 113.2k
  • 20
  • 242
  • 289

How to customize Bash command completion?

In bash, it's easy enough to set up customized completion of command arguments using the complete built-in. For example, if, for a hypothetical command with a synopsis of foo --a | --b | --c, you could do complete -W '--a --b --c' foo

You can also customize the completion you get when you press Tab at an empty prompt using complete -E, e.g., complete -E -W 'foo bar'. Then pressing tab at the empty prompt would suggest only foo and bar.

How do I customize command completion at a non-empty prompt? E.g., if I'm sitting at:

anthony@Zia:~$ f

how do customize completion so pressing tab would always complete to foo?

(The actual case I'd like is locTABlocalc. And my brother, who prompted me to ask this, wants it with mplayer).