Score:7

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

ca flag

Is there any feature in a terminal to make a list of favorites commands, using shortcuts, or some type of utility, something integrated into the terminal?

oldfred avatar
cn flag
Have you reviewed: http://linuxcommand.org/tlcl.php and many others? I use up arrow a lot to rerun or edit a previous command. If more than a couple of lines, I often create my own bash script. https://help.ubuntu.com/community/CommandLineResources & see section on saving on typing: https://help.ubuntu.com/community/UsingTheTerminal
Score:8
es flag

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).

danilo avatar
ca flag
is it possible to use a file called .favorites for example? I don't want to mix functions in .bashrc with my favorites.
HuHa avatar
es flag
You can include another file from your `.bashrc` with the `source` command, in this case `source .favorites`. Unlike calling it without `source`, this executes the content in the context of the _current_ shell which is important here; otherwise you'd call it, add the aliases to the new shell that you just called, that shell would exit, and the aliases would be immediately forgotten.
ojdo avatar
co flag
Instead of `.favorites`, better name it `.bash_aliases`. If present, that file gets sourced in `.bashrc` by default, at least on Ubuntu and is the default location to put user-defined aliases.
Score:2
cn flag

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
Score:1
br flag

It hasn't mentioned before here, but it might be useful to know that under bash by default command history is saved to ~/.bash_history and lines can be copied and saved out of here.

Score:1
cn flag

I'll vote for customing our terminal to let it learn which command used most frequently. And here the tips:

1.install zsh and set it as the default Shell environment.

# install `zsh`
sudo apt install zsh
# be sure `zsh` is installed successfully
which zsh
# set `zsh` as the default Shell
chsh -s /usr/bin/zsh

2.install Oh My Zsh

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

3.configure zsh theme(optional)

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k

4.add zsh-autosuggestion

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

after the installation, we should set plugins=(git zsh-autosuggestions zsh-syntax-highlighting) in ~/.zshrc, then restart Shell.

5.install Terminator(optional)

sudo apt install terminator

\o/ finish! Just have a try, and you will love it!

And be friendly to your up, down, left, right keys.

Score:1
cn flag

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.

Score:1
cn flag

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/

danilo avatar
ca flag
that's great!! some more explanations: https://stackoverflow.com/questions/2762994/define-an-alias-in-fish-shell
Score:0
cn flag

There is a small app called Marker that does exactly what you want. While your edited/polished command chain is on the command line you bookmark it with CTRL+k. It allows you to add some description too. to recall one of your bookmarked commands press CTRL+SPACE Type marker remove to remove a user-defined command

to install

git clone --depth=1 https://github.com/pindexis/marker ~/.marker && ~/.marker/install.py

main ref: https://github.com/pindexis/marker

also see this link for explanation.

The great thing about this app is that it offers almost all Linux commands -- including their flags and option -- as a template for you to complete. Just type the name of the command and press CTRL+SPACE.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.