1

In brief

Bash prompt has the autocomplete feature when we hitting tab. When there are multiple outcomes, hitting tab will display the candidate list.

I want to enter the initials of folder/filename and hit tab to complete as in programming autocomplete.

In details

For example we have folder foods as below

$ ls ./foods
apple apple-cake banana cherry

When we type in ap - hit tab, two folder listed i.e.

apple apple-cake

I'm looking for way to enter initials for apple-cake as a c, and hit tab to get autocomplete as apple-cake

Is it possible and how to?

4
  • 2
    In default bash behaviour the short answer is no, what you're asking is not possible. You could try renaming your folders somehow (ie a-apple, ac-apple-cake) to try to do what you are asking but this might not fit with other considerations you may have for naming conventions. You can extend bash completion yourself through the complete command and clever use of "switches" (ie -a for apple, -ac for apple-cake, etc). Writing your own Bash Completion Function
    – GrannySez
    Oct 7, 2016 at 3:56
  • 2
    Zsh can do this. Consider switching. :)
    – muru
    Oct 7, 2016 at 4:53
  • @muru May you list Zsh homepage - is it www.zsh.org?
    – Nam G VU
    Oct 7, 2016 at 5:12
  • 3
    Yes, but on Ubuntu you can just do sudo apt-get install zsh
    – muru
    Oct 7, 2016 at 6:06

0

You must log in to answer this question.

Browse other questions tagged .