I'm trying to add an alias to the bashrc file. Since I'm not good at this, Im' going to write all the steps I took
nano ~/.bashrc
The file had this in it
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
On top of that I added my alias
dropUpload(){
~/drop.sh upload $1 $2
}
alias dropU=dropUpload
Saved the file and then sourced it with . ~/.bashrc
In the same window I tried using the code dropU first/url second/url
and it worked. I closed the terminal window and opened a new one, the code no longer works. The error I get is
-bash: dropU: command not found
If I nano
back to the file my new code is there. If I re-source the file, the code works. How can I get this to persist?
.bashrc
sourced automatically on your new terminal session. You can try to add to.bashrc
a simple alias likealias myEcho='echo Anubeloredelana'
, which printAnubeloredelana
onto the terminal, and in a new terminal session try to call it to see if it work. – binhsonnguyen Mar 18 '16 at 05:00~/.bash_profile
, not~/.bashrc
. Double check that you added the correct lines to your~/.bash_profile
? – Ian C. Mar 18 '16 at 05:01if [ -f ~/.bashrc ]; then . ~/.bashrc fi
I realised I was adding it in both~/.bashrc
and~/.bash_profile
. Now it works. I can't upvote (not enough reputation) but thanks for your help @binhsonnguyen – relidon Mar 18 '16 at 05:31