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 Answers4

3

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
  • 744
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
  • 40,956
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
  • 37,534
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нιη
  • 36,350