summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorLucas Hoffmann <lucc@posteo.de>2018-10-01 10:39:21 +0200
committerPatrick Totzke <patricktotzke@gmail.com>2018-10-01 10:13:12 +0100
commit41197b766f5223c1d3f02594c9324b67c14c56ae (patch)
treec88131a0c26738a65168670cf1dedc25ebf6ced2 /extra
parentcd0c6b44f9c641941bd7077ad31607e1b0237267 (diff)
Enable zsh completion of sender addresses
This parses the config file to find the email addresses. Because the string interpolation happens at run time and not at load time of the completion script the python snippet is run on each completion attempt. This has the advantage that changes to the config file are picked up without restarting the shell and the snippet is simple enough to not impose a real delay in completion.
Diffstat (limited to 'extra')
-rw-r--r--extra/completion/alot-completion.zsh14
1 files changed, 13 insertions, 1 deletions
diff --git a/extra/completion/alot-completion.zsh b/extra/completion/alot-completion.zsh
index bbd3c54d..34d48a61 100644
--- a/extra/completion/alot-completion.zsh
+++ b/extra/completion/alot-completion.zsh
@@ -24,6 +24,18 @@ _alot_search()
'--sort=[sort results]:sorting:((newest_first\:"reverse chronological order" oldest_first\:"chronological order" message_id\:"lexicographically by Message Id"))'
}
+_alot_account_emails()
+{
+ python3 - ${XDG_CONFIG_HOME:-~/.config}/alot/config <<-'EOF'
+ import configobj, sys
+ config = configobj.ConfigObj(infile=sys.argv[1], encoding="UTF8")
+ accounts = config.get("accounts", {})
+ addresses = [accounts[k].get('address') for k in accounts
+ if type(accounts[k]) is configobj.Section]
+ print(" ".join(addresses), end="")
+ EOF
+}
+
_alot_compose()
{
_arguments -s : \
@@ -31,7 +43,7 @@ _alot_compose()
'--bcc=[Blind Carbon Copy header]:Recipient (Bcc header):_email_addresses' \
'--cc=[Carbon Copy header]:Recipient (Cc header):_email_addresses' \
'--omit_signature[do not add signature]' \
- '--sender=[From header]' \
+ "--sender=[From header]:Sender account:($(_alot_account_emails))" \
'--subject=[Subject header]' \
'--template=[template file to use]' \
'--to=[To header]:Recipient (To header):_email_addresses' \