Files
dasandClaude Opus 5.5 a2bffc7fe9
build / build (push) Successful in 38m26s
Terminal: Das prompt, dprompt and dbanner (0.9.1)
- das-shell 0.1.0: the Das two-line bash prompt by default (replaces the
  PS1 of Void's skel .bashrc once), dprompt (Textual prompt builder with
  presets and live preview) and dbanner (SSH login banner editor: canvas
  tools, fields with values, widgets, das-banner service for cached ones,
  Das OS logo and tryzub pictures). Python tests in make test.
- das-server 0.3.0 depends on das-shell; the server installer mentions
  dprompt and dbanner; the desktop image includes it.
- run-qemu.sh forwards the guest's SSH to localhost:2222.
- Hardware fixes: Ventoy menu icon, boot menu titles "Das OS <version>".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 09:17:10 +03:00

54 lines
1.6 KiB
Bash

# Functions behind the Das OS bash prompt (see dprompt). Sourced by
# /etc/bash/bashrc.d/das-prompt.sh and by the prompt.sh files dprompt writes.
# shellcheck shell=bash
# Colors when the terminal has at least 8 of them
__das_has_color() {
case $TERM in
*color* | xterm* | rxvt* | screen* | tmux* | linux | alacritty | foot* | kitty*) return 0 ;;
esac
[[ $(tput colors 2>/dev/null) -ge 8 ]]
}
# Sets __das_git to the branch (or short commit) and "*" when there are changes
__das_git_info() {
command -v git >/dev/null || return 1
local branch
branch=$(git symbolic-ref --short -q HEAD 2>/dev/null || git rev-parse --short -q HEAD 2>/dev/null) || return 1
[[ -n $branch ]] || return 1
if [[ -n $(git status --porcelain -uno 2>/dev/null | head -c1) ]]; then
branch+="*"
fi
__das_git=$branch
}
# Sets __das_jobs to the number of background jobs; fails when there are none
__das_jobs_count() {
local count='\j'
__das_jobs=${count@P}
((__das_jobs > 0))
}
# Runs first in PROMPT_COMMAND: keeps the exit status for the prompt and fills
# the variables of its conditional parts
__das_prompt_hook() {
__das_rc=$?
# Void's /etc/skel/.bashrc sets its own PS1 after /etc/bash/bashrc.d: put
# the Das OS one back, once, unless the user has a PS1 of their own
if [[ -n ${__das_ps1+set} ]]; then
[[ $PS1 == '[\u@\h \W]\$ ' ]] && PS1=$__das_ps1
unset __das_ps1
fi
declare -F __das_prompt_dynamic >/dev/null && __das_prompt_dynamic
return "$__das_rc"
}
__das_prompt_install() {
__das_ps1=$PS1
local cmd
for cmd in "${PROMPT_COMMAND[@]}"; do
[[ $cmd == __das_prompt_hook ]] && return 0
done
PROMPT_COMMAND=(__das_prompt_hook "${PROMPT_COMMAND[@]}")
}