Skip to content

Instantly share code, notes, and snippets.

@bootjp
Last active January 29, 2017 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bootjp/92488227c7d69beeffae0b2bf720a297 to your computer and use it in GitHub Desktop.
Save bootjp/92488227c7d69beeffae0b2bf720a297 to your computer and use it in GitHub Desktop.
bash command error view. fork from : http://qiita.com/takayuki206/items/f4d0dbb45e5ee2ee698e
# this file added ~/.bashrc
# fork from http://qiita.com/takayuki206/items/f4d0dbb45e5ee2ee698e
function __show_exit_code() {
local status=$(echo ${PIPESTATUS[@]})
local SETCOLOR_FAILURE="echo -en \\033[1;31m"
local SETCOLOR_NORMAL="echo -en \\033[0;39m"
for s in ${status}
do
if [ ${s} -ne 0 ]; then
${SETCOLOR_FAILURE}
echo -e "[\xe2\x9a\xa0\xef\xb8\x8f -> ${status// /|}]"
${SETCOLOR_NORMAL}
fi
done
}
PROMPT_COMMAND='__show_exit_code;'${PROMPT_COMMAND//__show_exit_code;/}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment