On Mon, 25 Oct 2004 23:55:02 -0500 Kjell Olsen wrote:
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>
Timothy Martens' solution of using an external script which is then called with a command works well, or -- if you'd prefer to keep it all within TextMate, you could try something like:
ruby <<END task_text = "$TM_SELECTED_TEXT" task_text.gsub!("[ ] ","[X] ") print ""
from = File.basename("$TM_FILEPATH",".txt") comp_time = Time.now datestamp = comp_time.strftime("%d/%m/%Y at %H:%M")
File.open("/Users/me/completed.txt",'a'){|archive_file| archive_file.puts archive_file.puts "#{task_text} => in #{from} on #{datestamp}" } END
I ran into a similar problem, which I suspect in my case was down to escaping the quotes in the format string wrongly. The double quotes to form the Ruby string make this tricky. I decided to side-step the issue slightly long-windedly by using Ruby's 'date' methods. Note also that this code works on selected text: I have Standard in = selected text and Standard out = Replace selected text. The selected task then gets deleted from the original file and pasted in to the completed.txt file with a checkbox ([X]).
I also put the date stamp on the same line as the text to make it easier to grep for; when someone chases me about something I've done, I can double-check when I did it ;-)
I'm a Ruby-newbie too, so I'm sure more experienced coders could make it more efficient.
Jackie
-- Jackie Chappell jmchappell@mac.com
On Oct 26, 2004, at 1:57 AM, Jackie Chappell wrote:
ruby <<END task_text = "$TM_SELECTED_TEXT" task_text.gsub!("[ ] ","[X] ") print ""
from = File.basename("$TM_FILEPATH",".txt") comp_time = Time.now datestamp = comp_time.strftime("%d/%m/%Y at %H:%M")
File.open("/Users/me/completed.txt",'a'){|archive_file| archive_file.puts archive_file.puts "#{task_text} => in #{from} on #{datestamp}" } END
/bin/sh: line 1: ruby: command not found
why? do I need the full path in line 1?
-t
Probably... Go into terminal and do _whereis ruby_ and put what it gives you instead of just ruby. Unless you installed ruby yourself It should be in /usr/bin - that's where it comes with panther. What operating system do you have?
You could also put /usr/bin into your path: add the lines:
PATH="$PATH:/usr/bin" export PATH
to the .bashrc file within your home directory. Add it if it doesn't exist.
On Oct 26, 2004, at 6:17 PM, Timothy Martens wrote:
/bin/sh: line 1: ruby: command not found
why? do I need the full path in line 1?
On Oct 26, 2004, at 3:51 PM, Kjell Olsen wrote:
Probably... Go into terminal and do _whereis ruby_ and put what it gives you instead of just ruby. Unless you installed ruby yourself It should be in /usr/bin - that's where it comes with panther. What operating system do you have?
I installed ruby 1.81 before installing rails. i'm pretty sure it's in: /usr/local/bin/ruby
"whereis ruby" returns nothing
"whereis [ruby]" returns nothing
I'm on Panther 10.3.5
According to Timothy Martens:
"whereis ruby" returns nothing
"whereis [ruby]" returns nothing
Forget whereis(1), it is not really doing the right way.
For bash users, use « type <command> ». In zsh, one can use ruby<ESC> ? to find the path for a given command (provided it is in the PATH). type is also supported in zsh of course. csh/tcsh has the same key binding as zsh too. which(1) is also a csh/tcsh builtin.
On Oct 26, 2004, at 3:51 PM, Kjell Olsen wrote:
You could also put /usr/bin into your path: add the lines:
PATH="$PATH:/usr/bin" export PATH
to the .bashrc file within your home directory. Add it if it doesn't exist.
I don't have a .bashrc file in home, but I do have .bash_profile which contains:
export PATH=$PATH:/usr/local/bin:/usr/local/mysql/bin:/usr/local/php/bin
is .bashrc something different/necessary?
-
On 27. Oct 2004, at 12:04, Timothy Martens wrote:
to the .bashrc file within your home directory. Add it if it doesn't exist.
I don't have a .bashrc file in home, but I do have .bash_profile which contains:
export PATH=$PATH:/usr/local/bin:/usr/local/mysql/bin:/usr/local/php/bin
Currently TextMate starts bash as a non-interactive non-login shell. So the only file sourced will be the one mentioned in the BASH_ENV variable (which no-one probably have setup).
I'll add '--login' in next beta, that should make it read the .bash_profile, and hopefully people will have less problems with paths.
Kind regards Allan