dotfiles

config files for my linux setup
git clone git://edryd.org/dotfiles
Log | Files | Refs

commit bf88b159e64c96344f627288f382ddcd3808a6ce
parent 9b02b8cdb9fb4dbc889f507dcd1568dd482f8e50
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Mon,  9 Apr 2018 23:15:37 -0700

bash: Replace checkium with echk

Diffstat:
bashrc | 4++--
bin/checkium.sh | 65-----------------------------------------------------------------
bin/echk | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+), 67 deletions(-)

diff --git a/bashrc b/bashrc @@ -53,7 +53,7 @@ git_color() { } PS1='\[${Blue}\]\u \ -\[$(checkium_color)\]$(checkium_random_face) \ +\[$(echk_color)\]$(echk_random_face) \ \[$(git_color)\]$(__git_ps1 "%s ")\[${Yellow}\]\ $([ \j -gt 0 ] && echo "\j ")\[${White}\]\ \$\[${Color_Off}\] ' @@ -78,7 +78,7 @@ export GPG_TTY=$(tty) # load other files source ~/bin/ED.sh -source ~/bin/checkium.sh +source ~/bin/echk source ~/bin/colors.sh source ~/bin/z.sh diff --git a/bin/checkium.sh b/bin/checkium.sh @@ -1,65 +0,0 @@ -#!/usr/bin/env bash - -checkium_color() { - # set color depending on if the last command succeed or not - if [[ $? -eq 0 ]]; then - echo -ne "\033[0;32m" - return 0 - else - echo -ne "\033[0;31m" - # need to return a value so that the other functions here will - # know if last command ran OK or not, the previous code will return 0 - return 1 - fi -} - -checkium_color_simple() { - if [[ $? -eq 0 ]]; then - return 0 - else - echo -ne "\033[0;31m" - return 1 - fi -} - -checkium_custom() { - if [[ $? -eq 0 ]]; then - local char=$1 - else - local char=$2 - fi - echo $char -} - -checkium_check() { - if [[ $? -eq 0 ]]; then - local char="✓" - else - local char="✗ " - fi - echo $char -} - -checkium_face() { - if [[ $? -eq 0 ]]; then - local face=":)" - else - local face=":(" - fi - echo $face -} - -checkium_random_face() { - # set arrays for different faces to randomly choose from - if [[ $? -eq 0 ]]; then - local faces=(":)" ":D") - else - local faces=(":P" ":(" ":(" ":O" ":\\" ":|" ":(" ":(") - fi - - local facels=${#faces[*]} # get how many elements are in each array - local randfacels=${faces[$((RANDOM % facels))]} # randomly choose an array element - echo $randfacels # print that face - -} - diff --git a/bin/echk b/bin/echk @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# echk: functions to display shell error code + +echk_color() { + # set color depending on if the last command succeed or not + if [[ $? -eq 0 ]]; then + echo -ne "\033[0;32m" + return 0 + else + echo -ne "\033[0;31m" + # need to return a value so that the other functions here will + # know if last command ran OK or not, the previous code will return 0 + return 1 # TODO $? + fi +} + +echk_color_simple() { + if [[ $? -eq 0 ]]; then + return 0 + else + echo -ne "\033[0;31m" + return 1 + fi +} + +echk_char() { + if [[ $? -eq 0 ]]; then + echo "$1" + else + echo "$2" + fi +} + +echk_check() { + echk_char "✓" "✗ " +} + +echk_face() { + echk_char ":)" ":(" +} + +echk_random_face() { + # set arrays for different faces to randomly choose from + if [[ $? -eq 0 ]]; then + local faces=(":)" ":D") + else + local faces=(":P" ":(" ":/" ":O" ":\\" ":|" ":(" ":(") + fi + + echo ${faces[$((RANDOM % ${#faces[*]}))]} # randomly choose an array element +}