Skip to main content
added 593 characters in body
Source Link
alchemy
  • 817
  • 1
  • 12
  • 26

Add this to you Bash profile file:

nohist() { history -d $HISTCMD; }; trap nohist ERR

EDIT: this is better as the error line can be retrieved easily:

ce() { eval "$BASH_COMMAND;  e='$BASH_COMMAND'"; false; }
if [[ $- == *i* ]]; then trap ce ERR; fi # capture error command
alias e='$e' # type e and then expand with ctrl-alt-e

Also, this will capture every output for reuse (but it has an issue with echo and hist

save_output() { 
   exec 1>&3 
   { [ -f /tmp/current ] && mv /tmp/current /tmp/last; }
   exec > >(tee /tmp/current)
}

exec 3>&1
trap save_output DEBUG

https://stackoverflow.com/a/48398357/4240654

Add this to you Bash profile file:

nohist() { history -d $HISTCMD; }; trap nohist ERR

Add this to you Bash profile file:

nohist() { history -d $HISTCMD; }; trap nohist ERR

EDIT: this is better as the error line can be retrieved easily:

ce() { eval "$BASH_COMMAND;  e='$BASH_COMMAND'"; false; }
if [[ $- == *i* ]]; then trap ce ERR; fi # capture error command
alias e='$e' # type e and then expand with ctrl-alt-e

Also, this will capture every output for reuse (but it has an issue with echo and hist

save_output() { 
   exec 1>&3 
   { [ -f /tmp/current ] && mv /tmp/current /tmp/last; }
   exec > >(tee /tmp/current)
}

exec 3>&1
trap save_output DEBUG

https://stackoverflow.com/a/48398357/4240654

Formatting
Source Link
AdminBee
  • 23.6k
  • 25
  • 56
  • 77

Add this to you Bash profile file. nohist() { history -d $HISTCMD; }; trap nohist ERR:

nohist() { history -d $HISTCMD; }; trap nohist ERR

Add this to you Bash profile file. nohist() { history -d $HISTCMD; }; trap nohist ERR

Add this to you Bash profile file:

nohist() { history -d $HISTCMD; }; trap nohist ERR
Source Link
alchemy
  • 817
  • 1
  • 12
  • 26

Add this to you Bash profile file. nohist() { history -d $HISTCMD; }; trap nohist ERR