views:

132

answers:

1

How can I make a shell script that will know where the caret is and grab selected text, so I can wrap the text in something? For example, this is a script from a Textmate bundle:

<${1:p}>$TM_SELECTED_TEXT</${1/\s.*//}>

It grabs the text and wraps it in open/close HTML tags. And it is variable so the second tag is mirrored as you type the first. I want to make a script like this but outside of Textmate so I can use it in TextEXpander.
Does this make sense ? :)

A: 

$TM_SELECTED_TEXT is not an environment variable provided to scripts running outside of TextMate -- it is a variable that is set by TextMate and provided to scripts that are run as part of its snippet system. It is not even provided to the Shell bundles "Run Script" command.

What you want to do may be doable through other shell facilities (e.g., sed) so the functionality can be replicated by a shell script -- it depends on your usage scenario.

mipadi