Discussion:
Adding script path: How to get Locomotive base directory?
Ronald Fischer
2008-01-02 20:52:16 UTC
Permalink
I would like to add the Rails script directory to my PATH, when opening
a Locomotive terminal window.

Right now I add it (in the Locomotive preferences) as relative path,
i.e.
I set the "additional path" in the preferences to

/usr/local/mysql/bin:script

Of course this breaks down if I do a cd in my terminal window. The
problem
is that I can not hard code the absolute path to the script directory,
because I have more than one Locomotive application, and each has of
course its own script directory.

I would ideally need an environment variable which gives the base
directory
of my Rails app, but as far I see, there is no such thing.

Does anyone know of a nice trick to achieve this goal?

In case my question is not clear, here an example: Say I have two
Rails applications managed by Locomotive: app1 based in /Users/ror/
foo/a1
and app2 based in /Users/ror/bar/a2. When I select app1 in Locomotive
and open a terminal window, I would like to have /Users/ror/foo/a1/
script
in my PATH, but when I select app2 in Locomotive and open a terminal
window, I would like to have /Users/ror/bar/a2/script in my PATH.

Ronald
--
Ronald Fischer <ronald.fischer-***@public.gmane.org>
http://www.fusshuhn.de/
Alex Satrapa
2008-01-03 02:14:22 UTC
Permalink
Post by Ronald Fischer
I would like to add the Rails script directory to my PATH, when opening
a Locomotive terminal window.
The best I can suggest at the moment is to create an alias for:
PATH=$PATH:`pwd`
... then run that any time you open Terminal from Locomotive.

An alternative for zsh users is to use named directories, eg:

$ hash -d a1=/Users/ror/foo/a1
$ hash -d a2=/Users/ror/bar/a2
...
$ ~a1/script/generate model Widget
$ bbedit ~a1/app/models/widget.rb

The "hash -d ..." lines can be added in your ~/.zshrc file. One
advantage of named directories is that you can never be confused
about which Terminal window "belongs" to which project.

HTH
Alex

Loading...