Skip to content

Instantly share code, notes, and snippets.

@cray0000
Created July 24, 2019 19:39
Show Gist options
  • Save cray0000/a78c3c01775fb53f4dbd3d10fa939aac to your computer and use it in GitHub Desktop.
Save cray0000/a78c3c01775fb53f4dbd3d10fa939aac to your computer and use it in GitHub Desktop.
bash. Clear terminal after each command.
# add it to ~/.bash_profile
# Clear terminal before each command execution
preexec () {
echo -e "\033];$1\007";
echo -e "\033[1;34m------------------------------------------------------------------------------------------------\033[0m";
clear;
echo -e "\033[1;34m$1\033[0m";
}
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"`; # obtain the command from the history, removing the history number at the beginning
preexec "$this_command"
}
trap 'preexec_invoke_exec' DEBUG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment