From 08c4c211ab226285217bb4bb85e823dad5f6f7c5 Mon Sep 17 00:00:00 2001 From: the_4n0nym0u53 Date: Mon, 7 Mar 2022 22:58:27 +0100 Subject: [PATCH] Zsh: Add IP option to get_ip() --- zsh/.config/zsh/functions.zsh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/zsh/.config/zsh/functions.zsh b/zsh/.config/zsh/functions.zsh index 786f421..4532226 100644 --- a/zsh/.config/zsh/functions.zsh +++ b/zsh/.config/zsh/functions.zsh @@ -1,5 +1,6 @@ doasedit() { (( ${+commands[doas]} )) || return 1 + doas -L doas $EDITOR /etc/doas.conf doas doas -C /etc/doas.conf && echo "ok" || echo "error" @@ -8,7 +9,16 @@ doasedit() { get_ip() { (( ${+commands[wget]} )) || return 1 - wget $@ -qO- "https://ifconfig.co/json" + + local IP="" + local ARGS="" + + while [[ $# -gt 0 ]]; do + [[ $1 == --ip ]] && IP="?ip=$2" && shift || ARGS="$ARGS $1" + shift + done + + eval "wget $ARGS -qO- 'https://ifconfig.co/json$IP'" } pz_upgrade() {