So, yeah, I got a mac. It's nice. But it's missing some fun. So, I added fun.
Open Files in my Editor (TextWrangler) from the Command Line
When writing code I use Eclipse, but there are times when I just want a decent text editor that's also fast. My coworker Steve recommended I try out TextWrangler and it seems to be pretty good so far. I was really used to being on the command line and doing: xemacs somefileinthisdirectory.info and having it open my editor for that file. No longer the case...there's path issues and even after solving those TextWrangler doesn't want to open multiple files.
After a bit of digging I learned of the command open -a TextWrangler filename but it won't accept wildcards (filename.*) and that's a lot of stuff to type.
So, I whipped up a little shell script to help me out - here are the steps.
First, Set your PATH
The first step is to set the "PATH" so that your command line knows where to find executable scripts. I have a folder in my home directory called "bin" where I still all sorts of fun little helpers so I added that to the ".profile" file in my home directory:
export PATH=/Users/greg/bin:$PATH
You can do this easily on the command line:
echo "export PATH=/Users/greg/bin:\$PATH" >> .profile
If you don't have a .profile file, thatcommand will create it. If you have one, it just adds that last bit to the end of it. Note that this command will only work if your name is "greg." Otherwise change "greg" to whatever your username is.
Second, Create the Shell Script to Call TextWrangler
At this point, you need to create a little shell script that will use that long syntax to open up the files that I pass to it:
Recent comments
1 hour 17 min ago
1 day 12 hours ago
2 days 7 hours ago
4 days 4 hours ago
4 days 18 hours ago
6 days 3 hours ago
6 days 8 hours ago
6 days 20 hours ago
6 days 21 hours ago
1 week 7 hours ago