From 2222646188be377c7a3232548934906ea6170331 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 5 Jan 2025 17:38:54 +0100 Subject: [PATCH] added the #{github_stars} custom variable example this shows how to make an api call with curl, and parse the json result with perl --- .tmux.conf.local | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.tmux.conf.local b/.tmux.conf.local index c3eeb4f..e17b324 100644 --- a/.tmux.conf.local +++ b/.tmux.conf.local @@ -467,25 +467,39 @@ tmux_conf_uninstall_plugins_on_reload=true # # # /!\ do not "uncomment" the functions: the leading "# " characters are needed # +# # usage: #{weather} # weather() { # see https://github.com/chubin/wttr.in#one-line-output # curl -f -s -m 2 'wttr.in?format=3' || printf '\n' # /!\ make sure curl is installed # sleep 900 # sleep for 15 minutes, throttle network requests whatever the value of status-interval # } # +# # usage: #{online} # online() { # ping -c 1 1.1.1.1 >/dev/null 2>&1 && printf '✔' || printf '✘' # } # +# # usage: #{wan_ip_v4} # 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 # } # +# # usage: #{wan_ip_v6} # 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 # } # +# # usage: #{github_stars}, #{github_stars tmux/tmux}, ... +# github_stars() { +# repository=${1##*https://github.com/} +# repository=${repository%% *} +# repository=${repository%%.git} +# url="https://api.github.com/repos/${repository:-gpakosz/.tmux}" +# curl -s "$url" | perl -MJSON::PP=decode_json -CO -0777 -E '$response = decode_json(readline *STDIN); say ($response->{stargazers_count})' +# 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