Combining Command Substitution and Aliases to Create Powerful Commands

Command substitution when combined with aliases can be used to create extremely useful commands. This tutorial shows how you can create a new command which allows you to edit an existing file in FireTXT text editor.

We know that edit command can be used to open FireTXT editor. Supplying a file name as an argument to edit command opens an existing file. If the file supplied as an argument does not exist, it is created. Now let us use the openfile command with edit command. Type the following command and press enter.

edit +|openfile|

You will notice that the open file dialog is displayed. Now browse and open a file. The selected file will get opened in the FireTXT text editor. The "+|" and "|" are the command substitution operators. Here, the filename selected by user is actually passed as an argument to edit command.

Now let us create an alias named editfile so that we don't have to remember the complete command line. Copy and paste the following command and press enter.

alias editfile edit +|openfile "Open File in FireTXT"|
Creating Alias editfile - FireCMD

The above command will create an alias to edit +|openfile "Open File in FireTXT"| named editfile. The argument supplied to openfile i.e. "Open File in FireTXT" is actually the title of open file dialog box.


Open File in FireTXT - FireCMD

Next time when you have to edit a file, you just have to type editfile. Similarly, you can use command substitution and aliases to create many other powerful commands.