Created
March 29, 2016 13:24
-
-
Save hryamzik/e216a0493e6e5e64b1ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
read line | |
role=$(echo "$line"|/usr/local/bin/sed -E 's/^\s*-\s*\{?\s*(role:\s)?([a-zA-Z0-9_+-\/]+)($|,.*)/\2/') | |
testpath="$TM_DIRECTORY" | |
function testPath { | |
if test -d "$1/$role" | |
then | |
echo "$1/$role" | |
elif test -d "$1/roles/$role" | |
then | |
echo "$1/roles/$role" | |
fi | |
} | |
function openRole { | |
echo "$1" | |
if test -f "$1/tasks/main.yml" | |
then | |
mate "$1/tasks/main.yml" | |
else | |
mate "$1" | |
fi | |
} | |
rolepath="$(testPath "$testpath" )" | |
test -z "$rolepath" || openRole "$(/usr/local/opt/coreutils/libexec/gnubin/realpath "$rolepath")" | |
echo $role | |
echo "$TM_DIRECTORY"|grep -o '/'|while read _ && test -z "$rolepath" | |
do | |
testpath="$testpath/../" | |
rolepath="$(testPath "$testpath" )" | |
test -z "$rolepath" || openRole "$(/usr/local/opt/coreutils/libexec/gnubin/realpath "$rolepath")" | |
done |
Author
hryamzik
commented
Mar 29, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment