Last active
November 13, 2016 21:28
-
-
Save dardo82/a871654b329b5caf57df to your computer and use it in GitHub Desktop.
Automator to SH script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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