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.

wifi 635B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env bash
  2. has() {
  3. local verbose=false
  4. if [[ $1 == '-v' ]]; then
  5. verbose=true
  6. shift
  7. fi
  8. for c in "$@"; do c="${c%% *}"
  9. if ! command -v "$c" &> /dev/null; then
  10. [[ "$verbose" == true ]] && err "$c not found"
  11. return 1
  12. fi
  13. done
  14. }
  15. err() {
  16. printf '\e[31m%s\e[0m\n' "$*" >&2
  17. }
  18. die() {
  19. (( $# > 0 )) && err "$*"
  20. exit 1
  21. }
  22. fzf() {
  23. command fzf --ansi --inline-info "$@"
  24. }
  25. has -v nmcli fzf || die
  26. network=$(nmcli --color yes device wifi | fzf --nth=2 --header-lines=1 | sed -r 's/^\s*\*?\s*//; s/\s*(Ad-Hoc|Infra).*//')
  27. [[ -z "$network" ]] && exit
  28. nmcli -a device wifi connect "$network"