Skip to content

Instantly share code, notes, and snippets.

@ZappaBoy
Created August 10, 2022 15:10
Show Gist options
  • Save ZappaBoy/1e85ffab3394e8d7004e8c3e1322c0e2 to your computer and use it in GitHub Desktop.
Save ZappaBoy/1e85ffab3394e8d7004e8c3e1322c0e2 to your computer and use it in GitHub Desktop.
Run in background aliases
# Run in background aliases
TMP_PID_PATH=/tmp/background.pid
function background(){
echo "Running in background: $@"
nohup "$@" > /dev/null 2>&1 & echo $! > $TMP_PID_PATH
disown -a
}
alias background="background"
alias background-pid="cat \$TMP_PID_PATH"
alias background-kill="pkill -F \$TMP_PID_PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment