UPDATE: I like vi more than Aptana now. Here’s how I use svn up to update a bunch of Rails sites, and then use vi to edit a file in each site:
for l in `ls -1`; do
svn up ${l}/config/environment.rb;
vi ${l}/config/environment.rb;
done
And when I’m done with my changes, I commit them all at once (sort of) with the same message:
for l in `ls -1`; do
svn status -q ${l}/config/environment.rb |
egrep '^M' |
svn commit `awk '{print $2}'` -m "changed environment.rb";
done
One lovely thing about Ruby on Rails is the uniformity of the directory structure. All of my apps have pretty much the same files in pretty much the same folders. Today, I wanted to edit the environment.rb file in each of my company’s nine applications. Ugh, what a ton of mouse clicks digging through nine directory structures (note: I am very much into efficiency — every second counts, and manual repetitive tasks suck). I thought There’s gotta be a way to find all files named environment.rb and open them in Aptana. This command works! I can get my work done in seconds now instead of minutes! I use locate, which keeps a database of file names… I’ve found it to be faster than find.
The command below will first locate all files beneath the present folder (that’s what $(pwd) does) matching the regular expression /.*environment.rb$/ which means all files ending in environment.rb which will exclude any SVN files with similar names. Files that match that regular expression will be passed to Aptana, which will open any and all files passed in as arguments. Aptana will use an existing window if open, otherwise it will open a new one (precisely what I want!).
aptana $(locate $(pwd)/.*environment.rb$ -r)
It is the same as:
aptana /apps/app1/config/environment.rb /apps/app2/config/environment.rb /apps/app3/environment.rb
It’s much faster than:
aptana /apps/app1/config/environment.rb aptana /apps/app2/config/environment.rb aptana /apps/app3/config/environment.rb
And here’s a textarea to tinker, copy, & paste from: