How to auto load source file on bash startup?

15,221

Assuming the .rvm/scripts/rvm file is at your home. Use the following command in a terminal,

echo "source ~/.rvm/scripts/rvm" | tee -a ~/.bashrc

It will add the command at the end of your ~/.bashrc which is non-login interactive shell initialization file. when you open a terminal you get a non-login interactive shell. So the command will be executed every time you open a new shell or terminal and will serve your purpose.

Open a new terminal to see the effect or use the following command in the same terminal,

. ~/.bashrc
Share:
15,221

Related videos on Youtube

Patoshi パトシ
Author by

Patoshi パトシ

Updated on September 18, 2022

Comments

  • Patoshi パトシ
    Patoshi パトシ over 1 year

    I recently installed Ruby Version Manager (RVM) to make use of the command called compass. Initially it was working find on installation, but now I get a missing error:

    The program 'compass' can be found in the following packages:
     * libcompass-ruby1.8
     * ruby-compass
    Try: sudo apt-get install <selected package>
    

    However to get it to work again, I have to type in this command:

    source .rvm/scripts/rvm
    

    How do I auto load this file when I start up a terminal? I think I need to add it to the .bashrc file but I'm unsure what’s the proper syntax to input there.

  • Frank
    Frank over 7 years
    @sourvac, I respect your answer. Doies it function properly for Ubuntu 16,04 and raspian plus raspberry pi 3 ? Thank you.