# 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)
}