-
-
Save robacarp/d692be38477caf4a3d1048d4e8b8b9ca to your computer and use it in GitHub Desktop.
This file contains 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
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 |
This file contains 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
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 | |
This file contains 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
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