Created
January 25, 2017 09:00
-
-
Save hryamzik/c12ef91906b0ebcd6d8c8d84067c835f 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment