Adds how_2_create_bash_alias.md
This commit is contained in:
parent
a07c95882b
commit
51b25c9884
|
@ -0,0 +1,33 @@
|
|||
# How to Create a Bash Alias
|
||||
|
||||
1. Open your .bashrc file
|
||||
|
||||
Using a text editor, open your .bashrc file, which is typically found in your home directory.
|
||||
|
||||
> vim ~/.bashrc
|
||||
|
||||
### Why .bashrc?
|
||||
|
||||
This file is loaded whenever a new bash instance is started and should included bash-specific commands, like aliases.
|
||||
|
||||
2. Create the alias
|
||||
|
||||
The anatomy of an alias is as follows:
|
||||
|
||||
> alias alias_name="text to alias"
|
||||
|
||||
Here is a common example:
|
||||
|
||||
> alias ll="ls -lha"
|
||||
|
||||
This means that whenever you type ll, it will be as if you had typed ls -lha.
|
||||
|
||||
It is basically a substitution, so if you have an alias set up like this: alias g="git". Then you can type g pull, which will execute git pull.
|
||||
|
||||
3. Reload your bashrc
|
||||
|
||||
If you'd like to use your alias, you can either open a new bash shell, or source your .bashrc file in your current shell using:
|
||||
|
||||
> source ~/.bashrc
|
||||
|
||||
This basically executes everything in your .bashrc file as if you had typed each command.
|
Loading…
Reference in New Issue