1

I want completion like in emacs that if there is only a sole completion to the command you are typing, than you don't need to type it all.

For example:

package ins

is enough instead of typing the whole:

package install

Is there a package or script that does that?

I am looking for a solution that doesn't require hitting the tab key but rather hitting the enter straight away and having a script do the auto completion before running the command.

Eden K
  • 21
  • 4

4 Answers4

1

bash does that by default if the bash-completion package is installed, just type e.g.

> apt i

press Tab ↹ and you'll get

> apt install

If there are multiple matches, pressing Tab ↹ another time will display a list of them., e.g.

> ap

Tab ↹

nothing happens

Tab ↹

aplay                         apport-bug                    apt                           aptdcon                       aptitude-curses
aplaymidi                     apport-cli                    apt-add-repository            apt-extracttemplates          aptitude-run-state-bundle
apm_available                 apport-collect                apt-cache                     apt-ftparchive                apt-key
apparmor_parser               apport-unpack                 apt-cdrom                     apt-get                       apt-mark
apparmor_status               appres                        apt-config                    aptitude                      apt-sortpkgs
applygnupgdefaults            apropos                       aptd                          aptitude-create-state-bundle  
dessert
  • 39,982
  • Thank you for you fast response, I am aware of this but am looking for auto completion without the need of pressing the tab key. – Eden K Sep 18 '17 at 06:51
  • @EdenK You're welcome! Did I understand your question correctly, does this solve your problem? If not please edit your question and add details about what you want. – dessert Sep 18 '17 at 06:52
  • I am looking for a solution in which I for instance can type "package ins" and hit enter rather than hitting the tab key. I know it only takes a second to hit the tab key but I am curious if such solution exists. – Eden K Sep 18 '17 at 06:54
  • @EdenK Please edit your question and add this information there! – dessert Sep 18 '17 at 06:56
  • @Edenk you could use fish shell – George Udosen Sep 18 '17 at 07:06
  • Same comment for your answer "OP wants RETURN to complete and execute the command in one step" not with TAB :D – αғsнιη Sep 18 '17 at 11:18
  • @αғsнιη In my defense, I wrote this when OP had not yet made that clear. ;D However, other people finding this question will probably want that, so I'll leave it this way. – dessert Sep 18 '17 at 11:45
1

I believe fish shell would be in order here. To install:

  1. Download from here

  2. Then use this tutorial to assist you learning.

George Udosen
  • 36,677
1

You need to install bash-completion. If already installed, you need to source it:

source /etc/bash_completion

You can add it in your .bashrc file. You can add custom completions in /etc/bash_completion.d/

Carl
  • 724
  • 3
  • 5
1

If your problem is you want Bash Completion, please refer to the post Terminal autocomplete doesn't work properly, else if you need Enter become as like Tab ↹ and also execute that command immediately, then you need to add the command below in your ~/.bashrc and then source ~/.bashrc it.

bind 'RET:"\C-i\C-j"'

The RET is shortened for RETURN; You could use "\C-M" instead as well which is stands for Ctrl+M.

αғsнιη
  • 35,660