Difference between revisions of "Translations:Aliases in .bashrc/1/en"

Importing a new version from external source
(Importing a new version from external source)
 
(Importing a new version from external source)
Tags: Mobile web edit Mobile edit
 
Line 1: Line 1:
==What's .bashrc? What is an alias?==
==What's a bashrc? What's a alias?==
* '''.bashrc''' is the ''configuration file'' for bash, a linux shell/command interpreter.
* '''.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.
* 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'''
* '''.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 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 execute
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 execute:
{{UserCmd|command=cp ~/.bashrc ~/.bashrc.bak}}
{{UserCmd|command=cp ~/.bashrc ~/.bashrc.bak}}
The original .bashrc can be restored with by executing
The original .bashrc can be restored with by executing
{{UserCmd|command=cp -i ~/.bashrc.bak ~/.bashrc}}
{{UserCmd|command=cp -i ~/.bashrc.bak ~/.bashrc}}
==Note==
==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:
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:
{{UserCmd|command=source .bashrc}}
{{UserCmd|command=source ~/.bashrc}}
== Aliases Examples ==
== Aliases Examples ==
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.  
The following can be added to the .bashrc file.
=== Standard syntax ===
Creating aliases in bash is very straight forward. The syntax is as follows:
{{File|file=~/.bashrc|
content=<pre>...
alias alias_name="command_to_run"
...</pre>}}
=== For updating your system ===
=== For updating your system ===
To upgrade the system via pacman, the command used is  
To upgrade the system via pacman, the command used is  
{{UserCmd|command=sudo pacman -Syu}}
{{UserCmd|command=sudo pacman -Syu}}
This can be aliased in .bashrc with
This can be aliased in ~/.bashrc with
{{File|file=~/.bashrc|
{{File|file=~/.bashrc|
content=<pre>...
content=<pre>...
Line 30: Line 35:
...</pre>}}
...</pre>}}
=== For editing commonly used files ===
=== 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)
To edit '''~/.bashrc''' itself and automatically reload bash configuration file (so that changes made to .bashrc can be implemented in current terminal session)
{{File|file=~/.bashrc|
{{File|file=~/.bashrc|
content=<pre>...
content=<pre>...
Line 51: Line 56:
alias grubup="sudo update-grub"
alias grubup="sudo update-grub"
...</pre>}}
...</pre>}}
==Conclusion==
==Creating Bash Aliases with Arguments (Bash Functions)==
This list is not comprehensive. Almost anything that is commonly used can be shortened with an alias
Sometimes you may need to create an alias that accepts one or more arguments. That’s where bash functions come in handy.
==See Also==
[https://www.gnu.org/software/bash/manual/html_node/index.html Bash documentation]
8,560

edits