Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Created January 8, 2014 20:37
Show Gist options
  • Save coderofsalvation/8324175 to your computer and use it in GitHub Desktop.
Save coderofsalvation/8324175 to your computer and use it in GitHub Desktop.
# flexible xmessage (uses xmessage or gmessage) or printf for printing messages
function x11message()
{ #prints a message using xmessage || gxmessage
[ -z "$1" ] && return 1
XMESSAGE=$(command -v gxmessage 2>/dev/null) || XMESSAGE=$(command -v xmessage 2>/dev/null)
MESSAGE="$(expr "$0" : '.*/\([^/]*\)'): $*"
printf "%s\\n" "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2
if [ -n "$DISPLAY" ] && [ -n "$XMESSAGE" ]; then
printf "%s\\n" "$MESSAGE" | fold -s -w ${COLUMNS:-80} | $XMESSAGE -center -file -
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment