Linux Add custom bash commands
Step 1 :
Find your .bashrc file
Step 2 :
(.bashrc is found in root directory)
(You can type cd in the terminal and hit enter to get to root and use ls -la to see list of files in directory)
– Edit your .bashrc file. Use whatever editing tool of your choice.
or you can just edit in the terminal with the below command :
nano .bashrc
Once you are in the file proceed to step 3.
Step 3 :
Go to the bottom of you .bashrc file and look for something along the lines of the below :
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Step 4 :
Add a comment above the snippet indicated above so it looks like this.
#Custom Bash Commands # Commands will be listed here... export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Step 5 :
Add your commands. 1 per line! use semi-colon ( ; ) to run multiple commands in succession
#Custom Bash Commands alias my_custom_bash_command="do something in bash code" alias my_custom_bash_command2="do something in bash code" alias my_custom_bash_command3="do something in bash code" alias my_custom_bash_command4="do something in bash code" export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
© Garth Baker 2024 All rights reserved.