Is there any feature in a terminal to make a list of favorites commands?

Solution 1:

You can define aliases:

alias l='ls -al'
alias tlc='toolongcommand'

(you can put that into your .bashrc)

and you probably know about tab completion (if you never heard of that, I can imagine why you are asking).

Solution 2:

I would recommend HSTR (formerly known as history suggest box. HSTR (HiSToRy) is a command line utility that brings improved bash/zsh command completion from the history. It aims to make completion easier and more efficient than Ctrl-r.

HSTR can also manage your command history (for instance you can remove commands that are obsolete or contain a piece of sensitive information) or bookmark your favorite commands.

I use it in particular for saving favorites.

To install

sudo add-apt-repository ppa:ultradvorka/ppa && sudo apt-get update && sudo apt-get install hstr && hstr --show-configuration >> ~/.bashrc && . ~/.bashrc

Solution 3:

In Bash those are functions

A Bash function is essentially a set of commands that can be called numerous times. The purpose of a function is to help you make your bash scripts more readable and to avoid writing the same code repeatedly. Compared to most programming languages, Bash functions are somewhat limited.

You can create a function "f1" that would execute a command with specific options and a function "f2" that does the same command with a 2nd set of default options.

Solution 4:

If interested, you could also try different shell, fish.

Fish has great auto-completion by default. Commonly run (or favorite) commands can be tab completed quite easily. This is also a useful feature for figuring out command sequences you don't have memorized, but remember parts of. You can type a portion of the sequence and use the ↑ and ↓ keys to go through you command history.

# install fish
apt install fish

# command to enter the fish shell
fish

# if you want set fish as your default shell 
# (log out and back in for the change to take place
chsh -s /usr/bin/fish

# switch back to bash as default with
chsh -s /bin/bash

And like bash, you can create aliases in fish. A handy way to do it in the terminal:

alias command_name "your command"
funcsave command_name

The functions are located in $HOME/.config/fish/functions/