Am 13.04.2005 um 23:10 schrieb Allan Odgaard:
On Apr 13, 2005, at 16:26, Thomas Schröder wrote:
- BibDesk gives the reference in the following format: "cite-key %
author, title" e.g.
I was indeed a bit puzzled by what it returned :)
:-)
Okay, here's my take on it:
osascript -e 'tell app "TextMate" to activate' &>/dev/null & awk <<<$res '{print $1}' | tr -d \n
Ah, great! OK, I think I'm starting to get the hang of this.
Or if you want to keep the comment but insert a bracket: perl <<<$res -pe 's/^(\w+)/$1}/'
That doesn't work for me because some of my cite-keys have appendixes like "-PVA" for a certain preparation method and the cite-key gets cut off at the "-". I prefer not to have the comments anyway, so I opt for the first version, so don't bother to fix this. At least not for me :-)
So the entire command (with the condition on selection) becomes: ----------8<---------- if [[ -z $TM_SELECTED_TEXT ]] then phrase=$TM_CURRENT_WORD else phrase=$TM_SELECTED_TEXT fi
res=`osascript <<EOF tell application "Bibdesk" to set candidates to search for "$phrase" with for completion tell application "System Events" activate choose from list candidates end tell EOF` osascript -e 'tell app "TextMate" to activate' &>/dev/null &
res=`perl <<<$res -pe 's/^(\w+)/$1}/'` if [[ -z $TM_SELECTED_TEXT ]] then echo -n ${res:${#TM_CURRENT_WORD}} else echo -n $res fi
Thanks for the effort, but I think I will stick with my new version which by the way incorporates your awk-pipe because that works better for me. Your new version does indeed handle things correctly for strings that are not part of the cite-key but only if you select the string, otherwise you still get a mix-up. For the time being this is too confusing for me even though the point still stands that it's way more elegant not to have to select some text. Anyways, here's my new take on this:
---
res=`osascript <<EOF tell application "Bibdesk" to set candidates to search for "$TM_SELECTED_TEXT" with for completion tell application "System Events" activate choose from list candidates end tell EOF`
osascript -e 'tell app "TextMate" to activate' &>/dev/null & awk <<<$res '{print $1}' | tr -d \n
---
As far as I'm concerned, everything works fine, I have what I wanted, so thank you very much!
Best wishes, Thomas