13

I remembered bash can do the following:

Suppose there are 3 files: a,b,c in the current directory, when I input:

$> somecommand *

and then press a key or key combinations or a key sequence, the wildcard * online expanded as:

$> somecommand a b c

but I cannot remember and cannot google out the key sequence! help!

1

3 Answers 3

9

If it is not, you would need to bind glob-expand-word to a key sequence. Typically by by adding something like:

"\C-x*": glob-expand-word

to .inputrc.

To check current status issue something like:

bind -P | grep glob-expand-word

Where result might be:

glob-expand-word can be found on "\C-x*".

Which would mean:

Ctrl-x*

This also most likely work:

Ctrl-xCtrl-*


Have a look at bind -P and manual(s) for other niceties.

3

It seems you are looking for list completion. In the man page for bash:

 COMP_TYPE
     Set to an integer value corresponding to the type of completion
     attempted  that caused a completion function to be called: TAB,
     for normal completion, ?, for listing completions after succes‐
     sive  tabs, !, for listing alternatives on partial word comple‐
     tion, @, to list completions if the word is not unmodified,  or
     %,  for  menu  completion.   This variable is available only in
     shell functions and external commands invoked by  the  program‐
     mable completion facilities

So it depends on the completion function for somecommand how this is completed.

3

If you are using set -o vi in bash, then Ctrl-X* doesn't work.

In set -o vi mode you need to use Esc* instead.

3
  • 1
    It might be worth noting that once you're in normal mode, <C-X>* will work, but the <C-X> is superfluous and does nothing. (<C-X> doesn't decrement as it does in vi.) If you're in insert mode, then you have to use <Esc> first.
    – wchargin
    Commented Apr 28, 2015 at 4:36
  • This is great. What are these called? bash keyboard shortcuts? Is there some documentation where I can find more of these keyboard shortcuts?
    – wisbucky
    Commented Feb 17, 2016 at 21:53
  • 2
    @wisbucky: A bit late, but for anyone else, GNU Readline is responsible for these. When you have a slow day, read through the EDITING COMMANDS section of man readline. I've been using Bash for 10 years and I'm still learning new ones. Commented Apr 30, 2019 at 1:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .