launching textpad from cygwin
This is a simple bash function that I use pretty often. It comes in handy when I’m navigating a tree of source code in a cygwin bash shell, and want to edit a file in TextPad. You can just put this line in your .bashrc file, and make sure the directory where TextPad.exe lives is in your $PATH environment variable:
function tp() { textpad $(cygpath --mixed $1) & }
This allows me to do things like:
$find . -name '*Foo*.java'
which returns results like:
./src/com/spugbrap/foo/bar/TestFooImpl.java
./servlet/com/spugbrap/baz/FooDispatcher.java
Then I can just copy one of those full (but relative) paths to the clipboard, and paste it into a command that looks like this:
$tp ./servlet/com/spugbrap/baz/FooDispatcher.java
Now, regardless of where the root of this relative path exists on the file system, it will open that file in TextPad.
The only limitation that I run into with this is that it only lets you specify one file to open. It could probably be modified to handle multiple files pretty easily, but this hasn’t bothered me enough to deal with yet.


April 14th, 2007 at 11:46 am
EditPlus!
April 16th, 2007 at 8:25 am
TextPad!
April 16th, 2007 at 6:46 pm
Hmm… I’ve never done a side-by-side comparison.. I just know textpad didn’t stick with me, and editplus did. but some of that may have been timing — 1999(?) vs 2005.
August 31st, 2007 at 8:08 am
Woohoo! Thanks to Bruce, who posted this for loop in a comment on Marc Abramowitz’s blog, I now have a ‘tp’ function that supports multiple paths on the command-line:
function tp()
{
for ((at=1; at < = $#; at++))
do
p="$p `cygpath -wa ${!at}`"
done
textpad $p &
}
August 31st, 2007 at 9:57 am
for your bunghole?
August 31st, 2007 at 11:12 am
are you threatening me?
September 17th, 2007 at 7:50 am
Ack! The function I posted in the comment, above, had a flaw: the ‘p’ variable never gets reset. Every time the ‘tp’ function is executed, the string ‘p’ already contains the values from every previous invocation, because the function keeps appending to p, without ever clearing it.
The following works better, and includes debug output that I don’t mind seeing every time I run the function:
function tp(){
echo tp:input:$*
unset p
for ((at=1; at < = $#; at++))
do
p="$p `cygpath -wa ${!at}`"
done
echo tp:output:$p
textpad $p &
}