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.

12345678910111213141516171819202122232425262728293031323334353637
  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. has -v nmcli fzf || die
  23. nmcli -f 'bssid,signal,bars,freq,ssid' --color yes device wifi |
  24. fzf \
  25. --with-nth=2.. \
  26. --ansi \
  27. --height=40% \
  28. --reverse \
  29. --cycle \
  30. --inline-info \
  31. --header-lines=1 \
  32. --bind="enter:execute:nmcli -a device wifi connect {1}"