Question

I would like to configure my bash shell to expand partially entered tree structure like it does emacs "minibuffer-complete" command.

Imagine I have two folders, foo1 and foo2. foo1 contains a subfolder sub1, and foo2 contains subfolder wow. So I have:

foo1/sub1/

foo2/wow/

Now when opening a file in emacs if I type

f/w

and press TAB it will automatically expand it to "foo1/wow/".

I would like to have a similar functionality in bash. Any ideas?

Was it helpful?

Solution

Whilst I don't know how to do this in bash, or even if it's possible, I know that if you change your shell to zsh, it can be done.

It's not enabled by default, and I'm not sure how to enable it either, but I use the zsh grml config, which enables the kind of expansion you're talking about.

Zsh, especially combined with said config, also has many other helpful features.

If you're not willing to change shell, then this isn't a helpful answer I'm afraid.

OTHER TIPS

you can have it the other way around, using emacs M-x shell command. It open a Shell buffer with an autocompletion like in the minibuffer

Disclosure: I am the author of the project

I have written the completion functions necessary to enable such completion in bash: https://github.com/sio/bash-complete-partial-path

Hope you'll find this project useful

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top