#联系 #地址簿 #vcard #vdir

bin+lib mates-rs

一个非常简单的命令行地址簿

2 个稳定版本

1.0.1 2022 年 4 月 27 日
1.0.0 2022 年 4 月 24 日

158电子邮件

MIT 许可证

32KB
729

Mates

Build status Crates.io Crates.io

一个命令行地址簿。主要目标是

  • 高度可扩展性

    • Mates 在一个 vCard 文件目录上操作,vCard 是一个标准的联系人文件格式。因此,可以与其他程序一起使用以同步 CardDAV 服务器(见下文)。
  • UI 响应性 在 mutt 中完成电子邮件地址时,mates 维护一个简单的文本文件,其中只包含 vCard 文件中的几个字段,它将在其上调用 grep。文本文件看起来像这样

    work@example.com\tExample Man\t/home/user/.contacts/exampleman.vcf
    home@example.com\tExample Man\t/home/user/.contacts/exampleman.vcf
    

安装

对于手动安装,您需要安装 RustCargo。1.0 和夜版本都应该可以工作。

  1. cargo install mates-rs(或使用 cargo install --git https://github.com/shalzz/mates.rs 安装开发版本)
  2. ~/.cargo/bin/ 添加到您的路径中。其中的二进制文件不依赖于 Rust 或 Cargo,只依赖于 glibcgrep

Shell 完成脚本

可以通过运行 mates completions 命令在运行时生成 Shell 完成脚本。

用法

将环境变量 MATES_DIR 设置为您的 .vcf 文件夹。然后使用 --help 运行二进制文件以列出所有命令。

其他环境变量包括

  • MATES_GREP,覆盖要使用的 grep 二进制文件。默认为 grep。此命令必须接受一个搜索字符串作为第一个参数和一个文件路径作为第二个参数。
  • MATES_INDEX,联系人索引的文件路径。默认为 ~/.mates_index

注意:“mates index” 必须定期调用。即使在使用 mates 的命令时,索引也不会自动更新,因为这会严重影响 UI 响应性。

集成

Aerc

查询

aerc.conf 中指定 address-book-cmd

address-book-cmd= mates mutt-query --disable-empty-line %s

Mutt

mutt 中的查询命令(电子邮件自动完成)

# ~/.muttrc

set query_command= "mates mutt-query '%s'"

# Normally you'd have to hit Ctrl-T for completion.
# This rebinds it to Tab.
bind editor <Tab> complete-query
bind editor ^T    complete

从消息创建新的联系人

# ~/.muttrc

macro index,pager A \
    "<pipe-message>mates add | xargs sh -c 'mates edit \"$@\" < /dev/tty || rm -v \"$@\"' mates<enter>" \
    "add the sender address"

使用此配置,在查看消息或在其文件夹视图中突出显示时按下A,将将其添加到您的联系人中,并在mates编辑器中打开新的联系人。如果您按下Ctrl-C,联系人将被删除。

使用模糊查找器进行电子邮件选择

selectafzf是工具,可以用来代替grep搜索联系人

m() {
    mutt "$(MATES_GREP=selecta mates email-query)"
}

m() {
    mutt "$(MATES_GREP='fzf -q' mates email-query)"
}

Selecta比fzf轻量得多,但另一方面fzf提供了一个更好的界面。

与CardDAV(Vdirsyncer)同步

Vdirsyncer可以用来将mates的MATES_DIR与CardDAV服务器同步。以下是一个简单的示例配置,其中MATES_DIR=~/.contacts/

[pair contacts]
a = contacts_local
b = contacts_remote

[storage contacts_local]
type = filesystem
path = ~/.contacts/
fileext = .vcf

[storage contacts_remote]
type = carddav
url = https://davserver.example.com/
username = foouser
password = foopass

许可

Mates是在MIT许可下发布的,有关详细信息,请参阅LICENSE

依赖项

~12–23MB
~306K SLoC