From 85081ecec3e728ba91cee19e9f73f8dee21bef23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Sat, 18 Apr 2026 09:29:59 +0200 Subject: [PATCH] Almost final zsh prompt --- private_dot_config/zsh/dot_zshrc | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/private_dot_config/zsh/dot_zshrc b/private_dot_config/zsh/dot_zshrc index 53ad16d..d6a1be7 100644 --- a/private_dot_config/zsh/dot_zshrc +++ b/private_dot_config/zsh/dot_zshrc @@ -108,20 +108,32 @@ source <(fzf --zsh) # allow for fzf history widget # set up prompt NEWLINE=$'\n' POWERLINE_START="\ue0d4" +POWERLINE_START_INV="\ue0d2" POWERLINE_SEPARATOR="\ue0c7" POWERLINE_STOP="\ue0b4" +POWERLINE_STOP_INV="\ue0b6" PROMPT_ENTER="" #"\ueb70" +PROMPT_PAD="." +PROMPT_EXTRA_WIDTH=73 precmd() { - local exec_ts=$(($(date +%s%N) - STARTCMD_TS)) - local seconds=$(echo "scale=9; $exec_ts / 1000000000" | bc) - local hours=$((seconds / 3600)) - local minutes=$(((seconds % 3600) / 60)) - seconds=$((seconds % 60)) - local exec_str=$(printf "%02d:%02d:%06.3f" hours minutes seconds) + if (($COLUMNS > PROMPT_EXTRA_WIDTH)); then + local exec_ts=$(($(date +%s%N) - STARTCMD_TS)) + local seconds=$(echo "scale=9; $exec_ts / 1000000000" | bc) + local hours=$((seconds / 3600)) + local minutes=$(((seconds % 3600) / 60)) + seconds=$((seconds % 60)) + local exec_str=$(printf "%02d:%02d:%06.3f" hours minutes seconds) + local padding=$(printf %$(($COLUMNS - 73))s | tr ' ' $PROMPT_PAD) + extra_prompt="%k%f${padding}${POWERLINE_STOP_INV}%K{${FG3}}%F{${BG3}}${POWERLINE_SEPARATOR}%K{${BG3}}%F{${FG3}} took ${exec_str} \uf252%K{${BG3}}%F{${BG2}}${POWERLINE_SEPARATOR}%K{${BG2}}%F{${FG2}}at $(date +%H:%M:%S) \uf017 %k%F{${BG2}}${POWERLINE_START_INV}" + else + extra_prompt="" + fi + print "" # empty line to increase readability - print -P "%F{${BG1}}${POWERLINE_START}%K{${BG1}}%F{${FG1}} %y on %M %K{${BG1}}%F{${BG2}}${POWERLINE_SEPARATOR}%K{${BG2}}%F{${FG2}} %n %K{${BG2}}%F{${BG3}}${POWERLINE_SEPARATOR}%K{${BG3}}%F{${FG3}} %~ %K{${BG3}}%F{${FG4}}${POWERLINE_SEPARATOR}%k%F{${FG4}}${POWERLINE_STOP}%k%f...%K{${BG3}}%F{${FG3}} took ${exec_str} \uf252 %K{${BG2}}%F{${FG2}} at $(date +%H:%M:%S) \uf017" + print -P "%F{${BG1}}${POWERLINE_START}%K{${BG1}}%F{${FG1}} %y on %M %K{${BG1}}%F{${BG2}}${POWERLINE_SEPARATOR}%K{${BG2}}%F{${FG2}} %n %K{${BG2}}%F{${BG3}}${POWERLINE_SEPARATOR}%K{${BG3}}%F{${FG3}} %~ %K{${BG3}}%F{${FG4}}${POWERLINE_SEPARATOR}%k%F{${FG4}}${POWERLINE_STOP}${extra_prompt}" + STARTCMD_TS=$(date +%s%N) } preexec() {