~tardypad/dotfiles

ref: 8a1a01060b09bdf89a8188f0cd84af082ef52dbb dotfiles/files/configs/zsh/completions/_bluetooth -rw-r--r-- 505 bytes
8a1a0106 — Damien Tardy-Panis Add bluetooth script 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#compdef bluetooth

_actions() {
  local actions=(
    connect
    disconnect
    receive
    send
  )

  compadd "$@" $actions
}

_device_aliases() {
  if [ $words[CURRENT-1] != 'receive' ]; then
    local device_aliases=( "${(@f)$( bluetoothctl paired-devices | cut -d' ' -f3 )}" )
    compadd "$@" $device_aliases
  fi
}

_send_files() {
  if [ $words[CURRENT-2] = 'send' ]; then
    _path_files
  fi
}


_arguments \
  '1:action:_actions' \
  '2:device_alias:_device_aliases' \
  '3:file:_send_files'