Псевдонимы в .bashrc

From Manjaro Linux
Jump to: navigation, search

Что такое .bashrc? Что такое псевдоним?

.bashrc - это конфигурационный файл bash, командного интерпретатора Линукс.

Псевдоним - сокращение оригинальной команды. Можно представить как некое подобие сочетания клавиш.

.bashrc находится в домашней дирректории пользователя ( ~ ) . Это скрытый файл. Чтобы его увидеть, необходимо активировать "Показать скрытые файлы".

В XFCE можно активировать сочетанием <Ctrl + H>.

Backup your current .bashrc

It is handy 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. After shutting an open Terminal window down & then restarting it, one can then test out their alias(s).

Or for a quicker way, after having modified the ~/.bashrc run the following command:

source .bashrc

To reload the configuration file.

Aliases

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 yaourt, the command used is yaourt -Syu --aur

This can be aliased with-

alias aup="yaourt -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. A user can add many aliases that (s)he commonly uses.


Support

Following is a link to this page's forum counterpart where you can post any related feedback and get more information about aliases: [1]


Credits goes to Handy for his .bashrc guide.