DEV Community

Mahmoud Galal
Mahmoud Galal

Posted on

Custom Commands in your Linux or Mac

Terminals are the superpower of developers

I have been in love with using terminals all the time even on windows.
The true love comes after I understand most of the commands and how to write Bash Scripts, and If you are not a Linux or Mac user using the terminal, you missed a lot.

How can I make my own commands?

  • Open your terminal using CTRL + ALT + T

  • sudo vim ~/.bashrc

Image description

if you get something else so, you should install Vim

sudo apt install vim

and run the command before

  • Go down and write your bash script click I to insert in the file write alias [your command]='[ the executable command in Linux ] '

Image description

then ESC and :wq Enter

if you want to make clean aliases

  • create a new file in the home ~ dir `touch .bash_aliases'
  • go into it using vim .bash_aliases
  • put your aliases there
  • save it by ESC and :wq Enter

close the current terminal to refresh your bashrc

  • open a new terminal and test your new commands

Image description

*this is the end of the tutorial *

How does it works?

when we open a terminal there's a bash script run to provide a path of everything we install,
when you write code . this opens your VScode so this command is saved in the bashrc
this makes a configuration for everything in the current terminal

so this script begins to execute every time you open the terminal, what if I want to print something every time a open a terminal

log to your bashrc again and write what you want using
echo Hi KroKing
save and restart the terminal

Image description

*Follow for more Tricks in Linux *

Latest comments (0)