mirror of
1
0
Fork 0

Compare commits

...

3 Commits

Author SHA1 Message Date
Gregory Pakosz b70400e1ee added the #{wan_ip_v4} and #{wan_ip_v6} custom variable examples, resolves #281 2024-01-21 21:31:47 +01:00
Gregory Pakosz eca5fb621b removed support for tmux < 2.6, resolves #698 2024-01-21 21:10:01 +01:00
Gregory Pakosz 7e00233465 fixed #{battery_bar} auto width, also resolves #447 2024-01-21 16:03:18 +01:00
3 changed files with 242 additions and 217 deletions

View File

@ -129,7 +129,6 @@ if -b '! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1'
if -b 'command -v wl-copy > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | wl-copy"'
# copy to macOS clipboard
if -b 'command -v pbcopy > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | pbcopy"'
if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | reattach-to-usernamespace pbcopy"'
# copy to Windows clipboard
if -b 'command -v clip.exe > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | clip.exe"'
if -b '[ -c /dev/clipboard ]' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - > /dev/clipboard"'
@ -258,6 +257,143 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# esac
# fi
#
# _bar() {
# bar_palette=$1
# bar_symbol_empty=$2
# bar_symbol_full=$3
# bar_length=$4
# bar_value=$5
#
# if [ "$bar_length" = "auto" ]; then
# columns=${6:-$(tmux -q display -p '#{client_width}' 2> /dev/null || echo 80)}
# if [ "$columns" -ge 160 ]; then
# bar_length=12
# elif [ "$columns" -ge 130 ]; then
# bar_length=10
# elif [ "$columns" -ge 120 ]; then
# bar_length=8
# elif [ "$columns" -ge 100 ]; then
# bar_length=6
# else
# bar_length=4
# fi
# fi
#
# if echo "$bar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $bar_palette; unset IFS; set +f; }
# palette_style=$1
# bg=${2:-none}
# [ "$palette_style" = "gradient" ] && \
# palette="196 202 208 214 220 226 190 154 118 82 46"
# [ "$palette_style" = "heat" ] && \
# palette="243 245 247 144 143 142 184 214 208 202 196"
#
# palette=$(echo "$palette" | awk -v n="$bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
# eval set -- "$palette"
#
# full=$(awk "BEGIN { printf \"%.0f\", ($bar_value) * $bar_length }")
# bar="#[bg=$bg]"
# # shellcheck disable=SC2046
# [ "$full" -gt 0 ] && \
# bar="$bar$(printf "#[fg=colour%s]$bar_symbol_full" $(echo "$palette" | cut -d' ' -f1-"$full"))"
# # shellcheck disable=SC2046
# empty=$((bar_length - full))
# # shellcheck disable=SC2046
# [ "$empty" -gt 0 ] && \
# bar="$bar$(printf "#[fg=colour%s]$bar_symbol_empty" $(echo "$palette" | cut -d' ' -f$((full + 1))-$((full + empty))))"
# eval bar="$bar#[fg=colour\${$((full == 0 ? 1 : full))}]"
# elif echo "$bar_palette" | grep -q -E '^(([#a-z0-9]{7,9}|none),?){3}$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $bar_palette; unset IFS; set +f; }
# full_fg=$1
# empty_fg=$2
# bg=$3
#
# full=$(awk "BEGIN { printf \"%.0f\", ($bar_value) * $bar_length }")
# [ "$bg" != "none" ] && \
# bar="#[bg=$bg]"
# #shellcheck disable=SC2046
# [ "$full" -gt 0 ] && \
# bar="$bar#[fg=$full_fg]$(printf "%0.s$bar_symbol_full" $(seq 1 "$full"))"
# empty=$((bar_length - full))
# #shellcheck disable=SC2046
# [ "$empty" -gt 0 ] && \
# bar="$bar#[fg=$empty_fg]$(printf "%0.s$bar_symbol_empty" $(seq 1 "$empty"))" && \
# bar="$bar#[fg=$empty_fg]"
# fi
#
# printf '%s' "$bar"
# }
#
# _hbar() {
# hbar_palette=$1
# hbar_value=$2
#
# if echo "$hbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $hbar_palette; unset IFS; set +f; }
# palette_style=$1
# [ "$palette_style" = "gradient" ] && \
# palette="196 202 208 214 220 226 190 154 118 82 46"
# [ "$palette_style" = "heat" ] && \
# palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
#
# palette=$(echo "$palette" | awk -v n=8 '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
# eval set -- "$palette"
#
# full=$(awk "BEGIN { printf \"%.0f\", ($hbar_value) * 8 }")
# eval hbar_fg="colour\${$((full == 0 ? 1 : full))}"
# elif echo "$hbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $hbar_palette; unset IFS; set +f; }
#
# # shellcheck disable=SC2046
# eval $(awk "BEGIN { printf \"hbar_fg=$%d\", (($hbar_value) - 0.001) * $# + 1 }")
# fi
#
# eval set -- "▏ ▎ ▍ ▌ ▋ ▊ ▉ █"
# # shellcheck disable=SC2046
# eval $(awk "BEGIN { printf \"hbar_symbol=$%d\", ($hbar_value) * ($# - 1) + 1 }")
# hbar="#[bg=none]#[fg=${hbar_fg?}]${hbar_symbol?}"
#
# printf '%s' "$hbar"
# }
#
# _vbar() {
# vbar_palette=$1
# vbar_value=$2
#
# if echo "$vbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $vbar_palette; unset IFS; set +f; }
# palette_style=$1
# [ "$palette_style" = "gradient" ] && \
# palette="196 202 208 214 220 226 190 154 118 82 46"
# [ "$palette_style" = "heat" ] && \
# palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
#
# palette=$(echo "$palette" | awk -v n=8 '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
# eval set -- "$palette"
#
# full=$(awk "BEGIN { printf \"%.0f\", ($vbar_value) * 8 }")
# eval vbar_fg="colour\${$((full == 0 ? 1 : full))}"
# elif echo "$vbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $vbar_palette; unset IFS; set +f; }
#
# # shellcheck disable=SC2046
# eval $(awk "BEGIN { printf \"vbar_fg=$%d\", (($vbar_value) - 0.001) * $# + 1 }")
# fi
#
# eval set -- "▁ ▂ ▃ ▄ ▅ ▆ ▇ █"
# # shellcheck disable=SC2046
# eval $(awk "BEGIN { printf \"vbar_symbol=$%d\", ($vbar_value) * ($# - 1) + 1 }")
# vbar="#[bg=none]#[fg=${vbar_fg?}]${vbar_symbol?}"
#
# printf '%s' "$vbar"
# }
#
# _maximize_pane() {
# current_session=${1:-$(tmux display -p '#{session_name}')}
# current_pane=${2:-$(tmux display -p '#{pane_id}')}
@ -301,16 +437,15 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# }
#
# _battery_info() {
# count=0
# charge=0
# battery_count=0
# battery_charge=0
# case "$_uname_s" in
# *Darwin*)
# while IFS= read -r line; do
# [ -z "$line" ] && continue
# discharging=$(printf '%s' "$line" | grep -qi "discharging" && echo "true" || echo "false")
# percentage=$(printf '%s' "$line" | grep -E -o '[0-9]+%' || echo "0%")
# charge=$(awk -v charge="$charge" -v percentage="${percentage%%%}" 'BEGIN { print charge + percentage / 100 }')
# count=$((count + 1))
# battery_charge=$(awk -v charge="$battery_charge" -v percentage="${percentage%%%}" 'BEGIN { print charge + percentage / 100 }')
# battery_count=$((battery_count + 1))
# done << EOF
# $(pmset -g batt | grep 'InternalBattery')
# EOF
@ -320,18 +455,17 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# [ -z "$batpath" ] && continue
# grep -i -q device "$batpath/scope" 2> /dev/null && continue
#
# discharging=$(grep -qi "discharging" "$batpath/status" && echo "true" || echo "false")
# bat_capacity="$batpath/capacity"
# if [ -r "$bat_capacity" ]; then
# charge=$(awk -v charge="$charge" -v capacity="$(cat "$bat_capacity")" 'BEGIN { print charge + (capacity > 100 ? 100 : capacity) / 100 }')
# battery_charge=$(awk -v charge="$battery_charge" -v capacity="$(cat "$bat_capacity")" 'BEGIN { print charge + (capacity > 100 ? 100 : capacity) / 100 }')
# else
# bat_energy_full="$batpath/energy_full"
# bat_energy_now="$batpath/energy_now"
# if [ -r "$bat_energy_full" ] && [ -r "$bat_energy_now" ]; then
# charge=$(awk -v charge="$charge" -v energy_now="$(cat "$bat_energy_now")" -v energy_full="$(cat "$bat_energy_full")" 'BEGIN { print charge + energy_now / energy_full }')
# battery_charge=$(awk -v charge="$battery_charge" -v energy_now="$(cat "$bat_energy_now")" -v energy_full="$(cat "$bat_energy_full")" 'BEGIN { print charge + energy_now / energy_full }')
# fi
# fi
# count=$((count + 1))
# battery_count=$((battery_count + 1))
# done << EOF
# $(find /sys/class/power_supply -maxdepth 1 -iname '*bat*')
# EOF
@ -339,9 +473,8 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# *CYGWIN*|*MSYS*|*MINGW*)
# while IFS= read -r line; do
# [ -z "$line" ] && continue
# discharging=$(printf '%s' "$line" | awk '{ s = ($1 == 1) ? "true" : "false"; print s }')
# charge=$(printf '%s' "$line" | awk -v charge="$charge" '{ print charge + $2 / 100 }')
# count=$((count + 1))
# battery_charge=$(printf '%s' "$line" | awk -v charge="$battery_charge" '{ print charge + $2 / 100 }')
# battery_count=$((battery_count + 1))
# done << EOF
# $(wmic path Win32_Battery get BatteryStatus, EstimatedChargeRemaining 2> /dev/null | tr -d '\r' | tail -n +2 || true)
# EOF
@ -349,36 +482,81 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# *OpenBSD*)
# for batid in 0 1 2; do
# sysctl -n "hw.sensors.acpibat$batid.raw0" 2>&1 | grep -q 'not found' && continue
# discharging=$(sysctl -n "hw.sensors.acpibat$batid.raw0" | grep -q 1 && echo "true" || echo "false")
# if sysctl -n "hw.sensors.acpibat$batid" | grep -q amphour; then
# charge=$(awk -v charge="$charge" -v remaining="$(sysctl -n hw.sensors.acpibat$batid.amphour3 | cut -d' ' -f1)" -v full="$(sysctl -n hw.sensors.acpibat$batid.amphour0 | cut -d' ' -f1)" 'BEGIN { print charge + remaining / full }')
# battery_charge=$(awk -v charge="$battery_charge" -v remaining="$(sysctl -n hw.sensors.acpibat$batid.amphour3 | cut -d' ' -f1)" -v full="$(sysctl -n hw.sensors.acpibat$batid.amphour0 | cut -d' ' -f1)" 'BEGIN { print charge + remaining / full }')
# else
# charge=$(awk -v charge="$charge" -v remaining="$(sysctl -n hw.sensors.acpibat$batid.watthour3 | cut -d' ' -f1)" -v full="$(sysctl -n hw.sensors.acpibat$batid.watthour0 | cut -d' ' -f1)" 'BEGIN { print charge + remaining / full }')
# battery_charge=$(awk -v charge="$battery_charge" -v remaining="$(sysctl -n hw.sensors.acpibat$batid.watthour3 | cut -d' ' -f1)" -v full="$(sysctl -n hw.sensors.acpibat$batid.watthour0 | cut -d' ' -f1)" 'BEGIN { print charge + remaining / full }')
# fi
# count=$((count + 1))
# battery_count=$((battery_count + 1))
# done
# ;;
# *FreeBSD*)
# discharging=$(sysctl -n 'hw.acpi.battery.state' | grep -q 1 && echo "true" || echo "false")
# charge=$(awk -v charge="$(sysctl -n 'hw.acpi.battery.life')" 'BEGIN { print charge / 100 }')
# count=1
# battery_charge=$(awk -v charge="$(sysctl -n 'hw.acpi.battery.life')" 'BEGIN { print charge / 100 }')
# battery_count=1
# ;;
# esac
# if [ "$count" -ne 0 ]; then
# charge=$(awk -v charge="$charge" -v count="$count" 'BEGIN { print charge / count }')
# if [ "$battery_count" -ne 0 ]; then
# battery_charge=$(awk -v charge="$battery_charge" -v count="$battery_count" 'BEGIN { print charge / count }')
# fi
#
# if [ "$battery_charge" = 0 ]; then
# tmux set -ug '@battery_percentage' \;\
# set -ug '@battery_charge'
# else
# battery_percentage="$(awk "BEGIN { printf \"%.0f%%\", ($battery_charge) * 100 }")"
#
# tmux set -g '@battery_percentage' "$battery_percentage" \;\
# set -g '@battery_charge' "$battery_charge"
# fi
# }
#
# _battery_status() {
# _battery_info
# if [ "$charge" = 0 ]; then
# battery_status_charging=$1
# battery_status_discharging=$2
#
# case "$_uname_s" in
# *Darwin*)
# while IFS= read -r line; do
# [ -z "$line" ] && continue
# battery_discharging=$(printf '%s' "$line" | grep -qi "discharging" && echo "true" || echo "false")
# done << EOF
# $(pmset -g batt | grep 'InternalBattery')
# EOF
# ;;
# *Linux*)
# while IFS= read -r batpath; do
# [ -z "$batpath" ] && continue
# grep -i -q device "$batpath/scope" 2> /dev/null && continue
#
# battery_discharging=$(grep -qi "discharging" "$batpath/status" && echo "true" || echo "false")
# done << EOF
# $(find /sys/class/power_supply -maxdepth 1 -iname '*bat*')
# EOF
# ;;
# *CYGWIN*|*MSYS*|*MINGW*)
# while IFS= read -r line; do
# [ -z "$line" ] && continue
# battery_discharging=$(printf '%s' "$line" | awk '{ s = ($1 == 1) ? "true" : "false"; print s }')
# done << EOF
# $(wmic path Win32_Battery get BatteryStatus, EstimatedChargeRemaining 2> /dev/null | tr -d '\r' | tail -n +2 || true)
# EOF
# ;;
# *OpenBSD*)
# for batid in 0 1 2; do
# battery_discharging=$(sysctl -n "hw.sensors.acpibat$batid.raw0" | grep -q 1 && echo "true" || echo "false")
# done
# ;;
# *FreeBSD*)
# battery_discharging=$(sysctl -n 'hw.acpi.battery.state' | grep -q 1 && echo "true" || echo "false")
# ;;
# esac
#
# if [ -z "$battery_discharging" ]; then
# tmux set -ug '@battery_status'
# return
# fi
#
# battery_status_charging=$1
# battery_status_discharging=$2
# if [ "$discharging" = "true" ]; then
# if [ "$battery_discharging" = "true" ]; then
# battery_status="$battery_status_discharging"
# else
# battery_status="$battery_status_charging"
@ -387,138 +565,6 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# tmux set -g '@battery_status' "$battery_status"
# }
#
# _battery_bar() {
# _battery_info
# if [ "$charge" = 0 ]; then
# tmux set -ug '@battery_bar' \;\
# set -ug '@battery_hbar' \;\
# set -ug '@battery_vbar' \;\
# set -ug '@battery_percentage'
# return
# fi
#
# battery_bar_symbol_full=$1
# battery_bar_symbol_empty=$2
# battery_bar_length=$3
# battery_bar_palette=$4
# battery_hbar_palette=$5
# battery_vbar_palette=$6
#
# if [ "$battery_bar_length" = "auto" ]; then
# columns=$(tmux -q display -p '#{client_width}' 2> /dev/null || echo 80)
# if [ "$columns" -ge 80 ]; then
# battery_bar_length=10
# else
# battery_bar_length=5
# fi
# fi
#
# if echo "$battery_bar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $battery_bar_palette; unset IFS; set +f; }
# palette_style=$1
# battery_bg=${2:-none}
# [ "$palette_style" = "gradient" ] && \
# palette="196 202 208 214 220 226 190 154 118 82 46"
# [ "$palette_style" = "heat" ] && \
# palette="243 245 247 144 143 142 184 214 208 202 196"
#
# palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
# eval set -- "$palette"
#
# full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
# battery_bar="#[bg=$battery_bg]"
# # shellcheck disable=SC2046
# [ "$full" -gt 0 ] && \
# battery_bar="$battery_bar$(printf "#[fg=colour%s]$battery_bar_symbol_full" $(echo "$palette" | cut -d' ' -f1-"$full"))"
# # shellcheck disable=SC2046
# empty=$((battery_bar_length - full))
# # shellcheck disable=SC2046
# [ "$empty" -gt 0 ] && \
# battery_bar="$battery_bar$(printf "#[fg=colour%s]$battery_bar_symbol_empty" $(echo "$palette" | cut -d' ' -f$((full + 1))-$((full + empty))))"
# eval battery_bar="$battery_bar#[fg=colour\${$((full == 0 ? 1 : full))}]"
# elif echo "$battery_bar_palette" | grep -q -E '^(([#a-z0-9]{7,9}|none),?){3}$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $battery_bar_palette; unset IFS; set +f; }
# battery_full_fg=$1
# battery_empty_fg=$2
# battery_bg=$3
#
# full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
# [ "$battery_bg" != "none" ] && \
# battery_bar="#[bg=$battery_bg]"
# #shellcheck disable=SC2046
# [ "$full" -gt 0 ] && \
# battery_bar="$battery_bar#[fg=$battery_full_fg]$(printf "%0.s$battery_bar_symbol_full" $(seq 1 "$full"))"
# empty=$((battery_bar_length - full))
# #shellcheck disable=SC2046
# [ "$empty" -gt 0 ] && \
# battery_bar="$battery_bar#[fg=$battery_empty_fg]$(printf "%0.s$battery_bar_symbol_empty" $(seq 1 "$empty"))" && \
# battery_bar="$battery_bar#[fg=$battery_empty_fg]"
# fi
#
# if echo "$battery_hbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $battery_hbar_palette; unset IFS; set +f; }
# palette_style=$1
# [ "$palette_style" = "gradient" ] && \
# palette="196 202 208 214 220 226 190 154 118 82 46"
# [ "$palette_style" = "heat" ] && \
# palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
#
# palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
# eval set -- "$palette"
#
# full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
# eval battery_hbar_fg="colour\${$((full == 0 ? 1 : full))}"
# elif echo "$battery_hbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $battery_hbar_palette; unset IFS; set +f; }
#
# # shellcheck disable=SC2046
# eval $(awk "BEGIN { printf \"battery_hbar_fg=$%d\", (($charge) - 0.001) * $# + 1 }")
# fi
#
# eval set -- "▏ ▎ ▍ ▌ ▋ ▊ ▉ █"
# # shellcheck disable=SC2046
# eval $(awk "BEGIN { printf \"battery_hbar_symbol=$%d\", ($charge) * ($# - 1) + 1 }")
# battery_hbar="#[fg=${battery_hbar_fg?}]${battery_hbar_symbol?}"
#
# if echo "$battery_vbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $battery_vbar_palette; unset IFS; set +f; }
# palette_style=$1
# [ "$palette_style" = "gradient" ] && \
# palette="196 202 208 214 220 226 190 154 118 82 46"
# [ "$palette_style" = "heat" ] && \
# palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
#
# palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
# eval set -- "$palette"
#
# full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
# eval battery_vbar_fg="colour\${$((full == 0 ? 1 : full))}"
# elif echo "$battery_vbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $battery_vbar_palette; unset IFS; set +f; }
#
# # shellcheck disable=SC2046
# eval $(awk "BEGIN { printf \"battery_vbar_fg=$%d\", (($charge) - 0.001) * $# + 1 }")
# fi
#
# eval set -- "▁ ▂ ▃ ▄ ▅ ▆ ▇ █"
# # shellcheck disable=SC2046
# eval $(awk "BEGIN { printf \"battery_vbar_symbol=$%d\", ($charge) * ($# - 1) + 1 }")
# battery_vbar="#[fg=${battery_vbar_fg?}]${battery_vbar_symbol?}"
#
# battery_percentage="$(awk "BEGIN { printf \"%.0f%%\", ($charge) * 100 }")"
#
# tmux set -g '@battery_bar' "$battery_bar" \;\
# set -g '@battery_hbar' "$battery_hbar" \;\
# set -g '@battery_vbar' "$battery_vbar" \;\
# set -g '@battery_percentage' "$battery_percentage"
# }
#
# _pane_info() {
# pane_pid="$1"
# pane_tty="${2##/dev/}"
@ -899,7 +945,6 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# ! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1 && command='xclip -i -selection clipboard > \/dev\/null 2>\&1'
# command -v wl-copy > /dev/null 2>&1 && command='wl-copy'
# command -v pbcopy > /dev/null 2>&1 && command='pbcopy'
# command -v reattach-to-user-namespace > /dev/null 2>&1 && command='reattach-to-user-namespace pbcopy'
# command -v clip.exe > /dev/null 2>&1 && command='clip\.exe'
# [ -c /dev/clipboard ] && command='cat > \/dev\/clipboard'
#
@ -1345,33 +1390,39 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# tmux_conf_battery_status_charging=$(_decode_unicode_escapes "${tmux_conf_battery_status_charging:-↑}") # U+2191
# tmux_conf_battery_status_discharging=$(_decode_unicode_escapes "${tmux_conf_battery_status_discharging:-↓}") # U+2193
#
# _pkillf "cut -c3- '$TMUX_CONF' \| sh -s _battery_bar"
# _pkillf "cut -c3- '$TMUX_CONF' \| sh -s _battery"
# _battery_info
# if [ "$charge" != 0 ]; then
# if [ "$battery_charge" != 0 ]; then
# case "$status_left $status_right" in
# *'#{battery_'*|*'#{?battery_'*)
# status_left=$(echo "$status_left" | sed -E \
# -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \
# -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \
# -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \
# -e 's%#\{\?battery_bar%#\{?@battery_percentage%g' \
# -e 's%#\{\?battery_hbar%#\{?@battery_percentage%g' \
# -e 's%#\{\?battery_vbar%#\{?@battery_percentage%g' \
# -e "s%#{battery_bar}%#(nice cut -c3- '$TMUX_CONF' | sh -s _bar '$tmux_conf_battery_bar_palette' '$tmux_conf_battery_bar_symbol_empty' '$tmux_conf_battery_bar_symbol_full' '$tmux_conf_battery_bar_length' '#{@battery_charge}' '#{client_width}')%g" \
# -e "s%#{battery_hbar}%#(nice cut -c3- '$TMUX_CONF' | sh -s _hbar '$tmux_conf_battery_hbar_palette' '#{@battery_charge}'')%g" \
# -e "s%#{battery_vbar}%#(nice cut -c3- '$TMUX_CONF' | sh -s _vbar '$tmux_conf_battery_hbar_palette' '#{@battery_charge}'')%g" \
# -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \
# -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g')
# status_right=$(echo "$status_right" | sed -E \
# -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \
# -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \
# -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \
# -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \
# -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g')
# -e 's%#\{\?battery_bar%#\{?@battery_percentage%g' \
# -e 's%#\{\?battery_hbar%#\{?@battery_percentage%g' \
# -e 's%#\{\?battery_vbar%#\{?@battery_percentage%g' \
# -e "s%#{battery_bar}%#(nice cut -c3- '$TMUX_CONF' | sh -s _bar '$tmux_conf_battery_bar_palette' '$tmux_conf_battery_bar_symbol_empty' '$tmux_conf_battery_bar_symbol_full' '$tmux_conf_battery_bar_length' '#{@battery_charge}' '#{client_width}')%g" \
# -e "s%#{battery_hbar}%#(nice cut -c3- '$TMUX_CONF' | sh -s _hbar '$tmux_conf_battery_hbar_palette' '#{@battery_charge}'')%g" \
# -e "s%#{battery_vbar}%#(nice cut -c3- '$TMUX_CONF' | sh -s _vbar '$tmux_conf_battery_hbar_palette' '#{@battery_charge}'')%g" \
# -e 's%#\{(\?)?battery_status%#\{\1@battery_status%g' \
# -e 's%#\{(\?)?battery_percentage%#\{\1@battery_percentage%g')
# status_right="#(echo; nice cut -c3- '$TMUX_CONF' | sh -s _battery_status '$tmux_conf_battery_status_charging' '$tmux_conf_battery_status_discharging')$status_right"
# interval=60
# if [ "$_tmux_version" -ge 320 ]; then
# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \"\$sleep_pid\"; exit 0' TERM; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_bar '$tmux_conf_battery_bar_symbol_full' '$tmux_conf_battery_bar_symbol_empty' '$tmux_conf_battery_bar_length' '$tmux_conf_battery_bar_palette' '$tmux_conf_battery_hbar_palette' '$tmux_conf_battery_vbar_palette'; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done"
# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \"\$sleep_pid\"; exit 0' TERM; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_info; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done"
# elif [ "$_tmux_version" -ge 280 ]; then
# status_right="#(echo; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_bar '$tmux_conf_battery_bar_symbol_full' '$tmux_conf_battery_bar_symbol_empty' '$tmux_conf_battery_bar_length' '$tmux_conf_battery_bar_palette' '$tmux_conf_battery_hbar_palette' '$tmux_conf_battery_vbar_palette'; sleep $interval; done)$status_right"
# status_right="#(echo; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_info; sleep $interval; done)$status_right"
# elif [ "$_tmux_version" -gt 240 ]; then
# status_right="#(echo; while :; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_bar '$tmux_conf_battery_bar_symbol_full' '$tmux_conf_battery_bar_symbol_empty' '$tmux_conf_battery_bar_length' '$tmux_conf_battery_bar_palette' '$tmux_conf_battery_hbar_palette' '$tmux_conf_battery_vbar_palette'; sleep $interval; done)$status_right"
# status_right="#(echo; while :; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_info; sleep $interval; done)$status_right"
# else
# status_right="#(nice cut -c3- '$TMUX_CONF' | sh -s _battery_bar '$tmux_conf_battery_bar_symbol_full' '$tmux_conf_battery_bar_symbol_empty' '$tmux_conf_battery_bar_length' '$tmux_conf_battery_bar_palette' '$tmux_conf_battery_hbar_palette' '$tmux_conf_battery_vbar_palette')$status_right"
# status_right="#(nice cut -c3- '$TMUX_CONF' | sh -s _battery_info)$status_right"
# fi
# ;;
# esac
@ -1596,25 +1647,12 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires awk" \; set -u display-time \; run "sleep 3" \; kill-server'
# return
# fi
# if [ "$_tmux_version" -lt 240 ]; then
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires tmux 2.4+" \; set -u display-time \; run "sleep 3" \; kill-server'
# if [ "$_tmux_version" -lt 260 ]; then
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires tmux 2.6+" \; set -u display-time \; run "sleep 3" \; kill-server'
# return
# fi
# fi
#
# # see https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
# if command -v reattach-to-user-namespace > /dev/null 2>&1; then
# default_shell="$(tmux show -gv default-shell)"
# case "$default_shell" in
# *fish)
# tmux set -g default-command "reattach-to-user-namespace -l $default_shell"
# ;;
# *sh)
# tmux set -g default-command "exec $default_shell... 2> /dev/null & reattach-to-user-namespace -l $default_shell"
# ;;
# esac
# fi
#
# case "$_uname_s" in
# *CYGWIN*|*MSYS*)
# # prevent Cygwin and MSYS2 from cd-ing into home directory when evaluating /etc/profile

View File

@ -344,12 +344,12 @@ tmux_conf_theme_clock_style="24"
# - true
# - false (default)
# - disabled
# on macOS, this requires installing reattach-to-user-namespace, see README.md
# on Linux, this requires xsel, xclip or wl-copy
tmux_conf_copy_to_os_clipboard=false
# -- user customizations -------------------------------------------------------
# this is the place to override or undo settings
# increase history size
@ -445,6 +445,16 @@ tmux_conf_uninstall_plugins_on_reload=true
# ping -c 1 1.1.1.1 >/dev/null 2>&1 && printf '✔' || printf '✘'
# }
#
# wan_ip_v4() {
# curl -f -s -m 2 -4 ifconfig.me
# sleep 300 # sleep for 5 minutes, throttle network requests whatever the value of status-interval
# }
#
# wan_ip_v6() {
# curl -f -s -m 2 -6 ifconfig.me
# sleep 300 # sleep for 5 minutes, throttle network requests whatever the value of status-interval
# }
#
# "$@"
# # /!\ do not remove the previous line
# # do not write below this line

View File

@ -10,7 +10,7 @@ Installation
Requirements:
- tmux **`>= 2.4`** running inside Linux, Mac, OpenBSD, Cygwin or WSL
- tmux **`>= 2.6`** running inside Linux, Mac, OpenBSD, Cygwin or WSL
- awk, perl and sed
- outside of tmux, `$TERM` must be set to `xterm-256color`
@ -120,22 +120,18 @@ Features
- [maximize any pane to a new window with `<prefix> +`][maximize-pane]
- SSH/Mosh aware username and hostname status line information
- mouse mode toggle with `<prefix> m`
- automatic usage of [`reattach-to-user-namespace`][reattach-to-user-namespace]
if available
- laptop battery status line information
- uptime status line information
- optional highlight of focused pane
- configurable new windows and panes behavior (optionally retain current path)
- SSH/Mosh aware split pane (reconnects to remote server)
- copy to OS clipboard (needs [`reattach-to-user-namespace`][reattach-to-user-namespace]
on macOS, `xsel`, `xclip`, or `wl-copy` on Linux)
- copy to OS clipboard (needs `xsel`, `xclip`, or `wl-copy` on Linux)
- support for 4-digit hexadecimal Unicode characters
- [Facebook PathPicker][] integration if available
- [Urlscan][] (preferred) or [Urlview][] integration if available
[Powerline]: https://github.com/Lokaltog/powerline
[maximize-pane]: http://pempek.net/articles/2013/04/14/maximizing-tmux-pane-new-window/
[reattach-to-user-namespace]: https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
[Facebook PathPicker]: https://facebook.github.io/PathPicker/
[Urlview]: https://packages.debian.org/stable/misc/urlview
[Urlscan]: https://github.com/firecat53/urlscan
@ -271,9 +267,10 @@ your own preferences.
This configuration supports the following builtin variables:
- `#{battery_bar}`: horizontal battery charge bar
- `#{battery_hbar}`: 1 character wide, horizontal battery charge bar
- `#{battery_vbar}`: 1 character wide, vertical battery charge bar
- `#{battery_percentage}`: battery percentage
- `#{battery_status}`: is battery charging or discharging?
- `#{battery_vbar}`: vertical battery charge bar
- `#{circled_session_name}`: circled session number, up to 20
- `#{hostname}`: SSH/Mosh aware hostname information
- `#{hostname_ssh}`: SSH/Mosh aware hostname information, blank when not
@ -337,26 +334,6 @@ See the sample `.local` customization file for instructions.
[TPM]: https://github.com/tmux-plugins/tpm
### Accessing the macOS clipboard from within tmux sessions (tmux `< 2.6`)
[Chris Johnsen created the `reattach-to-user-namespace`
utility][reattach-to-user-namespace] that makes `pbcopy` and `pbpaste` work
again within tmux.
To install `reattach-to-user-namespace`, use either [MacPorts][] or
[Homebrew][]:
$ port install tmux-pasteboard
or
$ brew install reattach-to-user-namespace
Once installed, `reattach-to-usernamespace` will be automatically detected.
[MacPorts]: http://www.macports.org/
[Homebrew]: http://brew.sh/
### Using the configuration under Cygwin within Mintty
**I don't recommend running this configuration with Cygwin anymore. Forking