Hazel turning dots into ellipsis in my scripts..

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

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.
dancingfish
 
Posts: 4
Joined: Mon Apr 15, 2013 10:23 pm

It's not Hazel (it's OSX's automatic text formatting), and the conversion can be undone by hitting backspace after the ellipse shows.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

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...
dancingfish
 
Posts: 4
Joined: Mon Apr 15, 2013 10:23 pm

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'"
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Likely it's system-wide, not Hazel-specific, as a_freyer has mentioned. Check under System Preferences > Language & Text / Text:
Image
sjk
 
Posts: 332
Joined: Thu Aug 02, 2007 5:43 pm
Location: Eugene

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!).
dancingfish
 
Posts: 4
Joined: Mon Apr 15, 2013 10:23 pm

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.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

And that was it. Of course, it makes sense. D'oh!

Thanks! (hair is still intact)
dancingfish
 
Posts: 4
Joined: Mon Apr 15, 2013 10:23 pm


Return to Support