1

I have been using zsh 5.3 for sometime now. I finally managed to have a prompt that I like (see my own answer) -

Big Fade prompt in zsh

Now I want to add battery status to my zsh prompt on the right-corner so I always know how much battery is remaining . How do I do it ?

Update - I saw Paul H.'s comment and saw the stackoverflow answers and saw https://stackoverflow.com/a/34913418 . I like that one EXCEPT that one shows the battery in left and I want it to show on the right.

Any ideas ?

1

2 Answers 2

1

With zsh you can easily set prompts on the right side by using the RPROMPT parameter (alternatively RPS1). Assuming you already have a way to retrive the battery status, lets say via a command called batstat, you just have to set the following in your ~/.zshrc:

RPROMPT='$(batstat)'

The prompt will be displayed on the right side on same line as the last line of the left side prompt, that is on the line where the input cursor is initially placed. Multi-line right side prompt are not possible. Should you type a command long enough to reach the right side prompt, zsh will hide all of it automatically.

1

This helped me,

pmset -g batt | grep -Eo "\d+%" | cut -d% -f1

EDIT: This is for mac

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .