Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
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 at 7:42

2 Answers 2

up vote 1 down vote accepted

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
share|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 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. –  patrix Feb 3 at 9:17
    
→ Ishan: good question, but please follow the Patrix comment. You'll help everyone… and yourself: better targeted answer. –  daniel Azuelos Feb 3 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"
share|improve this answer
    
This won't be static. I was just trying out using a static example. –  Ishan Jain Feb 3 at 7:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.