+ tmux-ip-address plugin with custom hand made fixes about remove beep x07 symbol (represented as \a from ip address values) from status-right bar
This commit is contained in:
18
.tmux/plugins/tmux-ip-address/scripts/helpers.sh
Executable file
18
.tmux/plugins/tmux-ip-address/scripts/helpers.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set_tmux_option() {
|
||||
local option="$1"
|
||||
local value="$2"
|
||||
tmux set-option -gq "$option" "$value"
|
||||
}
|
||||
|
||||
get_tmux_option() {
|
||||
local option="$1"
|
||||
local default_value="$2"
|
||||
local option_value="$(tmux show-option -gqv "$option")"
|
||||
if [ -z "$option_value" ]; then
|
||||
echo "$default_value"
|
||||
else
|
||||
echo "$option_value"
|
||||
fi
|
||||
}
|
16
.tmux/plugins/tmux-ip-address/scripts/ip_address.sh
Executable file
16
.tmux/plugins/tmux-ip-address/scripts/ip_address.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
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)
|
||||
echo ${ip_address}
|
||||
}
|
||||
|
||||
main() {
|
||||
print_ip_address
|
||||
}
|
||||
|
||||
main
|
33
.tmux/plugins/tmux-ip-address/scripts/update_ip_address.sh
Executable file
33
.tmux/plugins/tmux-ip-address/scripts/update_ip_address.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
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"
|
||||
local ip_addr=$ip_address
|
||||
if [ -z "$ip_address" ]
|
||||
then
|
||||
ip_addr="Offline"
|
||||
fi
|
||||
|
||||
local interpolated="$(echo $1 | sed "s/$ip_address_interpolation_string/$ip_addr/g")"
|
||||
|
||||
echo "$interpolated"
|
||||
}
|
||||
|
||||
update_tmux_option() {
|
||||
local option="$1"
|
||||
local option_value="$(get_tmux_option "$option")"
|
||||
local new_option_value="$(do_interpolation "$option_value")"
|
||||
set_tmux_option "$option" "$new_option_value"
|
||||
}
|
||||
|
||||
main() {
|
||||
update_tmux_option "status-right"
|
||||
}
|
||||
main
|
Reference in New Issue
Block a user