Skip to content

Instantly share code, notes, and snippets.

@hugollm
Last active September 24, 2017 16:47
Show Gist options
  • Save hugollm/fcd7d6caf2e9f54cf154d1e28efb88e4 to your computer and use it in GitHub Desktop.
Save hugollm/fcd7d6caf2e9f54cf154d1e28efb88e4 to your computer and use it in GitHub Desktop.
bashrc script to add newlines before and after each prompt, for easier reading
#---------------------------------------------
# Newlines before and after each prompt line
#---------------------------------------------
function pre_command() {
printf "\n"
}
function post_command() {
printf "\n"
}
function pre_command_hook() {
if [ -z "$AT_PROMPT" ]; then
return
fi
unset AT_PROMPT
pre_command
}
function post_command_hook() {
AT_PROMPT=1
if [ -n "$FIRST_PROMPT" ]; then
unset FIRST_PROMPT
return
fi
post_command
}
FIRST_PROMPT=1
trap "pre_command_hook" DEBUG
PROMPT_COMMAND="post_command_hook"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment