Skip to content

Instantly share code, notes, and snippets.

@dardo82
Last active November 13, 2016 21:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dardo82/a871654b329b5caf57df to your computer and use it in GitHub Desktop.
Save dardo82/a871654b329b5caf57df to your computer and use it in GitHub Desktop.
Automator to SH script
#!/bin/zsh
# Convert Apple Automator "Run Shell Script" action to actual shell script
NAME="${${1##*/}%.*}.sh"
CDWF="$1/Contents/document.wflow"
touch $NAME
chmod +x $NAME
awk -F'<|>' '/bin\/.*sh/{print "#!"$3; exit}' $CDWF > $NAME
awk '{if($0~/<string>.*[^>]$/)f=1; if($0~/<\/string>/)f=0; if(f==1){sub(/\t*<string>/,"",$0); print $0}}' $CDWF | ascii2uni -q -a Y >> $NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment