Browse Source

* set curl timeout for fetching ip-address to non fractional number, because on some systems catching error about max-time option as "expected a proper numerical parameter"

* use regex for update ip
master
dimti 2 months ago
parent
commit
6429e6adbc
  1. 2
      .tmux/plugins/tmux-ip-address/scripts/ip_address.sh
  2. 3
      .tmux/plugins/tmux-ip-address/scripts/update_ip_address.sh

2
.tmux/plugins/tmux-ip-address/scripts/ip_address.sh

@ -5,7 +5,7 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/helpers.sh"
print_ip_address() {
local ip_address=$(curl --max-time 1.5 --silent http://ip.me)
local ip_address=$(curl --max-time 2 --silent http://ip.me)
echo ${ip_address}
}

3
.tmux/plugins/tmux-ip-address/scripts/update_ip_address.sh

@ -5,7 +5,6 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/helpers.sh"
ip_address="$($CURRENT_DIR/ip_address.sh)"
ip_address_interpolation_string="\#{ip_address}"
do_interpolation() {
local string="$1"
@ -15,7 +14,7 @@ do_interpolation() {
ip_addr="Offline"
fi
local interpolated="$(echo $1 | sed "s/$ip_address_interpolation_string/$ip_addr/g")"
local interpolated="$(echo $1 | sed "s/\(Offline\|[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\)/$ip_addr/g")"
echo "$interpolated"
}

Loading…
Cancel
Save