[TxMt] Help with simple command

Jeffrey Robert Spies jspies at nd.edu
Wed May 10 02:16:38 UTC 2006


Oliver,

This should do what you need:

npp=38
res=$(echo `wc -l`)
pretty () { rev <<<$1|perl -pe 's/(\d{3})(?=.)/$1,/g'|rev; }
total=$(pretty $(cut <<<$res -d\  -f1))
php -r "echo ceil($TM_LINE_NUMBER/$npp).'/'.ceil($total/$npp);"

Just "Add new command" in Bundle Editor, input "Entire Document", and  
output "Show as Tool Tip".  Part of that comes form Text's statistics  
for document command.  It's a good place to start even if you don't  
know how to script.

Hope that helps,

Jeff.

On May 9, 2006, at 9:19 PM, Oliver Taylor wrote:

> I don't speak any scripting language so I was hoping you all could
> help me out with two simple commands.
>
> 1. Take the current line number, divide my 38 and display the result
> as a tooltip that reads: Aprox. Page-Count for Current Line: XX
> 2. Take the total number of lines in the document, divide my 38 and
> display the result as a tooltip that reads: Aprox. Page-Count for
> Document: XX
>
> Thanks in advance!
>
> —oliver
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate




More information about the textmate mailing list