Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
replay111 opened this issue Dec 3, 2019 · 2 comments
Open

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

replay111 opened this issue Dec 3, 2019 · 2 comments
Labels

Comments

@replay111
Copy link

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?

@ayozemr
Copy link

ayozemr commented Feb 17, 2020

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

@replay111
Copy link
Author

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants