diff options
Diffstat (limited to 'modules/communication/neomutt')
| -rw-r--r-- | modules/communication/neomutt/default.nix | 21 | ||||
| -rw-r--r-- | modules/communication/neomutt/neomutt-sync.zsh | 21 |
2 files changed, 41 insertions, 1 deletions
diff --git a/modules/communication/neomutt/default.nix b/modules/communication/neomutt/default.nix index 67728d8..84e6c61 100644 --- a/modules/communication/neomutt/default.nix +++ b/modules/communication/neomutt/default.nix @@ -20,6 +20,25 @@ let ]; text = builtins.readFile ./neomutt-sync.sh; }; + + neomuttSyncCompletion = + pkgs.runCommand "neomutt-sync-completion" + { + nativeBuildInputs = [ pkgs.installShellFiles ]; + } + '' + mkdir -p $out/share/zsh/site-functions + installShellCompletion --zsh --name _neomutt-sync ${pkgs.writeText "neomutt-sync.zsh" (builtins.readFile ./neomutt-sync.zsh)} + ''; + + neomuttSync = pkgs.symlinkJoin { + name = "nix-update"; + paths = [ + neomuttSyncScript + neomuttSyncCompletion + ]; + meta = neomuttSyncScript.meta or { }; + }; in { imports = [ @@ -74,7 +93,7 @@ in name = "neomutt-wrapped"; paths = [ pkgs.neomutt - neomuttSyncScript + neomuttSync ]; nativeBuildInputs = [ pkgs.makeWrapper ]; postBuild = '' diff --git a/modules/communication/neomutt/neomutt-sync.zsh b/modules/communication/neomutt/neomutt-sync.zsh new file mode 100644 index 0000000..03c092a --- /dev/null +++ b/modules/communication/neomutt/neomutt-sync.zsh @@ -0,0 +1,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 |
