Last active
March 26, 2018 08:25
-
-
Save jonnitto/cc28c412326552fe30a04bafcd92e4d1 to your computer and use it in GitHub Desktop.
Open Neos project from the Command Line
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
# With the command `NeosProject` you get the site package folder and available folders definded in `ADDITIONAL_FOLDER` | |
# With `codeProject` you open your project in Visual Studio Code | |
# With `atomProject` you open your project in Atom | |
# With `pstormProject` you open your project in PHP Storm | |
# To disable the fallback (open current folder), change the fallback variable to "" | |
NeosProject() { | |
# Places where site packages could are stored | |
local SITE_FOLDER=(".src" "_src" "Packages/Sites") | |
# Additional folder to open | |
local ADDITIONAL_FOLDER=("Packages/Plugins" "Web") | |
local FOLDER_ARRAY=() | |
local fallback="." | |
# Get the site folder | |
for f in "${SITE_FOLDER[@]}" | |
do | |
if [ -d $f -a ${#FOLDER_ARRAY[@]} == 0 ] | |
then FOLDER_ARRAY+=("${f}/$([ $(echo ${f}/* | wc -w) == 1 ] && basename ${f}/*)"); | |
fi | |
done | |
# Get additional folder | |
for f in "${ADDITIONAL_FOLDER[@]}" | |
do | |
if [ -d "${f}" ] | |
then FOLDER_ARRAY+=($f) | |
fi | |
done | |
# Fallback | |
if [ -n "$fallback" -a ${#FOLDER_ARRAY[@]} == 0 ] | |
then FOLDER_ARRAY=($fallback) | |
fi; | |
echo "${FOLDER_ARRAY[@]}" | |
} | |
codeProject() { | |
# If we have a code workspace, open this instead | |
if [ -f *.code-workspace ]; | |
then for f in *.code-workspace; do open "$f"; done; | |
else code $(NeosProject); | |
fi; | |
} | |
atomProject() { | |
atom $(NeosProject) | |
} | |
sublimeProject() { | |
sublime $(NeosProject) | |
} | |
pstormProject() { | |
pstorm $(NeosProject) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment