When I open Sublime Text from the terminal, I have type in
$ sublime_text <filename>
Is there any way I can change it so I can say something like:
$ subl <filename>
When I open Sublime Text from the terminal, I have type in
$ sublime_text <filename>
Is there any way I can change it so I can say something like:
$ subl <filename>
Avinash is right. Aliases are a way for you to customize the commands by giving them aliases (nicknames). You can use them to remember hard commands or make short names to long commands you just hate to type.
To setup aliases, create an empty file in your home directory and name it .bash_aliases
. Notice the period at the beginning of the name that will make the file hidden. You can use the touch
command (touch .bash_aliases
) to create the file.
Using your favorite text editor open the file you just created and start making your aliases. But there are few things you should keep in mind, the syntax should be:
alias subl='sublime_text'
You can create an alias for commands with arguments. For instance, if you want to use subl
for editing text.txt, you can create the following alias
alias subl='sublime_text text.txt'
Creating an alias and putting it in ~/.bashrc
will do:
printf "\nalias subl=$(which sublime_text)" >> ~/.bashrc && source ~/.bashrc
There are also other methods like creating functions or syslinks but alias is most suitable for this case.
alias
– Avinash Raj Feb 20 '15 at 01:36