On Apr 13, 2005, at 16:26, Thomas Schröder wrote:
I changed this command a little to my needs for two reasons:
- This works great if you type the beginning of the cite-key e.g.
"Od" for "Odgaard2005" but if you type something from the title e.g. "Te" you'll get something like "Tegaard2005".
Ah yes -- I didn't realize it was a sub-string search. What you could do is start the command like this:
if [[ -z $TM_SELECTED_TEXT ]] then phrase=$TM_CURRENT_WORD else phrase=$TM_SELECTED_TEXT fi
and then search for "$phrase", which will be current word when there is no selection. You'd need a similar 'if' construct when returning the result, so to cut the prefix when doing current word search.
- BibDesk gives the reference in the following format: "cite-key %
author, title" e.g.
I was indeed a bit puzzled by what it returned :)
echo -n ${res} > /tmp/BibDesk_Completion.txt osascript -e 'tell app "TextMate" to activate' &>/dev/null & #perl -pe 's/ %/} %/' /tmp/BibDesk_Completion.txt cat /tmp/BibDesk_Completion.txt | awk '{print $1}' > /tmp/BibDesk_Completion.txt echo -n `cat /tmp/BibDesk_Completion.txt`
Okay, here's my take on it:
osascript -e 'tell app "TextMate" to activate' &>/dev/null & awk <<<$res '{print $1}' | tr -d \n
Or if you want to keep the comment but insert a bracket: perl <<<$res -pe 's/^(\w+)/$1}/'
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