Closed webnetwiz closed 9 months ago
Got the WAN IP (public IP) portion working by editing this line in the tmux.conf.local file to look like this:
tmux_conf_theme_status_right=' #{prefix}#{pairing}#{synchronized}, #(curl icanhazip.com) , #{?battery_status, #{battery_status},}#{?battery_bar, #{battery_bar},}#{?battery_percentage, #{battery_percentage},} , %R , %d %b | #{username}#{root} | #{hostname} '
Wonder if anyone can help out with the local ip portion and bandwidth up/down indicators...
@webnetwiz Don't icanhazip.com, give you limit quota by query so many times in a day?
@webnetwiz I using this command ip route get 1.2.3.4 | cut -d " " -f 7
to print LAN IP
How can we get the feature?, this is so helpful, @gpakosz what can I do to help?
in order to get the public IP we can also use the following command dig +short myip.opendns.com @resolver1.opendns.com
for the local ip address we can use ifconfig | grep 'inet ' | awk 'NR==1 {print $2}'
or use the name of the interface.
And for this
ip route get 1.2.3.4 | cut -d " " -f 7
This doesn't work on mac, I know my command isn't perfect cause ifconfig has removed from linux but maybe we can integrate both commands
How can we get the feature?, this is so helpful, @gpakosz what can I do to help? in order to get the public IP we can also use the following command
dig +short myip.opendns.com @resolver1.opendns.com
for the local ip address we can use
ifconfig | grep 'inet ' | awk 'NR==1 {print $2}'
or use the name of the interface.And for this
ip route get 1.2.3.4 | cut -d " " -f 7
This doesn't work on mac, I know my command isn't perfect cause ifconfig has removed from linux but maybe we can integrate both commands
on linux hostname -I
works to get just the ips of the network interfaces does that work on mac?
Hi @Fuseteam
On my mac is doesn't work.
Regards, Moshe
While I think this feature is definitely useful, I'm not sure it should be part of the core .tmux.conf
.
We already have TPM support and this type of functionality seems best to be leveraged from a plugin, for example https://github.com/0xAF/tmux-public-ip
Hello there.
My 2 cents: it's less about Oh My Tmux! vs TPM than "should the configuration run a dig query or ping an external whatsmyip site (which could fail) every 15s when the status bar refreshes"? Comparatively, how often do you expect your WAN IP address to change? What's even the need to always have it at hand (apart from aesthetics)?
You don't even need a full fledge plugin per se, and you can adapt the weather()
custom function described in the sample .tmux.conf.local
sample and create a wanip()
function that does curl ifconfig.me
Hi @Fuseteam
On my mac is doesn't work.
Regards, Moshe
thanks now I know
Hi @gpakosz
I created this function like weather()
, How do I append that to the status bar?
Regards, Moshe
Hey @mosheDO 👋
If you named the function foo()
, you need to use #{foo}
in tmux_conf_theme_status_left
or tmux_conf_theme_status_right
@gpakosz thanks
Can I add a PR to this repo? only the functions? If so, to which files I need to add those changes?
Regards, Moshe
Can I add a PR to this repo?
Thanks for the offer but I'm hesitating collecting every custom function one might need in the sample .tmux.conf.local
Ok, so not sure where I need to change that (in which file?) in order for me to get those changes locally
@mosheDO you should have your own .tmux.conf.local
copy placed in your home directory
@gpakosz
I get an unknown command weather()
when trying to save the .tmux.conf.local
file, do u know why?
@mosheDO did you call it as #{weather}
?
@mosheDO Likely you "uncommented" the weather()
function. You should not do that. I just pushed a note: https://github.com/gpakosz/.tmux/blob/5abe651ccb810c90b13758a30e3100c8a6d5551a/.tmux.conf.local#L394
Yes, this is what I did, but now it works, thank u @gpakosz, this feature is really useful to me
@gpakosz if I wanted to do wanip would I just added a new function like this?
# -- custom variables ----------------------------------------------------------
# to define a custom #{foo} variable, define a POSIX shell function between the
# '# EOF' and the '# "$@"' lines. Please note that the opening brace { character
# must be on the same line as the function name otherwise the parse won't detect
# it.
#
# then, use #{foo} in e.g. the 'tmux_conf_theme_status_left' or the
# 'tmux_conf_theme_status_right' variables.
# # /!\ do not remove the following line
# EOF
#
# # /!\ do not "uncomment" the functions: the leading "# " characters are needed
#
# weather() {
# curl -m 1 wttr.in?format=3 2>/dev/null
# sleep 900 # sleep for 15 minutes, throttle network requests whatever the value of status-interval
# }
#
# wanip() {
# curl -m 1 ifconfig.me 2>/dev/null
# sleep 900 # sleep for 15 minutes, throttle network requests whatever the value of status-interval
# }
#
# online() {
# ping -c 1 1.1.1.1 >/dev/null 2>&1 && printf '✔' || printf '✘'
# }
#
# "$@"
# # /!\ do not remove the previous line
Hello!
Please tell me.
If I have a web resource address, how can I connect to it through this program?
Hello,
This tmux config is really awesome, and I no longer have to install powerline and deal with all of its dependencies. That being said, I'm having a bit of a hard time adding this line:
set -g status-right "#[fg=green]: #h : #[fg=brightblue]#(curl icanhazip.com) #[fg=yellow]#(ifconfig en0 | grep 'inet ' | awk '{print \"en0 \" $2}') #(ifconfig en1 | grep 'inet ' | awk '{print \"en1 \" $2}') #[fg=red]#(ifconfig tun0 | grep 'inet ' | awk '{print \"vpn \" $2}') "
To this portion of the status bar:
tmux_conf_theme_status_right=' #{prefix}#{pairing}#{synchronized} #{?battery_status, #{battery_status},}#{?battery_bar, #{battery_bar},}#{?battery_percentage, #{battery_percentage},} , %R , %d %b | #{username}#{root} | #{hostname} '
The goal is to have the WAN & LAN IP addresses displayed to the left of the battery indicator.
Also, would love to know how to change the time to show seconds, and date to show the year. Thanks in advance!