Terminal command autocomplete

27,245

Solution 1

You can auto-complete a partially typed terminal command using Page Up, which does a reverse search of previously typed commands.

To enable this terminal functionality, i.e. to use Page Up to go match further up in terminal command history, edit the file /etc/inputrc:

gksudo gedit /etc/inputrc

find the lines:

# alternate mappings for "page up" and "page down" to search the history
# "\e[5~": history-search-backward
# "\e[6~": history-search-forward

remove the # to uncomment the two lines:

# alternate mappings for "page up" and "page down" to search the history
"\e[5~": history-search-backward
"\e[6~": history-search-forward

and save the file.

For example typing in the terminal:

ge Page Up

....now auto-completes to:

gedit the_doc_i_open_previously.txt

Solution 2

You can use the key to scroll through your history. Using Ctrl+R you can search through the history.

Share:
27,245

Related videos on Youtube

Edhoari
Author by

Edhoari

Updated on September 18, 2022

Comments

  • Edhoari
    Edhoari almost 2 years

    I'm currently trying to switch from OpenSUSE to Ubuntu as my main OS. While most of opensuse features is there in ubuntu, there is one feature that doesn't. In Opensuse, I can always use Ctrl+Up to autocomplete the command line using previously typed command. That feature is very useful for me as it allows me to work faster without having to retype long command.

    Can anyone provide a way to enable this on Ubuntu?

    Thank you

  • dodohjk
    dodohjk almost 10 years
    might have to restart the terminal too for the functionality to take place
  • zeal
    zeal over 6 years
    @benj do we have a similar thing for mac user as mac os also uses bash shell.