[TxMt] drag commands

marios tmtxpstuff at consking.com
Sun Oct 1 12:26:24 UTC 2006


Allan Odgaard wrote:
> On 30/9/2006, at 22:38, marios wrote:
>
>> [...] How do I change the code, so it uses a different Variable in
>> these cases ?
>> (for instance, in this case, using a different variable like
>> $TM_LOCAL_URL instead of $TM_REMOTE_URL)
>
> You can do something like:
>
>     if [[ "$TM_MODIFIER_FLAGS" = *OPTION* ]]
>         then BASE="$TM_LOCAL_URL"
>         else BASE="$TM_REMOTE_URL"
>     fi
>
> Then in your command use "$BASE" (which will be the local URL when ⌥
> is down).
>

Wonderful. I've got this working now, except, there is one peculiar
thing happening, that's not directly related
with this.
When I use option, and drag the File, The document window looses focus
and disappears under the cursor, when the file gets
dropped in the document window, so I changed the whole thing to use
Shift instead, where I get the expected behavior.
This is what I have so far using your recommendation:


if [[ "$TM_MODIFIER_FLAGS" = *SHIFT* ]]
        then BASE="$TM_LOCAL_URL"
        else BASE="$TM_REMOTE_URL"
fi
echo -n "<a href=\"http://$BASE/file_download/\${1:file_id}\"
title=\"\${2:`ruby -e 'print
ENV['\''TM_DROPPED_FILE'\''].gsub(/^(.*\/)/,String.new)'`}\">\${3:\$2}</a>"


>> echo -n "<a href=\"http://$TM_REMOTE_URL/file_download/\${1:file_id}\"
>> title=\"\${2:`ruby -e 'print
>> ENV['\''TM_DROPPED_FILE'\''].gsub(/^(.*\/)/,String.new)'`}\">\${3:\$2}</a>"
>>
>>
>> Also , I tried to modify the code so it strips off the file-extension
>> from the third variable doing the usual TM Transformation,
>> but then I get an Error , gsub complaining.
>
> Just paste an example of the desired result.

This is the output that I have using the above modification.

<a href="http://www.consking.com/file_download/file_id"
title="test.abc">test.abc</a>
<a href="http://www.local.dev/file_download/file_id"
title="test.abc">test.abc</a>

What I am trying to achieve is this:

<a href="http://www.consking.com/file_download/file_id"
title="test">test</a>
<a href="http://www.local.dev/file_download/file_id" title="test">test</a>

,where test is a transformation of $TM_DROPPED_FILE getting stripped off
both the relative path AND the file extension .abc

I had a look also, at
http://macromates.com/blog/archives/2005/09/26/shell-variables/,
Is there a shorthand way, also to strip both, at the end and the
beginning, using this method ?

regards, marios




>
>
>




More information about the textmate mailing list