GithubHelp home page GithubHelp logo

errorscream's Introduction

Using ErrorScream

You can source the script in your bashrc. Or write an alias to source the script for your particular terminal session.

Want to mess with a developer on your team? Put this in their bashrc. ๐Ÿคก

Program will do no harm to your computer.

How does it work?
trap <code> ERR
Runs a line of code if there is an error before presenting the output of your command.
This project traps on err and uses say for a mac to shout the last entry of the history command.

Installation

git clone https://github.com/MichaelDimmitt/ERRORSCREAM.git; cd ERRORSCREAM; cat scream_we_all_scream_for_sh.sh; . scream_we_all_scream_for_sh.sh;

errorscream's People

Contributors

michaeldimmitt avatar

Stargazers

Travis Vachon avatar

Watchers

Travis Vachon avatar James Cloos avatar  avatar

errorscream's Issues

Solution for Error Scream summarized

It works!

Solution

trap 'say $(history | tail -1 | cut -c 8-) failed with error code $?' ERR

notes:

PROMPT_COMMAND='echo "$(history | tail -1 | cut -c 8-)"'
trap 'say $BASH_COMMAND failed with error code $?' ERR

Do this so it will work; or the other things listed ๐Ÿ˜‹

trap on debug lets you evaluate every single command ๐Ÿ˜…

example:

trap date DEBUG

Prompt command causes a command to run after every command.

example:

PROMPT_COMMAND=date

useful resources:
https://stackoverflow.com/questions/45123034/execute-command-after-every-command-in-bash
side note - did you know bash is written in c? https://github.com/gitGNU/gnu_bash

Check error codes and make sure everything works.

error_message(){
  # per request:
  say 'MICHAEL SCOTT "no GOD NOO"'
  ## future case, support different voices by changing mac defaults.
  say $@
  ## say $1 $2
}
check_errs()
{
  if [ "${1}" -ne "0" ]; then
	error_message "${1}" "${2}"
    # as a bonus, make our script exit with the right error code.
    exit ${1}
  fi
}
check_errs $?

useful link:
https://www.shellscript.sh/exitcodes.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.