-1

There are several commands I often use, some of them are longer and it's a bit of a hassle to type them out (or look for them via arrow-up or CTRL-R) each time.

Are there ways (built-in or apps) to link them to a certain key combo, or some kind of favorites manager that allows easy access?

kraligor
  • 101

1 Answers1

0

This all depends on the shell, of course.

For bash, you can use an alias:

alias foo="ls --color=always -l -Z --my-favourite-option"

Now when you enter foo on the command line, bash will replace it with that long ls command line. This is valid until you exit your shell; if you wish for it to be permanent, you can add that command to ~/.bashrc, which will be executed by every started bash shell.

You can also create shortcuts by way of a .inputrc file. E.g., if you enter the following in a file ~/.inputrc:

"\C-\M-e": "echo this is a test"

and then restart the shell, then whenever you hit control-alt-e, readline will enter that command.

Note, however, that since the inputrc file is parsed by libreadline (rather than by bash), it is used by every program that uses libreadline; so things like gdb and lftp will use it too, where running shell commands may not work.