[TxMt] [TextMate] Help With Ruby Command
Timothy Martens
timfm at hawaii.rr.com
Tue Oct 26 09:28:45 UTC 2004
With Daniel's help, I'm using the script like:
in the command window:
/usr/local/bin/ruby ~/Library/Application\
Support/Textmate/completedTask.rb $TM_FILEPATH
the ruby script:
#!/usr/local/bin/ruby
task_text = $stdin.read
task_text.gsub!("\\[ \\] ","[X] ")
from = File.basename(ARGV[0],".txt")
File.open("/Users/tim/Documents/projects/GTD/Inbox/
done.txt",'a'){|archive_file|
archive_file.puts
archive_file.puts task_text
archive_file.puts " in #{from} #{`date \"+%H:%M %Y%m%d %a\"`}"
}
I mapped it to a key and it moves the selected text/line to "done.txt"
Except the task_text.gsub!("\\[ \\] ","[X] ")
stuff doesn't seem to be working.
Any ruby mentors out there? We really want to learn :)
-t
On Oct 25, 2004, at 6:55 PM, Kjell Olsen wrote:
>
> I love the idea of Daniel Von Fanges TextMate Log Script[1], but my
> unfamiliarity with both ruby and textmate is giving me a headache. I
> hope I can use you guys as a sounding board and this doesn't bug you
> too much.
>
> [1]: http://www.braino.org/blog/archives/001440.php
>
> I can't make the date function work within the command - If I execute
> my script outside of textmate it works beautifully, but from within
> textmate I get:
>
> <code>
> date: illegal time format
> usage: date [-nu] [-r seconds] [+format]
> date [[[[[cc]yy]mm]dd]hh]mm[.ss]
> </code>
>
> When I run the same script with the textmate variables replaced by
> normal strings I get:
>
> <code>* [23:19:54 ] @test -> just a test action</code>
>
> Do the ticks ` in the date function mean that I'm using bash's date
> program? The error thrown in the command matches the error from the
> command line, but why doesn't it happen when the script is executed by
> ruby?
>
> Why won't this work? All the help I can get would be very much
> apreciated. I'm using v1.02b1, and here's what the command looks like
> in it's entirety:
>
> <code>
> /usr/bin/env ruby <<END
> task_text = "$TM_CURRENT_LINE"
> task_text.gsub!("* ","* [#{`date \"+%H:%M:%S\"`}] ")
> task_text.gsub!("\n","")
>
> from = "$TM_CURRENT_FILE"
>
> File.open("/Users/kjell/Documents/planner/complete",'a'){|archive_file|
> archive_file.puts task_text
> #archive_file.puts " in #{from} #{`date \"+%H:%M %Y%m%d %a\"`}"
> archive_file.puts
> }
> END
> </code>
>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/mailman/listinfo/textmate
>
More information about the textmate
mailing list