Skip to content

Instantly share code, notes, and snippets.

@manicolosi
Last active August 29, 2015 14:04
Show Gist options
  • Save manicolosi/d67cb56b673f07c2d587 to your computer and use it in GitHub Desktop.
Save manicolosi/d67cb56b673f07c2d587 to your computer and use it in GitHub Desktop.
Troll tool for Mark B.
# Source this thing from bash
trap 'preexec_invoke_exec' DEBUG
preexec () { :; }
preexec_invoke_exec () {
[ -n "$COMP_LINE" ] && return # do nothing if completing
[ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return # don't cause a preexec for $PROMPT_COMMAND
local this_command=`history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//g"`;
preexec "$this_command"
}
preexec() {
if [ $PWD = ~ ]; then
w="~"
else
w=$(basename $PWD)
fi
p="$PS1"
p="${PS1//\\u/$USER}"
p="${p//\\h/$HOSTNAME}"
p="${p//\\w/$w}"
eval echo $p | say
say $1
eval $1 | say
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment