You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
635 B
35 lines
635 B
#!/usr/bin/env bash |
|
|
|
has() { |
|
local verbose=false |
|
if [[ $1 == '-v' ]]; then |
|
verbose=true |
|
shift |
|
fi |
|
for c in "$@"; do c="${c%% *}" |
|
if ! command -v "$c" &> /dev/null; then |
|
[[ "$verbose" == true ]] && err "$c not found" |
|
return 1 |
|
fi |
|
done |
|
} |
|
|
|
err() { |
|
printf '\e[31m%s\e[0m\n' "$*" >&2 |
|
} |
|
|
|
die() { |
|
(( $# > 0 )) && err "$*" |
|
exit 1 |
|
} |
|
|
|
fzf() { |
|
command fzf --ansi --inline-info "$@" |
|
} |
|
|
|
has -v nmcli fzf || die |
|
|
|
network=$(nmcli --color yes device wifi | fzf --nth=2 --header-lines=1 | sed -r 's/^\s*\*?\s*//; s/\s*(Ad-Hoc|Infra).*//') |
|
[[ -z "$network" ]] && exit |
|
|
|
nmcli -a device wifi connect "$network"
|
|
|