[TxMt] Bash query

Richard Dyce dd at dyce.com
Tue Nov 6 11:35:34 UTC 2007


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?





More information about the textmate mailing list