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.

  • 1
    Which version of Sublime Text do you use? I tried with version 2.0.2 and it worked as expected: I could open a python file using a function like yours sourced from .bash_profile. Which is the output of type st? As a side comment, add functions to .bashrc instead, since functions not are exported to the environment. – jaume Feb 3 '14 at 7:42

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


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
| improve this answer | |
  • I finally got it to work. The mistake was that there was an alias "st" in my .bashrc also. This was creating the problem. I found it by issuing the "type" command. Thanks :). Also could you tell me what things should I put in my bash_profile and what things should I put in bashrc? – Ishan Jain Feb 3 '14 at 8:39
  • 1
    @ishanJain Comments should be used to ask for clarifications on the given answer and similar stuff. Asking follow-up questions in comments doesn't work so well, it's better to ask a new question in these cases. In your case it might also help to search through old questions here, on stackoverflow.com and on unix.stackexchange.com because it is highly likely that this topic has come up before. – nohillside Feb 3 '14 at 9:17
  • → Ishan: good question, but please follow the Patrix comment. You'll help everyone… and yourself: better targeted answer. – dan Feb 3 '14 at 15:01

Since your command is a static command, you could try an alias:

alias st="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /Users/ishan/workspace/nltk_engine/index.py"
| improve this answer | |
  • This won't be static. I was just trying out using a static example. – Ishan Jain Feb 3 '14 at 7:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .