Don't know if this helps, but there's a very rarely used shell variable called CDPATH
. CDPATH
is very much like the PATH
variable for commands. When you do a cd
, it searches the CDPATH
for directories that match your CDPATH
.
For example:
CDPATH=.:/usr/local:$HOME/projects
If I did:
cd jiff/source
The CD command would look for a ./jiff/source
, then a /usr/local/jiff/source
directory, then a $HONE/projects/jiff/source
directory. If there's a $HOME/projects/jiff/source
directory, the directory will change to there.
This won't solve your problem where you can simply type in a partial path, and have your command execute, but you could say add myapp/app/view
to your CDPATH
environment variable and do this:
$ cd user
$ gedit show.html.erb
The other thing you can do is alias the gedit
command to _gedit
, and then write a quick shell script to take the "file name", search for a directory tree that matches what you put, and then edit the file. This is something that Kornshell users do to get the equivalent of the PS1=\u@\h:\w
PS prompt that you BASH users have. Add something like this to your .bashrc
file:
alias _gedit=gedit
function gedit {
fileName=$(basename $0)
dirName=$(dirname $0)
for directory in app/controller my_app/app/view
do
if [[ -d "$directory/$dirName" ]]
then
$directory/$0
break
fi
done
}
Now, if you typed gedit user_controler.rb
, and there's a file app/controler/user_controler.rb
, it'll edit app/controller/user_controler.rb
yeah I figured that, but since it had a little bit to do with ruby on rails I thought a programmer might have had the same problem. – Spencer Cooley – 2011-06-20T21:31:00.447
well, since it was moved perhaps consider accepting an answer on this or one of your other questions here on superuser. – matchew – 2011-06-26T17:28:10.193