How to add elements to your bash profile
Last updated
Last updated
In order to access software such as Freesurfer or FSL via your Terminal, it is first helpful to add these programs to your bash profile. This tells bash where the source codes for these programs live on your computer so that all you need to do is type specific commands into your terminal rather than entire paths to the code for each command.
As you can see in the example above, some pieces of software are set up to automatically add elements to your bash profile upon installation (such as MRtrix3). However, some elements need to be added manually.
You can do this by doing the following:
Open a terminal window
Type vi .bash_profile
When you see your bash profile open (which may be empty at first, type “i” (this stands for “insert” and will allow you to type things into the window that you will later save.
Start by adding a header to indicate which program you’re adding to your bash profile by using #. # at the beginning of a line indicates that a line is a comment and will not by read by any program as usable script. As you can see, I have headings for all programs beginning with # in my profile above.
Add whatever you need to add* dependent on the program. Typically, this will involve inputting export PATH=$PATH:/path-to-application/
Hit “Esc”, then “;” (the semi-colon), then “wq” (this stands for “write/save and quit”, then “enter”.
*If you are uncertain of what you need to add to your profile to get bash to recognize the program you want it to recognize, you can copy the lines in the example above based on the program in question. Or you can Google “add [program] to bash profile”
After you successfully add a program to your bash profile, you should be able to access all of the call-able commands the software offers. Such as “bet” or “flirt” from FSL or “recon-all” from Freesurfer.
Programs to consider adding to your bash profile: PyDesigner, FSL, MRIcroGL, Freesurfer, MRtrix3, or anything you will regularly call from your Terminal.