kd is an open-source command-line dictionary tool available on GitHub. Simply pass the word you want to look up, and it will immediately display information such as the word's definition and example sentences. It also includes a parameter for translating entire sentences, making it very convenient for frequent English-Chinese and Chinese-English translation needs.

kd is written in the Go language and supports Windows, MacOS, and Linux.
On Windows, you can use it directly after downloading kd.exe. When run for the first time, it generates a dictionary file at C:\Users\<Username>\.cache\kdcache\kd_data.db, which is used for local lookups.

Adding the -n option during execution will connect to the network dictionary online.

1. kd Usage Instructions

  • -h lists the usage instructions.
  • --update can update the software version.
c:/util # kd -h
NAME:
   kd - A crystal clean command-line dictionary.

USAGE:
   kd [global options]

VERSION:
   v0.0.12

AUTHOR:
   kmz <[email protected]>

GLOBAL OPTIONS:
   --nocache, -n            don't use cached result 不使用本地词库,查询网络结果
   --theme value, -T value  choose the color theme for current query 选择颜色主题,仅当前查询生效 (default: temp)
   --daemon                 ensure/start the daemon process 启动守护进程
   --update                 check and update kd client 更新kd的可执行文件
   --generate-config        generate config sample 生成配置文件,Linux/Mac默认地址为~/.config/kd.toml,Win为~\kd.toml
   --edit-config            edit configuration file with the default editor 用默认编辑器打开配置文件
   --help, -h               show help
   --version, -v            print the version

Just pass the word you want to look up directly. The displayed content includes DJ and KK phonetic transcriptions, Chinese definitions, English definitions, and example sentences.
An image to describe post

It can also perform Chinese-English translation.
An image to describe post

Adding the -t option allows you to translate entire sentences.
An image to describe post

2. Displaying Traditional Chinese

kd's dictionary uses Simplified Chinese. Although kd_data.db is an SQLite3 database, its content is compressed, making conversion somewhat complex. Therefore, the output can be directly passed to OpenCC for conversion to Traditional Chinese. For OpenCC installation and usage, please refer to my previous video: OpenCC(Open Chinese Convert)能準確的簡轉繁與繁轉簡,經常下載簡體網路小說的朋友們必備!(內嵌字幕)

The OpenCC command is c:\util\opencc\opencc -c c:\util\opencc\conf\s2tw.json, specifying conversion from Simplified Chinese to Taiwan Traditional Chinese format. After processing with OpenCC, the original display formatting (like colors, italics, etc.) might be lost.

An image to describe post

3. Integration with Obsidian

If you want to paste lookup results directly into Obsidian, you can use the Shell Commands plugin. Here are the steps:

  1. In the Shell Commands plugin settings, add a new command named kd. Copy the word to look up to the system clipboard. You can also try the Shell Commands' Prompt setting for a preview before execution.

  2. In the Shell Commands' Output tab, set 【Output channel for stdout】 to 【Current file: caret position】 to write the result at the cursor's location.

  3. Instead of {{clipboard}}, you can use {{selection}} to use the selected text. In this case, the output method must be changed to something else, such as outputting to the clipboard or the end of the file.
    An image to describe post

  4. Use the hotkey settings to assign a hotkey to the kd command.
    An image to describe post

  5. Copy a word to the clipboard and press the hotkey to insert the kd lookup results.
    An image to describe post

4. Other Integrations

Since kd is an executable file, it can be easily integrated with tools like AutoHotkey (Windows) and Raycast (MacOS). Please write your own scripts for this.

💡 Explanatory article: https://jdev.tw/blog/8622/
💡 Explanatory article OpenCC: https://jdev.tw/blog/5656/opencc-introduction

Karmenzind/kd: 跨平台命令行词典 a command-line dictionary supported Linux/Win/Mac
✅ OpenCC

6. Tutorial Video

https://youtu.be/r8hQwgbFOts