Automatically Run Command Upon Opening Terminal (Linux Mint 16)

I am using Rails and for some reason unbeknownst to me I have to execute the following line every time I start the terminal in order to use ruby and rails.

source ~/.bash_profile

If I type the following before running the above command, it will recommend that I install the packages (ie "type 'sudo apt-get install package' to install")

rails -v && ruby -v && irb -v

Is there a way to make my terminal execute a command upon opening? Or, better yet, can anybody help explain the reason I have to run this line? I found an article that said I had to do that given my issue but it didn't explain why.

Answers


Assuming you're using the bash shell, then ~/.bash_profile will be sourced once (and only once) when you log in to the system but not each time you open a terminal window.

The ~/.bashrc, however, will be sourced every time a new shell is opened (i.e. when you open a terminal window).

So they are probably some environment variables settings in ~/.bash_profile which are required for ruby to run. Those settings should be moved to the ~/.bashrc file instead so they are defined in all shell instances.

Alternatively, source ~/.bash_profile from your ~/.bashrc (this is at your own risk, it may have side-effects).


Need Your Help

Finding the day of the thirteenth of every month over a period of years

c++ calendar

I am currently trying to solve some problems from the USACO training website in preparation for an unrelated C++ programming competition.

java application vs java servlet jdbc connection

java servlets jdbc teradata

I have a Connector class that works perfect for my java app . However , when I refer to this class from my servlet , i get classNotFound .com.teradata.jdbc.TeraDriver

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.