[HOW TO] create terminal shortcuts

I would not recommend using too many of these. Many commands should be remembered and memorized for the best workflow.
But in the terminal, some commands can get long and complex or tedious and a person will waste some brain space trying to memorize too much. Especially if you use a complex command only once in a while.
In such cases, a terminal shortcut can be a time and brain saver.

To create a shortcut for terminal, open your ~/.bashrc file or your Shell Resource file (in my case, ~/.zshrc) if using something else like ZSH or Fish.
Add a line to it that has alias followed by the new shortcut, followed by the command you are shortcutting in quotes.
For example, one of mine for batch converting all .png files in a directory to .svg:

for a in $(find `pwd` -type f -name '*.png'); do inkscape -z -f "$a" -l "${a%.png}.svg"; done

Would look like:

alias pconvs="for a in $(find `pwd` -type f -name '*.png'); do inkscape -z -f "$a" -l "${a%.png}.svg"; done"

For simpler and more familiar examples:
alias upd="sudo apt update"
alias upg="sudo apt upgrade"

Once the resource file is saved, you can begin to use them...

upd && upg

OR you can:
alias rmv="sudo apt remove --purge"

Then if you wish to remove and purge for Gimp, it would look like

rmv gimp

Let your imagination carry your forward. Just be sure to not get carried away forward, lest you find yourself forgetting simple commands and backsliding into novice territory.


Hi, nice tutorial. I've just realized that while I have Inkscape installed (I believe as part of the default Zorin installation) this command does not work for me as inkscape cannot be found. Is this normal/expected or are they meant to be installed separately?

I often point out that grabbing the "latest and greatest" is not the greatest practice.
This is one example of it. Due to deprecations and regressions, the inkscape version needed is Inkscape 0.92.5
Inkscape must not be install using either Snap or Flatpak.
These isolate it from the system, disallowing access.

If you have no inkscape installed or if you have removed currently installed versions (snap remove inkscape or flatpak remove inkscape)
To install Inkscape,

sudo apt install -y inkscape

should do the trick.

1 Like

Indeed it was installed as a flatpak, I was able to get things working following your steps. I got this message in the terminal when I run it, I assume it has no importance but just to mention it:

Gtk-Message: 10:50:08.584: Failed to load module "canberra-gtk-module"

I still get a prompt to choose some options and the output is indeed an svg. Although I don't have suitable images for vectors so the output file is quite large, is that to be expected?

It's not of importance, but you can fix it by;

sudo apt install libcanberra-gtk3-module

It is, if you use just any image. I use the above command for creating Icon sets.

Thank you both for the help :slight_smile:

On the topic of creating terminal shortcuts: would you say it's best practice to have a dedicated .bash_aliases or .bash_profile for things like this? I personally like having them because I can easily find what I'm looking for when I need to update these aliases. As I'm not particularly fluent in shell scripting, not having to navigate through dozens of lines of code makes things easier for me.

1 Like

I would say that is a good practice. It helps keep things organized and useful to keep track of user-made changes.

I think this counts as a useful suggestion from you, rather than a question.:wink: