tmux-cpu icon indicating copy to clipboard operation
tmux-cpu copied to clipboard

Replace date with perl to fix get_time() on macOS

Open Frederick888 opened this issue 11 months ago • 0 comments

The BSD date on macOS doesn't support %N. It just prints a literal N (e.g. '1738285044.N'), which breaks the awk command in get_cache_val(), stopping cached values from being updated.

Instead, I found this perl command at [1]. Tested on macOS, Arch Linux, and OpenWRT (which has a minimal perl distribution. By the way, BusyBox date doesn't support %N either but it just prints e.g. '1738285044.' without an 'N'. So while the awk command works, [2] didn't really improve the time precision here).

[1] https://apple.stackexchange.com/a/359718/254536 [2] https://github.com/tmux-plugins/tmux-cpu/pull/56/files#diff-e015cc3ac522b202bb23852488a7ac2c019e2c82568ecb387b97b60ebbecdf4bR72-R74

Frederick888 avatar Jan 31 '25 01:01 Frederick888