Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [FEATURE REQUEST] Adding battery power to bigfade prompt



On 2016-12-27 01:51:28 +0530, shirish शिरीष wrote:
> Please CC me if anybody answers to this mail as I'm not subscribed to
> the zsh-workers mailing list.
> 
> Hi all,
> I have been playing around and recently came to know about zsh
> prompts. I tried a few and had issues with a prompt which I was able
> to solve -
> 
> http://unix.stackexchange.com/questions/332732/removing-strange-characters-from-a-zsh-prompt
> 
> Now, first of all i want to thank Adam who converted the theme to be
> used in zsh.
> 
> Now while I was looking at that, I saw there was still something
> missing in the bigfade prompt and realized it was not having battery
> power on the right-hand side of the command prompt.
[...]

FYI, I use the following on my Linux laptops for my prompt config:

updprompt()
{
  psvar[2]=""
  local battery="$(acpi -b)"
  [[ $battery == *Discharging* ]] &&
    psvar[2]="[${${battery#*Discharging, }%\%,*}%]"

  unset _trapchld_called
# ...
  [[ -n $_trapchld_called ]] && updprompt
}

This function is called from precmd, but also from

TRAPCHLD()
{
  if [[ -o interactive && -n $TTY ]] then
    updprompt
    typeset -g _trapchld_called=1
  fi
}

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



Messages sorted by: Reverse Date, Date, Thread, Author