agnoster-zsh-theme icon indicating copy to clipboard operation
agnoster-zsh-theme copied to clipboard

Q: right side of prompt - time, exit code and history ID

Open replay111 opened this issue 5 years ago • 2 comments

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?

replay111 avatar Dec 03 '19 15:12 replay111

I have this one https://github.com/romkatv/powerlevel10k

ayozemr avatar Feb 17 '20 19:02 ayozemr

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
}

replay111 avatar Feb 17 '20 22:02 replay111