Autocomplete commands from history
To autocomplete commands that you have entered in history, follow these steps and you do not have to remember stuff you write in terminal any more, great time saver.
Edit the .inputrc file
$ sudo gedit ~/.inputrc
then add the following lines to the file (file is empty by default):
This is a very useful and powerful feature, that will saves you a lot of time, to find a previous command, enter the first 2 or 3 letters and the Up arrow key, it will autocomplete the command once you have typed it in the past.
To scroll trought the commands you have entered previously, use Up or Down keys on your keyboard.
Enter the history command to display a complete and numbered list of commands from history.
or use less option for scrollable list
$ history | less
or search for ‘something’ in the history file and expect only the matching lines as a outcome.
$ history | grep something
Press Ctrl + r and as you start typing characters one by one, a match of the command entered by you in past will be displayed on the right of the semicolon. Use backspace to delete last characters if you make a mistake.
When you enter the history command, you will get output with number and a line, to run a command with a specific number, use ! followed by the number of the command in the line.
History of commands is stored in hidden file called .bash_history in users home folder, /home/username/.bash_history
$ sudo gedit ~/.bash_history
Use Tab key on your keyboard to autocomplete the command for you, if there are more option, you will be served with a list, otherwise your command will be completed for you, this is one of the biggest time-savers. Alt + c capitalizes the character over the cursor and moves to the end of the word.