diff --git a/zsh/.config/zsh/functions.zsh b/zsh/.config/zsh/functions.zsh index c5f7166..f2b190d 100644 --- a/zsh/.config/zsh/functions.zsh +++ b/zsh/.config/zsh/functions.zsh @@ -2,9 +2,13 @@ bt() { (( ${+commands[bluetoothctl]} )) || return 1 if [[ $1 == on ]]; then - connmanctl enable bluetooth + (( ${+commands[connmanctl]} )) \ + && connmanctl enable bluetooth \ + || bluetoothctl power on elif [[ $1 == off ]]; then - connmanctl disable bluetooth + (( ${+commands[connmanctl]} )) \ + && connmanctl disable bluetooth \ + || bluetoothctl power off else bluetoothctl "$@" fi @@ -30,14 +34,14 @@ doasedit() { get_ip() { (( ${+commands[jq]} )) && local JQ="| jq" local IP="" - local ARGS="" + local ARGS=() while [[ $# -gt 0 ]]; do - [[ $1 == --ip ]] && IP="?ip=$2" && shift || ARGS="$ARGS $1" + [[ $1 == --ip ]] && IP="?ip=$2" && shift || ARGS+=("$1") shift done - eval "curl $ARGS -fsSL 'https://ifconfig.co/json$IP' $JQ" + eval "curl ${ARGS[*]} -fsSL 'https://ifconfig.co/json$IP' $JQ" } http() {