Difference between revisions of "Aliases in .bashrc"
Views
Actions
Namespaces
Variants
Tools
imported>DeMus |
imported>Dalto (Make more generic and update obsolete commands) |
||
Line 7: | Line 7: | ||
An '''alias''' is a ''substitute for a (complete) command''. It can be thought of as a shortcut. | An '''alias''' is a ''substitute for a (complete) command''. It can be thought of as a shortcut. | ||
'''.bashrc''' is found in the ''home folder'' of a user ( ~ ) . It is a hidden file, to see it | '''.bashrc''' is found in the ''home folder'' of a user ( ~ ) . It is a hidden file, to see it show hidden files in your file manager or use '''ls -a''' | ||
== Backup your current .bashrc == | == Backup your current .bashrc == | ||
It | It can be useful to backup the ~/.bashrc before editing it, as it allows one to be able to easily recover from the unexpected. | ||
To make a backup of your current .bashrc . Open a terminal and type - | To make a backup of your current .bashrc . Open a terminal and type - | ||
Line 25: | Line 23: | ||
== Note == | == Note == | ||
Any changes made to the .bashrc will have no effect on any currently open | Any changes made to the .bashrc will have no effect on any currently open terminal windows. To test newly updated changes in your .bashrc open a new terminal or use the command: | ||
source .bashrc | source .bashrc | ||
== Aliases Examples == | |||
== Aliases == | |||
Aliases can turn a complex command string into a simple custom made command that one can type in the Terminal. | Aliases can turn a complex command string into a simple custom made command that one can type in the Terminal. | ||
Line 48: | Line 42: | ||
To upgrade packages installed from the AUR via | To upgrade packages installed from the AUR via yay, the command used is '''''yay -Syu --aur''''' | ||
This can be aliased with- | This can be aliased with- | ||
alias aup=" | alias aup="yay -Syu --aur" | ||
Line 81: | Line 75: | ||
== Conclusion == | == Conclusion == | ||
This list is not comprehensive. | This list is not comprehensive. Almost anything that is commonly used can be shortened with an alias | ||
== See Also == | |||
[https://www.gnu.org/software/bash/manual/html_node/index.html Bash documentation] | |||
[[Category:Contents Page]] | [[Category:Contents Page]] |
Revision as of 18:45, 18 May 2019
What's .bashrc? What is an alias?
.bashrc is the configuration file for bash, a linux shell/command interpreter.
An alias is a substitute for a (complete) command. It can be thought of as a shortcut.
.bashrc is found in the home folder of a user ( ~ ) . It is a hidden file, to see it show hidden files in your file manager or use ls -a
Backup your current .bashrc
It can be useful to backup the ~/.bashrc before editing it, as it allows one to be able to easily recover from the unexpected.
To make a backup of your current .bashrc . Open a terminal and type -
cp ~/.bashrc ~/.bashrc.bak
The original .bashrc can be restored with -
cp -i ~/.bashrc.bak ~/.bashrc
Note
Any changes made to the .bashrc will have no effect on any currently open terminal windows. To test newly updated changes in your .bashrc open a new terminal or use the command:
source .bashrc
Aliases Examples
Aliases can turn a complex command string into a simple custom made command that one can type in the Terminal.
The following can be added to the .bashrc file.
For updating your system
To upgrade the system via pacman, the command used is sudo pacman -Syu
This can be aliased in .bashrc with-
alias pacup="sudo pacman -Syu"
To upgrade packages installed from the AUR via yay, the command used is yay -Syu --aur
This can be aliased with-
alias aup="yay -Syu --aur"
For editing commonly used files
To edit .bashrc itself and automatically reload bash configuration file (so that changes made to .bashrc can be implemented in current terminal session)
alias bashrc="nano ~/.bashrc && source ~/.bashrc"
To edit /etc/fstab
alias fstab="sudo nano /etc/fstab"
To edit /etc/default/grub
alias grub="sudo nano /etc/default/grub"
To update GRUB
To update your grub bootloader using the sudo update-grub
alias grubup="sudo update-grub"
Conclusion
This list is not comprehensive. Almost anything that is commonly used can be shortened with an alias