tmux-battery | play battery percentage and icon indicator | Command Line Interface library
kandi X-RAY | tmux-battery Summary
kandi X-RAY | tmux-battery Summary
Enables displaying battery percentage and status icon in tmux status-right.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of tmux-battery
tmux-battery Key Features
tmux-battery Examples and Code Snippets
Community Discussions
Trending Discussions on tmux-battery
QUESTION
I want to pad a format string to a certain length. For example, the Tmux Battery plugin introduces the battery_percentage
format string. I can use this in the status bar as #{battery_percentage}
. The battery percentage values can be:
- Between 0% and 9% (One Digit).
- Between 11% and 99% (Two Digits).
- Exactly 100% (Three Digits).
I want the format string to always be displayed 3 digits, padded with spaces at the end, how can I achieve that?
I saw that there is the format #{pN:variable}
in this page, but it did not work when I tried to use it with format strings, even though at the end they are variables. Maybe I just did not know how to use it, I don't know...
ANSWER
Answered 2021-Jan-14 at 18:53Looking at the plugin startup code, battery.tmux, you can see that ${battery_percentage}
is actually converted to #($CURRENT_DIR/scripts/battery_percentage.sh)
, which is a request to run a script. I don't know if #{p3:#(...)}
can be made to work since this is not a simple variable.
You could always edit the plugin shell script to return the padded string (assuming tmux keeps the leading spaces).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install tmux-battery
pmset (MacOS only)
acpi
upower
termux-battery-status
apm
Add plugin to the list of TPM plugins in .tmux.conf:. Hit <prefix> + I to fetch the plugin and source it. If format strings are added to status-right, they should now be visible.
Add this line to the bottom of .tmux.conf:.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page