aboutsummaryrefslogtreecommitdiffstats
path: root/modules/communication/neomutt/neomutt-sync.zsh
blob: 03c092aaedbbd2a646eb8afd8f5809fece6e0c42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#compdef neomutt-sync
# Zsh completion for the neomutt-sync command.
# Completes mbsync channel names parsed from the mbsyncrc
# (defaults to ~/.config/mbsync/.mbsyncrc, overridable via MBSYNCRC).

_arguments '1: :->channel'

case $state in
  channel)
    local mbsyncrc="${MBSYNCRC:-$HOME/.config/mbsync/.mbsyncrc}"
    local -a channels
    while IFS= read -r channel; do
      case $channel in
        *-quick) channels+=("$channel:Quick sync of INBOX only (new mail); run from the neomutt gs macro") ;;
        *-full)  channels+=("$channel:Full two-way sync of all folders (slow); for scheduled runs") ;;
        *)       channels+=("$channel") ;;
      esac
    done < <(grep -oP '^Channel\s+\K\S+' "$mbsyncrc" 2>/dev/null | sort -u)
    _describe 'channel' channels
    ;;
esac