Created
November 3, 2025 12:08
-
-
Save yuki-yano/636184c3ca326e19cc76351e34ac3517 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setopt prompt_subst | |
| zmodload -i zsh/parameter | |
| : ${SUSP_JOBS_MAX:=3} | |
| : ${SUSP_JOBS_ICON:=$'\u23F8'} | |
| : ${SUSP_JOBS_COLOR:='%F{yellow}'} | |
| typeset -g SUSP_JOBS_RPROMPT="" | |
| function __susp_jobs_update_rprompt() { | |
| local -a ids shown | |
| local k state txt | |
| for k in ${(k)jobstates}; do | |
| state=${jobstates[$k]} | |
| [[ ${state%%:*} == suspended ]] && ids+="$k" | |
| done | |
| if (( ${#ids} )); then | |
| local i | |
| for i in ${ids}; do | |
| txt=${jobtexts[$i]} | |
| shown+="${i}:${${txt%% *}:-${txt}}" | |
| (( ${#shown} >= SUSP_JOBS_MAX )) && break | |
| done | |
| local rest=$(( ${#ids} - ${#shown} )) | |
| local body="${(j: :)shown}" | |
| (( rest > 0 )) && body+=" +${rest}" | |
| typeset -g SUSP_JOBS_RPROMPT="${SUSP_JOBS_COLOR}${SUSP_JOBS_ICON} ${body}%f" | |
| else | |
| typeset -g SUSP_JOBS_RPROMPT="" | |
| fi | |
| } | |
| precmd_functions+=(__susp_jobs_update_rprompt) | |
| if [[ -z ${SUSP_JOBS_KEEP_RPROMPT+x} ]]; then | |
| RPROMPT='${SUSP_JOBS_RPROMPT}'"${RPROMPT}" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment