OhmArchitect
OhmArchitect

Reputation: 131

How to cd open / autocomplete a folder that ends in a specific phrase

I have a folder with subfolders named like this:

1122334 important things
1122335 less important things
1122336 notes
1122337 pictures of kittens

etc

The numbers at the beginning are date codes. If it was up to me, I would put the date codes at the end, but it isn't.

In bash, I'd like to do something like this:

$ cd *pictu<tab>

and get this

$ cd 1122337\ pictures\ of\ kittens/

Is there a simple way to do this, or something I can put in my .bashrc to make this possible?

Upvotes: 2

Views: 363

Answers (1)

OhmArchitect
OhmArchitect

Reputation: 131

from terdon: How to cd open / autocomplete a folder that ends in a specific phrase

As far as I know, there is no way of making bash autocomplete *pictu here are some workarounds:

  1. Don't use TAB, just cd directly using wildcards before and after the pattern:

    $ cd *pictu*
    

    That will move you into the first directory whose name contains pic.

  2. Use two wildcards and then TAB:

    $ cd *pictu*<TAB>
    

    That should expand to cd 1122337\ pictures\ of\ kittens/

  3. Use another shell. zsh has a cool feature, you can do:

    ➜ cd pictu<tab>
    

    and that expands to ➜ cd 1122337\ pictures\ of\ kittens/.

Upvotes: 1

Related Questions