Comments (25)
Works for me.
from .tmux.
Double check upgrading didn't break awk
.
from .tmux.
Hi,
I got it working with these changes:
diff --git a/.tmux.conf b/.tmux.conf
index 2e96dcf..4ae9e5a 100644
--- a/.tmux.conf
+++ b/.tmux.conf
@@ -319,7 +319,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
# eval set -- "$palette"
#
-# full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
+# full=$(awk 'BEGIN { printf "%.0f", ($charge) * $battery_bar_length }')
# battery_bar="#[bg=$battery_bg]"
# # shellcheck disable=SC2046
# [ "$full" -gt 0 ] && \
@@ -337,7 +337,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# battery_empty_fg=$2
# battery_bg=$3
#
-# full=$(awk "BEGIN { print \"%d\" ($charge) * $battery_bar_length }")
+# full=$(awk 'BEGIN { printf "%d", ($charge) * $battery_bar_length }')
# [ x"$battery_bg" != x"none" ] && \
# battery_bar="#[bg=$battery_bg]"
# [ "$full" -gt 0 ] && \
@@ -348,6 +348,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# battery_bar="$battery_bar#[fg=$battery_empty_fg]"
# fi
#
+# battery_vbar_bg='none'
# if echo "$battery_vbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $battery_vbar_palette; unset IFS; set +f; }
from .tmux.
I disagree with the first two changes. I don't understand how it can even work since $charge
won't even be expanded inside single quotes
from .tmux.
it's expanded by awk not bash
from .tmux.
but the problem is not the quotes, it's the print instead of printf and the battery_vbar_bg only being initialized inside of the if.
from .tmux.
This also works:
diff --git a/.tmux.conf b/.tmux.conf
index 2e96dcf..55c0732 100644
--- a/.tmux.conf
+++ b/.tmux.conf
@@ -337,7 +337,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# battery_empty_fg=$2
# battery_bg=$3
#
-# full=$(awk "BEGIN { print \"%d\" ($charge) * $battery_bar_length }")
+# full=$(awk "BEGIN { printf \"%d\", ($charge) * $battery_bar_length }")
# [ x"$battery_bg" != x"none" ] && \
# battery_bar="#[bg=$battery_bg]"
# [ "$full" -gt 0 ] && \
@@ -348,6 +348,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# battery_bar="$battery_bar#[fg=$battery_empty_fg]"
# fi
#
+# battery_vbar_bg='none'
# if echo "$battery_vbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $battery_vbar_palette; unset IFS; set +f; }
from .tmux.
It's expanded by awk not bash
NO. The way it works is it's expanded by Bash. Then expansion is given to Awk.
Just try it for yourself...
#!/bin/sh
charge="50 / 100"
battery_bar_length="10"
set -x
full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
set +x
echo "$full"
echo ---
set -x
full=$(awk 'BEGIN { printf "%.0f", ($charge) * $battery_bar_length }')
set +x
echo "$full"
gives
$ ./test.sh
++ awk 'BEGIN { printf "%.0f", (50 / 100) * 10 }'
+ full=5
+ set +x
5
---
++ awk 'BEGIN { printf "%.0f", ($charge) * $battery_bar_length }'
+ full=0
+ set +x
0
Also, it has to be printf
to truncate the decimal part
from .tmux.
Which version of awk
are you using?
from .tmux.
$ awk -V
GNU Awk 4.1.3, API: 1.1 (GNU MPFR 3.1.5, GNU MP 6.1.1)
from .tmux.
Again, it works for me with a stock 16.10 installed.
$ vagrant init ubuntu/yakkety64; vagrant up --provider virtualbox
$ vagrant ssh
$ cd
$ git clone https://github.com/gpakosz/.tmux.git
$ ln -s .tmux/.tmux.conf
$ tmux
from .tmux.
but I think you are right, I get the same result with the test script you pasted above.
And I think that with my first diff I would always get a full bar. Use my second diff.
from .tmux.
but that line should have printf instead of a print:
awk "BEGIN { print \"%d\" (50) * 100 }"
returns %d5000
from .tmux.
I think the difference is my tmux.conf.local you must be landing on the part the has:
full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
and I'm landing on the elif where it has the:
full=$(awk "BEGIN { printf \"%d\", ($charge) * $battery_bar_length }")
After upgrading my ubuntu I've also made some changes to my .tmux.conf.local and that might have triggered the problem, not the upgrade.
from .tmux.
Try without a ~/.tmux.conf.local
.
Also look around where tmux_conf_battery_bar_length
is defined in your buggy .tmux.conf.local
file.
from .tmux.
My ~/.tmux.conf.local is valid and tmux_conf_battery_bar_length is set to 5.
The problem is that on line 340 you should have a printf instead of a print and that battery_vbar_bg is only set if you are using heat or gradient.
Line 340 is also never used if you use heat or gradient.
With the default ~/.tmux.conf.local everything works because you never hit that part of the code.
from .tmux.
Can you tell me which palette you're using then so that I can understand the problem in detail on my side please?
from .tmux.
I'm using:
tmux_conf_battery_vbar_palette='#d70000,#ff5f00,#5fff00'
you can see my full ~/.tmux.conf.local here: https://github.com/luisdavim/dotfiles/blob/master/files/tmux.conf.local
from .tmux.
the battery status freezes to the last state after you apply my ~/.tmux.conf.local, it disappears if you reboot afterwards and starts working again if you apply the changes from my second diff.
from .tmux.
Thanks for helping debugging this 👍
from .tmux.
No problem :)
from .tmux.
Meh, force pushed as I forgot to silence the linter :(
from .tmux.
since you are updating stuff, can you add a .gitignore file containing:
plugins/
I use some plugins and I keep them in ~/.tmux the same as this...
from .tmux.
I could but doesn't that mean you should clone my configuration elsewhere?
from .tmux.
In fact, I think it's a better idea you add ~/.tmux/plugins
to a global ignore file, see https://git-scm.com/docs/gitignore
from .tmux.
Related Issues (20)
- conflict with vim < C-b >? HOT 4
- copy mode is trippin with mouse HOT 4
- `tmux_conf_battery_bar_palette="#xxxxxx,#yyyyyy,#zzzzzz"` seems broken HOT 4
- What is the recommended way to do theme customization? HOT 2
- When using {battery_vbar} or {battery_hbar}, the battery status display does not take effect. HOT 1
- Changing prefix to <C-s> works but <C-a> continues to be another prefix even after unbind HOT 1
- Question: Change bg color of status bar if prefix is active HOT 2
- unable to work with nvim-osc52 HOT 1
- .tmux.conf is ignored HOT 1
- ${TERM} always set to tmux-256color, how to change it HOT 4
- Fail to minimize back to original window/pane HOT 1
- Suggestion for keybinds HOT 2
- Statusline broken after update HOT 1
- I had some problems during the installation process
- The shortcut keys set using ohmytmux take effect, but the style is still the default style. HOT 14
- Unable to get this to work at all, using .config and migrating from dracula/snazzy (OSX Sonoma 14.4.1 M3) HOT 2
- Plugin setup and configuration is entirely skipped HOT 20
- Status Bar custom module disappearing HOT 9
- Command prompt position -- don't hide status line HOT 4
- Can't get status line to update HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from .tmux.