Update highlight-debug.sh
1 file changed, +4 -2
+4-2highlight-debug.sh
| @@ -1,7 +1,8 @@ | ||
| 1 | 1 | # Highlight the current directory for all commands |
| 2 | +# WARNING: This changes the success status code to 69 | |
| 2 | 3 | shopt -s extdebug |
| 3 | 4 | highlight() { |
| 4 | - if [ "$BASH_LOADED" = false ]; then | |
| 5 | + if [ "$BASH_LOADED" = false ] || [ "$BASH_COMMAND" = "uh" ] || [ "$BASH_COMMAND" = "hh" ] || [[ "$BASH_COMMAND" =~ "trap" ]]; then | |
| 5 | 6 | return 0 # Return 0 lets the command run how it normally would |
| 6 | 7 | fi |
| 7 | 8 | results=$(eval "$BASH_COMMAND" 2>&1) |
| @@ -13,6 +14,7 @@ highlight() { | ||
| 13 | 14 | if [ $status=0 ]; then |
| 14 | 15 | return 69 # 69 becomes your new success code |
| 15 | 16 | fi |
| 17 | + echo "status: $status" | |
| 16 | 18 | return $status # Return original error code |
| 17 | 19 | } |
| 18 | 20 | uh() { # Unset the highlight trap |
| @@ -23,4 +25,4 @@ hh() { # Set the highlight trap | ||
| 23 | 25 | echo -e "\033[32mSetting highlight trap\033[0m" |
| 24 | 26 | trap highlight DEBUG |
| 25 | 27 | } |
| 26 | -trap highlight DEBUG # Set the highlight trap by default | |
| 28 | +# trap highlight DEBUG # Set the highlight trap by default |