From f1646abba62fd60fa73f486bf55efa921a8225aa Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Sat, 16 Feb 2019 23:01:30 +0530 Subject: [PATCH] Add exit_code, bg_jobs plugins. Minor fix to vcs.sh --- plugins/bg_jobs.sh | 22 ++++++++++++++++++++++ plugins/exit_code.sh | 20 ++++++++++++++++++++ plugins/vcs.sh | 2 +- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 plugins/bg_jobs.sh create mode 100644 plugins/exit_code.sh diff --git a/plugins/bg_jobs.sh b/plugins/bg_jobs.sh new file mode 100644 index 0000000..9340661 --- /dev/null +++ b/plugins/bg_jobs.sh @@ -0,0 +1,22 @@ +function wish_bg_jobs_start() { + return 0 +} + +function wish_bg_jobs_end() { + return 0 +} + +function wish_bg_jobs_set_colors() { + WISH_BG_JOBS_FG=${WISH_BG_JOBS_FG:-$WISH_DEFAULT_FG} + WISH_BG_JOBS_BG=${WISH_BG_JOBS_BG:-$WISH_DEFAULT_BG} + WISH_BG_JOBS_SUFFIX=${WISH_BG_JOBS_SUFFIX:-&} +} + +function wish_bg_jobs_main() { + local x=$(jobs -p | wc -l) + if [[ $x == 0 ]]; then + wish_append $WISH_BG_JOBS_BG $WISH_BG_JOBS_FG "" + else + wish_append $WISH_BG_JOBS_BG $WISH_BG_JOBS_FG " $x$WISH_BG_JOBS_SUFFIX " + fi +} diff --git a/plugins/exit_code.sh b/plugins/exit_code.sh new file mode 100644 index 0000000..b63505a --- /dev/null +++ b/plugins/exit_code.sh @@ -0,0 +1,20 @@ +function wish_exit_code_start() { + return 0 +} + +function wish_exit_code_end() { + return 0 +} + +function wish_exit_code_set_colors() { + WISH_EXIT_CODE_FG=${WISH_EXIT_CODE_FG:-$WISH_DEFAULT_FG} + WISH_EXIT_CODE_BG=${WISH_EXIT_CODE_BG:-$WISH_DEFAULT_BG} +} + +function wish_exit_code_main() { + if [[ $1 == 0 ]]; then + wish_append $WISH_EXIT_CODE_BG $WISH_EXIT_CODE_FG "" + else + wish_append $WISH_EXIT_CODE_BG $WISH_EXIT_CODE_FG $1 + fi +} diff --git a/plugins/vcs.sh b/plugins/vcs.sh index d0f21ff..be27696 100644 --- a/plugins/vcs.sh +++ b/plugins/vcs.sh @@ -26,7 +26,7 @@ function wish_vcs_main() { local add=$(echo "$op" | awk '{a += $1} END {print a}') local del=$(echo "$op" | awk '{d += $2} END {print d}') - if [[ $add != 0 ]] && [[ $del != 0 ]]; then + if [[ $add != 0 ]] || [[ $del != 0 ]]; then git="$git+$add -$del " fi wish_append $WISH_VCS_BG $WISH_VCS_FG "$git"