Not urgent an query, just looking for some insight...
I've put together a little bash script (that creates an AppleScript) to stick an entry into Journler based on a parsed version of the current line or selection:
input=${TM_SELECTED_TEXT:-$TM_CURRENT_LINE}
title=${input%|*|*} tags=${input#*|} tags=${tags%|*} tags=${tags//, /", "} tags=${tags%", "} note=${input#*|*|*}
aplscr="tell application "Journler" to set en1 to make new entry with properties {name:"$title", tags:{"$tags"}, rich text:"$note "}"
osascript -e "$aplscr" &>/dev/null & echo "Added entry\ntitle: $title; tags: {"$tags"}; note:$note" echo "$aplscr"
Whilst it does work, I realised that there are more cunning minds at work on this list than mine, and perhaps they might have some way to clean-up those substitutions for the $tags variable in the middle. I know I can do it using a sed script, but I was wondering if there was some elegant bash trick I was missing....
Any ideas?
On 6 Nov 2007, at 12:35, Richard Dyce wrote:
Not urgent an query, just looking for some insight... [...] Whilst it does work, I realised that there are more cunning minds at work on this list than mine, and perhaps they might have some way to clean-up those substitutions for the $tags variable in the middle. I know I can do it using a sed script, but I was wondering if there was some elegant bash trick I was missing....
Nope, bash is very limited in that way, i.e. it basically does a two- step variable expansion with close to no support for recursive constructs (forcing you to call out to a more capable scripting language or split up your expressions into multiple lines).
Allan,
Thanks! I couldn't see that any other way to do it, but I thought it was a good idea to check - I think I'm getting the hang of bash ;-)
R
On 6 Nov 2007, at 22:34, Allan Odgaard wrote:
On 6 Nov 2007, at 12:35, Richard Dyce wrote:
Not urgent an query, just looking for some insight... [...] Whilst it does work, I realised that there are more cunning minds at work on this list than mine, and perhaps they might have some way to clean-up those substitutions for the $tags variable in the middle. I know I can do it using a sed script, but I was wondering if there was some elegant bash trick I was missing....
Nope, bash is very limited in that way, i.e. it basically does a two- step variable expansion with close to no support for recursive constructs (forcing you to call out to a more capable scripting language or split up your expressions into multiple lines).
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate