Refactor stuff

This commit is contained in:
Sam A. 2022-07-05 12:14:18 +02:00
parent 926f6c07cd
commit b423a60d33
Signed by: samsapti
GPG Key ID: CBBBE7371E81C4EA
1 changed files with 8 additions and 8 deletions

View File

@ -1,5 +1,5 @@
bt() {
(( ${+commands[bluetoothctl]} )) || return 1
(( ${+commands[bluetoothctl]} )) || return 2
if [[ $1 == on ]]; then
(( ${+commands[connmanctl]} )) \
@ -15,7 +15,7 @@ bt() {
}
doasedit() {
(( ${+commands[doas]} )) || return 1
(( ${+commands[doas]} )) || return 2
doas -L
doas -u root sh -c \
@ -31,8 +31,7 @@ doasedit() {
return $STATUS
}
get_ip() {
(( ${+commands[jq]} )) && local JQ="| jq"
get_ip() {
local IP=""
local ARGS=()
@ -41,12 +40,13 @@ get_ip() {
shift
done
eval "curl ${ARGS[*]} -fsSL 'https://ifconfig.co/json$IP' $JQ"
eval "curl ${ARGS[*]} -fsSL 'https://ifconfig.co/json$IP' \
$( (( ${+commands[jq]} )) && echo "| jq" )"
}
http() {
(( ${+commands[python]} )) || return 1
(( ${+commands[python]} )) || return 2
[[ $# -gt 0 ]] && local DIR="--directory $1"
eval "python -m http.server 8080 --bind 127.0.0.1 $DIR"
eval "python -m http.server 8080 --bind 127.0.0.1 \
$( [[ $# -gt 0 ]] && echo "--directory $1" )"
}