Last active
November 19, 2025 18:46
-
-
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 .
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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