commit: 22b420df21634a6e2881bcf3bb75ad5599dd579b
parent d774b8db6eae063845934368b9a90820ed4d036c
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Mon, 3 May 2021 13:24:08 +0200
.common.sh: Add № of jobs to PS1
Diffstat:
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/.common.sh b/.common.sh
@@ -59,13 +59,21 @@ case $(hostname) in
*) host_ansi="31" ;;
esac
+jobs_pp() {
+ job_count="$(jobs | wc -l)"
+
+ if [[ "${job_count}" != "0" ]]; then
+ echo -n "[30;46m${job_count}⏾[47;36m"
+ fi
+}
+
case $SHELL in
*ksh*)
# hack derived from ksh88(1), works in mksh, doesn't works in bash
- export PS1='
[47;30m$?[37;100m[100;30m$(date +w%wT%T)[40;90m[40;32m${USER}[${host_ansi}m@$(hostname)[30;46m$(get_working_directory)$(get_git_branch)[0m '
+ export PS1='
$(jobs_pp)[47;30m$?[37;100m[100;30m$(date +w%wT%T)[40;90m[40;32m${USER}[${host_ansi}m@$(hostname)[30;46m$(get_working_directory)$(get_git_branch)[0m '
;;
*bash*)
- export PS1='\[\e[47;30m\]$?\[\e[37;100m\]\[\e[100;30m\]$(date +w%wT%T)\[\e[40;90m\]\[\e[40;32m\]\u\[\e[${host_ansi}m\]@\h\]\[\e[30;46m\]$(get_working_directory)\[\e[0;36m\]\[\e[0m\] '
+ export PS1='\[\e[47;30m\]$(jobs_pp)$?\[\e[37;100m\]\[\e[100;30m\]$(date +w%wT%T)\[\e[40;90m\]\[\e[40;32m\]\u\[\e[${host_ansi}m\]@\h\]\[\e[30;46m\]$(get_working_directory)\[\e[0;36m\]\[\e[0m\] '
;;
*)
# Don't even try escape codes, and so no powerline-style