I want to set up a shorter name as an alias of this command:
sudo -i pantheon-files $(pwd)
For example I want to type sfoh
(for sudo file open here) and it should run this command.
How do I do this?
Simply run this command:
alias key='your long command'
Add the commands as described above into .bash_aliases
.
Open scratch with the Applications menu and edit the file .bash_aliases
in your home directory. It's a hidden file, so press Ctrl+H to see it.
Or you can type in the terminal: scratch-text-editor ~/.bash_aliases
Then add into it the following line:
alias key='your long command'
To apply the changes immediately run this command:
source ~/.bashrc
alias key=...
doesn't take options, like the directory in this example, unless it does and I'm just being silly.
Creating an alias is quite simple, and it opens a whole realm of possibility for adding shortcuts to your terminal usage.
Open up ~/.bashrc
in your favourite text editor, and add the following to the end:
alias <string>='<full and long command>'
Again, adding to the end of the .bashrc
file:
alias sfoh='sudo -i pantheon-files $(pwd)'
This does not require a restart to take effect, but it will require a new terminal window to be opened so that the ~/.bashrc
file can be parsed again.
~/.bash_aliases
is the default I believe.
.bashrc
. I've never tried .bashrc_aliases
, so YMMV
Commented
Jun 30, 2015 at 21:36