0

I use IPython 0.13 on OS X 10.6 and would like to do the following: I have different project folders e.g. ~/dev/proj1, ~/dev/proj2. Now I want to start IPython in one of these folders without changing to it. My first idea was to setup a new shell alias. In order to do so, I updated my bashrc with the following line:

proj1="~/dev/proj1/ipython"

Unfortunately it did not work. What I got instead was:

~/dev/proj1/ipython: No such file or directory

I do not really understand this error, because IPython can be started from any directory by simply typing ipython. And the folders do exist for sure. So, I wondered if there is a way to supply the starting directory as an argument to IPython like:

ipython start-dir="~/dev/proj1/ 

Any ideas to solve this one?

sodd
  • 12,482
  • 3
  • 54
  • 62
MaxPowers
  • 5,235
  • 2
  • 44
  • 69

2 Answers2

1

You can define an alias like this:

f_ipy()
{
        cd ~/dev/$1/
        ipython
}

alias ipy=f_ipy

That you can call like ipy proj1, ipy proj2, etc.

Also, it is better to use $HOME rather than ~. See "~/Desktop/test.txt: No such file or directory".

Community
  • 1
  • 1
fedorqui
  • 275,237
  • 103
  • 548
  • 598
  • Thank you for your help and the advise on `~` and `$HOME`. Unfortunately this does not work, too. I got the same error `no such file or directory`. – MaxPowers May 02 '13 at 10:21
  • Then we should go one step back: can you do `~/dev/proj1/ipython` in your prompt? If not, my solution is useless. From what I read in [iPython quick reference](http://scienceoss.com/ipython-quick-reference/) the project is based on the directory in which you are. In this case, can you try the code I just added in my answer? – fedorqui May 02 '13 at 10:26
  • @fedorqui your first version of this answer does not answer the question at all... Perhaps you should remove it – drevicko Sep 20 '13 at 02:04
  • @drevicko it was the first version that then was improved. Thanks for notifying, just updated it. No need to downvote, though. – fedorqui Sep 20 '13 at 08:19
1

Use the following command to start IPython in given directory:

ipython -i -c "%cd ~/dev/proj1/ipython"