Skip to content

Instantly share code, notes, and snippets.

@FilBot3
Last active May 4, 2022 12:58
Show Gist options
  • Save FilBot3/cc89aecdb64309e2012a94176195f697 to your computer and use it in GitHub Desktop.
Save FilBot3/cc89aecdb64309e2012a94176195f697 to your computer and use it in GitHub Desktop.
A Bash shell script that can be sourced or modified for a CI/CD like script that prints and runs the command given to the function.
#!/usr/bin/env bash
function print_and_run() {
# print_and_run is useful for doing CI/CD with Shell Scripts where the entire
# process is done in a single step. This function can be used in a single
# script, or it can be sourced as a function for other scripts.
#
# Parameters
# ----------
# $@ - shell command being ran
#
# Returns
# -------
# None
time_now=$(date +"%Y-%m-%d_%Z_%T:%N")
echo -n "[${time_now}] ${@} "
exec $@
}
@FilBot3
Copy link
Author

FilBot3 commented May 4, 2022

for some reason, starting google-chrome this way doesn't actually send it to the background like other processes I run.

print_and_run "nohup google-chrome &>/dev/null &"

So, I have to figure out wtf is going on there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment