1
0
Fork 0
mirror of synced 2025-01-07 05:52:14 -05:00

added the #{github_stars} custom variable example

this shows how to make an api call with curl, and parse the json result with perl
This commit is contained in:
Gregory Pakosz 2025-01-05 17:38:54 +01:00
parent 34d654f917
commit 2222646188

View file

@ -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