From a0da981ec79e17a9f61b33810d568b4c0a4764b8 Mon Sep 17 00:00:00 2001 From: Joao Patricio Date: Mon, 20 Mar 2023 11:05:08 +0000 Subject: [PATCH] Run file for running common tasks with few keystrokes :) --- run | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 run diff --git a/run b/run new file mode 100755 index 000000000..0888bd9d2 --- /dev/null +++ b/run @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Inspired on https://github.com/adriancooney/Taskfile +# Install an alias, to be able to simply execute `run` => echo 'alias run=./run' >> ~/.aliases +# + +set -e + +function help { + echo "$0 " + echo "Tasks:" + compgen -A function | cat -n +} + +function default { + help +} + +function bash { + docker-compose exec -u $(id -u) php bash +} + +# The user with native SSH capability +function coolify-bash { + docker-compose exec -u coolify php bash +} + +function root-bash { + docker-compose exec php bash +} + +# Usage: ./Taskfile envFile:set FOOBAR abc +# This will set the FOOBAR variable to "abc" in the .env file +function envFile:set { + sed -i "s#^$1=.*#$1=$2#g" .env +} + +TIMEFORMAT="Task completed in %3lR" +time "${@:-default}"