1
0

feat: migrate from Oh-My-Zsh to ZInit

This commit is contained in:
2024-08-14 13:49:10 +02:00
parent 4a8dcfba3d
commit adc26f9860
7 changed files with 212 additions and 68 deletions

View File

@@ -31,48 +31,3 @@ split() {
(kitty . &)
}
# === FUNCTIONS FOR COMMAND TIMING ===
# Function to capture the start time of the command
preexec() {
timer_start=$EPOCHSECONDS
}
# Function to capture the end time of the command and calculate the elapsed time
precmd() {
local timer_end=$EPOCHSECONDS
local elapsed=$((timer_end - timer_start))
# Reset RPROMPT
RPROMPT=""
if (( elapsed > 36000 )); then
return
fi
if (( elapsed > 0 )); then
local color time_str
if (( elapsed >= 60 )); then
local minutes=$((elapsed / 60))
local seconds=$((elapsed % 60))
time_str="${minutes}m ${seconds}s"
color="%{$fg_bold[red]%}"
elif (( elapsed >= 10 )); then
time_str="${elapsed}s"
color="%{$fg_bold[blue]%}"
elif (( elapsed >= 5 )); then
time_str="${elapsed}s"
color="%{$fg_bold[yellow]%}"
elif (( elapsed >= 1 )); then
time_str="${elapsed}s"
color="%{$fg_bold[green]%}"
fi
# Set RPROMPT if elapsed time is greater than or equal to 1 second
if [[ -n $time_str ]]; then
RPROMPT="${color}${time_str}%{$reset_color%}"
fi
fi
timer_start=0
}