MacOS – Can’t open a file in sublime text using bash_rc

bashmacossublimetextterminal

My bash_profile function looks like:

function st() { /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /Users/ishan/workspace/nltk_engine/index.py;}

However, when I do st in terminal, it just opens up a sublime text window without opening the file. I copied the line in terminal and it is working. Its not working through bash_profile.

Best Answer

The st function which is working when you type st is an old one which you defined interactively within Terminal. If you enter:

type st

you will see that this definition is not the one you entered within your .bash_profile.

To execute the definition entered within your .bash_profile, you have to load it within your actual shell:

. ~/.bash_profile

or

source ~/.bash_profile

And you will be able to check that from now on your definition of your st function is correct with:

type st