agnoster-zsh-theme
agnoster-zsh-theme copied to clipboard
Q: right side of prompt - time, exit code and history ID
question: is there a way to add on the right side of prompt information about time, last command exit code and last command history number?
I have this one https://github.com/romkatv/powerlevel10k
Hi,
I've changed a little bit agnostic theme attached to oh-my-zsh:
prompt_agnoster_precmd() {
RV=$?
vcs_info
PROMPT='%{%f%b%k%}$(prompt_agnoster_main) '
RPROMPT="$(my_right_prompt)"
}
my_right_prompt() {
local BATTERYLEVEL=`pmset -g batt | grep -Eo "\d+%" | cut -d% -f1`
local BATTERYCOLOR=green
if [ $BATTERYLEVEL -lt 90 ]; then
BATTERYCOLOR=191
fi
if [ $BATTERYLEVEL -lt 70 ]; then
BATTERYCOLOR=179
fi
if [ $BATTERYLEVEL -lt 50 ]; then
BATTERYCOLOR=174
fi
if [ $BATTERYLEVEL -lt 30 ]; then
BATTERYCOLOR=209
fi
if [ $BATTERYLEVEL -lt 15 ] ; then
BATTERYCOLOR=001
[[ $RV -ne 0 ]] && line="%{%F{red}%}$CROSS"
[[ $RV -eq 0 ]] && line="%{%F{green}%}$TICK"
local DATALONG=$(date +%Y-%m-%d\ %H:%M:%S)
local DATASHORT=$(date +%H:%M:%S)
$(battery_time_remaining) $BATTERYLEVEL%%]"
line+="[$DATASHORT]%{%F{$BATTERYCOLOR}%}[$BATTERYICON $BATTERYLEVEL%%]"
echo -n $line
}