Using Shell Scripts to Extend TextExpander

Philip Blog, TextExpander, TextExpander Tips

> I’ve created the following snippet with abbreviation: ,getdate: > > %date:EEEE% %date:d% %date:LLLL% %date:Y% – día %date:D% del año > > Which is converted to the following on my system: > > jueves 30 septiembre 2010 – día 273 del año > > However, I would like the day of the week and month to be in uppercase, as follows: > > Jueves 30 Septiembre 2010 – día 273 del año > > Do you know how to do this? It seems that the Unicode date formatting doesn’t offer a way to specify that the month or day names should be returned in uppercase. I was able to write a Perl script and to nest the ,getdate snippet to convert the first and third words to uppercase. I set my abbreviation to ,date and my Content: to Shell Script:

#!/usr/bin/perl

$_ = "%snippet:,getdate%";

m/(\S+) (\S+) (\S+)(.*)/;

$_ = ucfirst($1) . " $2 " . ucfirst($3) . "$4";

print "$_\n";
Here is what ,date returns right now with my system set to return date information in Spanish: Miércoles 13 Octubre 2010 – día 286 del año That which wasn’t possible before is possible now, thanks to the power of shell scripts in TextExpander.