Created
July 24, 2019 19:39
-
-
Save cray0000/a78c3c01775fb53f4dbd3d10fa939aac to your computer and use it in GitHub Desktop.
bash. Clear terminal after each command.
This file contains hidden or 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
# 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