generated from 2KAbhishek/bare-minimum
-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
ping.sh
27 lines (20 loc) · 607 Bytes
/
ping.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
export LC_ALL=en_US.UTF-8
current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$current_dir"/utils.sh
ping_function() {
case $(uname -s) in
Linux | Darwin)
pingserver=$(get_tmux_option "@tmux2k-ping-server" "google.com")
pingtime=$(ping -c 1 "$pingserver" | tail -1 | awk '{print $4}' | cut -d '/' -f 2)
echo "$pingtime ms"
;;
CYGWIN* | MINGW32* | MSYS* | MINGW*) ;; # TODO - windows compatability
esac
}
main() {
echo "$(ping_function)"
RATE=$(get_tmux_option "@tmux2k-ping-rate" 5)
sleep "$RATE"
}
main