As part of a computer programming course (which utilizes Java) that I started taking, we had to install a program called JGRASP. In order to launch the program, I have to type the following in Terminal:
$java -jar jgrasp.jar
This is long and difficult to remember. Luckily, there’s a way to shorten this up and use a custom name that’s easier to remember.
It turns out Ubuntu is set up to handle this type of thing. By creating a file in the Home directory called:
.bash_aliases
Upon starting Terminal, Ubuntu will check for the existence of this file. If it exists, it will use any aliases present.
So, for this specific example, I added the following to my .bash_aliases file:
alias jgrasp=’java -jar jgrasp.jar’
The format of the alias command is rather straightforward:
alias – Invokes the alias Terminal command.
jgrasp – The name of my alias that I decided upon.
=’ ‘ – The equals sign assigns the following path and/or command(s) that are contained in single quotation marks to the alias.
So, now to launch JGRASP, all I have to type in Terminal is:
$jgrasp
Sweet! And, with the ability to assign a path to a specific alias, that means I also don’t have to change directories to launch programs!
1 thought on “Creating aliases (i.e. shortcuts) to launch programs from Terminal”