Skip to content

Instantly share code, notes, and snippets.

@dacostafilipe
Last active April 4, 2019 13:46
Show Gist options
  • Save dacostafilipe/a1ac94d5b846ddc8f1e50312da751ac0 to your computer and use it in GitHub Desktop.
Save dacostafilipe/a1ac94d5b846ddc8f1e50312da751ac0 to your computer and use it in GitHub Desktop.
bitbar Plugin for ddev
#!/bin/bash
# Display status of DDEV configs
#
#
# <bitbar.title>DDEV List</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>DA COSTA Filipe</bitbar.author>
#
export PATH="/usr/local/bin:/usr/bin:/bin:$PATH"
echo "DDEV"
echo "---"
LIST=$(ddev list | sed '/http:/!d')
while read -r line; do
NAME=$(echo $line | cut -f1 -d" ")
TYPE=$(echo $line | cut -f2 -d" ")
SOURCE=$(echo $line | cut -f3 -d" ")
URI=$(echo $line | cut -f4 -d" ")
STATUS=$(echo $line | cut -f5 -d" ")
if [ "$STATUS" == "running" ]; then
COLOR='green'
else
COLOR='red'
fi
echo "${NAME} | color=${COLOR}"
if [ "$STATUS" == "running" ]; then
echo "--${URI} | href='${URI}'"
echo "--SSH"
echo "----Web | bash='cd ${SOURCE}; ddev ssh'"
echo "----Database | bash='cd ${SOURCE}; ddev ssh --service db'"
echo "-----"
echo "--Restart | bash='ddev restart ${NAME}'"
echo "--Stop | bash='ddev stop ${NAME}'"
else
echo "--Start | bash='ddev start ${NAME}'"
fi
echo "---"
done <<< "$LIST"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment