Skip to content

Instantly share code, notes, and snippets.

@robacarp robacarp/lolcatme.bash Secret
Last active Apr 8, 2017

Embed
What would you like to do?
function lolcatme() {
which -s lolcat
if [ $? -ne 0 ]; then
echo no lolcat
return 0
fi
if [[ "$BASH_COMMAND" == "$PROMPT_COMMAND" ]]; then
return 0
fi
if [ -e /etc/bashrc_Apple_Terminal ]; then
grep -F --quiet "'$BASH_COMMAND'" /etc/bashrc_Apple_Terminal
if [ $? -eq 0 ]; then
echo terminal boot sequence
return 0
fi
fi
unsafe_commands=('vi' 'vim' 'nano' 'emacs' 'open' 'bash' 'fish' 'zsh' 'man')
unsafe_commands+=('shell_session_history_check' 'update_terminal_cwd')
for cmd in "${unsafe_commands[@]}"; do
if [[ "'"$BASH_COMMAND"'" =~ $cmd.* ]]; then
echo unsafe command: $BASH_COMMAND
return 0
fi
done
$BASH_COMMAND | lolcat
return 2
}
shopt -s extdebug
trap 'lolcatme' DEBUG
function fish_user_key_bindings
bind \r 'lolcatme'
end
function lolcatme
set -l cmd (commandline)
set -l first (commandline --tokenize)[1]
if not contains $first vi vim emacs nano open bash fish zsh
commandline --append ' | lolcat'
end
commandline -f execute
end
setopt DEBUG_BEFORE_CMD
function lolcatme() {
eval ${ZSH_DEBUG_CMD} | lolcat
setopt ERR_EXIT
}
trap 'lolcatme' DEBUG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.