Almost final zsh prompt
This commit is contained in:
@@ -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() {
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user