[TxMt] Menu output (was: textmate Digest, Vol 5, Issue 56)

Allan Odgaard allan at macromates.com
Mon Feb 21 13:07:42 UTC 2005


On Feb 20, 2005, at 20:09, max at machinate.org wrote:

> I have put together a command that outputs filenames matching the 
> first few
> letters but need a way of selecting options when there are multiple 
> results.
> We'll have to wait for commands to output to a contextual menu to fully
> realise some of the potential of these ideas, but when it is supported 
> I
> think there will be a lot of great tools available to us.

Until I provide better support for this, you may want to use the 
'choose from list' apple script command.

For example here is a script that finds all files starting with 
$TM_CURRENT_WORD (in current directory), shows an AS dialog from where 
you can choose, and inserts the choice (removing the common prefix).

Input: none
Output: insert as snippet

FILES=`find . -name "${TM_CURRENT_WORD}*" -type f -maxdepth 1 -exec 
basename '{}' \;|perl -pe 's/(.*)\n/"$1",/'|perl -pe 's/,$//g'`

osascript -e 'tell app "Finder" to activate'
res=`osascript -e "tell app \"Finder\" to choose from list { $FILES }"`
osascript -e 'tell app "TextMate" to activate' &>/dev/null &

echo -n ${res:${#TM_CURRENT_WORD}}




More information about the textmate mailing list