Page 1 of 1

Hazel turning dots into ellipsis in my scripts..

PostPosted: Mon Apr 15, 2013 10:28 pm
by dancingfish
Hi,

I'm embedding a script which has a regex to match 3 or 4 characters in a row (using 3 or 4 dots), and Hazel keeps eating these and turning them into some kind of ellipsis symbol (a single char), which, of course, messes up my expression matching. How can I get Hazel to stop doing this?

I searched in the forums, but haven't found anything related yet.

thanks.

Re: Hazel turning dots into ellipsis in my scripts..

PostPosted: Tue Apr 16, 2013 9:33 am
by a_freyer
It's not Hazel (it's OSX's automatic text formatting), and the conversion can be undone by hitting backspace after the ellipse shows.

Re: Hazel turning dots into ellipsis in my scripts..

PostPosted: Tue Apr 16, 2013 11:43 am
by dancingfish
This is not the same as the ellipsis showing after you type some var names, etc. This ellipsis replaces some of the dots that you've typed, and hitting backspace just deletes them, and you have to type them again (and the ellipsis replaces the dots, and so on).

Try typing in a script where you need a regex that matches 8 dots in a row, and you'll see what I mean.

My workaround for now is to type the dots in a text editor, and copy and paste them into the script.

Now I'm having fun with backslashes and applescript...

Re: Hazel turning dots into ellipsis in my scripts..

PostPosted: Tue Apr 16, 2013 11:54 am
by a_freyer
Image

This is still an autotext - just hit CMD+Z when the conversion happens. If you enter too many periods too quickly, it will format the entire string so backspace won't do anything. Undo (i.e. CMD+Z) does, as the screenshot shows.

As far as backslash in applescript goes, I find it FAR easier to use:

Code: Select all
do shell script quoted form of "sed 's/easyregex/sillyapplescript/g'"

Re: Hazel turning dots into ellipsis in my scripts..

PostPosted: Tue Apr 16, 2013 2:22 pm
by sjk
Likely it's system-wide, not Hazel-specific, as a_freyer has mentioned. Check under System Preferences > Language & Text / Text:
Image

Re: Hazel turning dots into ellipsis in my scripts..

PostPosted: Tue Apr 16, 2013 5:00 pm
by dancingfish
Thanks, the undo and text prefpane tips really help.

The problem I'm having with slashes/backslashes is puzzling me. Basically I have a string formatted like "12/31/2012", and I'm trying to pull the month and year out of it for file naming, in applescript.

Here's my statement for pulling out the month:
set stmtMonth to do shell script "echo $x | awk -F'/' '{print $1}'"

where $x is "12/31/2012". In terminal on the command line, this seems to work fine and returns "12". But in this applescript, it returns an empty string. I've tried escaping the forward slash, once, twice and even four times. Unfortunately, "quoted form of" doesn't help with this, I think due to the shell variables that are used.

I know there are many ways to do this, but I'm stumped as to why this simple method isn't working. And I'm sure the answer is right in front of my face... I'm not new to shell programming, other kinds of scripts, regular expressions, but I am new to applescript (and hazel!).

Re: Hazel turning dots into ellipsis in my scripts..

PostPosted: Tue Apr 16, 2013 5:05 pm
by a_freyer
Is this a copied line from your code?

Code: Select all
set stmtMonth to do shell script "echo $x | awk -F'/' '{print $1}'"


If so, there is no value in $x, and that is why you are returning nil. Each time you call "do shell script" AppleScript will spawn a new shell, so variables you set in previous lines are inaccessible.

Try this instead:

Code: Select all
set stmtMonth to do shell script "echo " & theDateValue & " | awk -F'/' '{print $1}'"


EDIT - and just so you don't pull all of your hair out, none of these characters need to be escaped as written.

Re: Hazel turning dots into ellipsis in my scripts..

PostPosted: Tue Apr 16, 2013 5:11 pm
by dancingfish
And that was it. Of course, it makes sense. D'oh!

Thanks! (hair is still intact)