Skip to content

Instantly share code, notes, and snippets.

@linux4life798
Last active November 19, 2025 18:46
Show Gist options
  • Select an option

  • Save linux4life798/57e932a26edbd9398332ba153111a662 to your computer and use it in GitHub Desktop.

Select an option

Save linux4life798/57e932a26edbd9398332ba153111a662 to your computer and use it in GitHub Desktop.
My bash msg-run function, but self contained for easy copy/paste. The full version can be found https://github.com/linux4life798/bash-includes/blob/main/bash_include.d/1-msg-print.bash .
# https://github.com/linux4life798/bash-includes/blob/main/bash_include.d/1-msg-print.bash
# Print command in Blue and then run it.
# Usage: msg-run [cmd] [args...]
#
# Example: msg-run confirm
msg-run() {
local f="" redir=""
for f in " <$(readlink /proc/$$/fd/0)" " >$(readlink /proc/$$/fd/1)" " 2>$(readlink /proc/$$/fd/2)"; do
redir+="${f##*/dev/pts/*}"
done
printf "\E[34m%s\E[m\n" "> $*${redir}" >&2
"$@"
#local ret="$?"; echo "Returned ${ret}" >&2; return "${ret}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment