Cycle through completion in the terminal?

The terminal shows ghost completion candidate when I type some letters, and I could use arrow keys to select a word or all. But what if I want to see other candidates?

For example, imagine that I have typed sudo cat 123, sudo coala, and sudo dog before, and now I want to run sudo coala. If I type su, I may see sudo dog as the ghost candidate. Even if I type sudo c, it could still show sudo cat 123. What is the way to see other possible candidates after typing some letters? Also, is there anyway to just type d and select sudo dog? I mean, so many commands in the history start with sudo, so I do not want to start by typing sudo.

CTRL + R, then start typing some characters, and then continue to use CTRL + R to keep cycling through the matches (of the characters you typed) from your shell history.


For example. “I think it was a recent sudo command?”

  1. CTRL + R
  2. Then start typing sud
  3. Then continue to hit CTRL + R to keep cycling if the first result is not what you want

Another example. “Hm, it was something to do with coala?”

  1. CTRL + R
  2. Then start typing coa
  3. Then continue to hit CTRL + R to keep cycling if the first result is not what you want

Use arrow keys. Up, to be exact.

1 Like

The “ghost completion” is called auto suggestion. Pressing right selects that completions, pressing ctrl+right selects one more word from that completion in case you want to alter the parameters or something.

If you type something and press up, it searches your command history for things that you already typed. It doesn’t need to be in the beginning of command, for example typing ca and pressing up would match sudo cat /etc/default/grub

If you want more completions, press tab. If you write something like

cat -
And press tab, it will show you the possible flags you can use with that command. If you type just

cat
And press tab, it starts completing the possible paths to the target file.

If you type just a partial command, for example gnome-, pressing tab cycles through different commands that begin with the string you typed.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.