Home

Advertisement

Battery level in Bash prompt

  • Oct. 17th, 2008 at 3:33 PM

Originally published at Random Geekage You can comment here or there.

If you are like me and want to run mainly in command line while using a laptop, you might have trouble finding out how much charge is left in your laptop battery. GUIs always have some sort of widget that reports battery info but the command line is sorely lacking. It would suck to be typing away then your screen going dead in the middle of something important.

I have been looking for a simple solution for a while and came up with one. The idea is to print the output of the acpi command in your bash prompt. It is a pretty simple thing to do.

[ `acpi` ] is the fragment of text you need to put into the PS1 variable in your .bashrc file. My prompt looks like PS1=’[ `acpi` ]\n${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ‘

Looks complicated but the bulk of it is colour making the prompt look better. My prompt looks as such:

Hope this helps someone.

Latest Month

December 2009
S M T W T F S
  12345
6789101112
13141516171819
20212223242526
2728293031  

Tags

Syndicate

RSS Atom
Powered by LiveJournal.com
Designed by Lilia Ahner