ITADN
daipeihust/im-select
daipeihust/im-select · 文件 下载 ZIP
文件最后提交记录最后更新时间
README.md
以下内容由 AI 翻译,如有问题请点此提交 issue 反馈

欢迎使用 im-select 👋

image

在 shell 中切换输入法。本项目是 VSCodeVim 的基础支持。它为 VSCodeVim 的 autoSwitchIM 功能提供命令行程序。

 

GitHub repo size GitHub repo file count GitHub release (by tag) GitHub issues GitHub GitHub release (latest by date) GitHub commit activity GitHub contributors GitHub last commit GitHub Discussions GitHub Repo stars

 

English | 简体中文

前提条件

  • 使用 VSCodeVim
  • 拥有一台 Mac/Windows/Linux 设备
  • 下载 git-bash(如果你使用 Windows)
  • 了解如何使用 shell

安装

macOS

Homebrew

brew tap daipeihust/tap
brew install im-select

或者你可以在控制台中运行以下命令:

curl -Ls https://raw.githubusercontent.com/daipeihust/im-select/master/install_mac.sh | sh

im-select 程序将被下载到您的 /usr/local/bin/ 路径。

windows

下载 im-select.exe,并将其移动到正确的路径。(如果您需要 64 位版本,可以下载 this one。)

linux

您无需为 linux 安装此程序。linux 拥有切换输入法的工具

Usage

macOS

如果您的 PATH 包含 /usr/local/bin,您可以直接使用 im-select 代替 /usr/local/bin/im-select

获取当前输入法按键

/usr/local/bin/im-select

切换当前输入法

/usr/local/bin/im-select imkey

例如 /usr/local/bin/im-select com.apple.keylayout.US

linux

ibus

@mengbo 提供了此 ibus 配置

"vim.autoSwitchInputMethod.enable": true,
"vim.autoSwitchInputMethod.defaultIM": "xkb:us::eng",
"vim.autoSwitchInputMethod.obtainIMCmd": "/usr/bin/ibus engine",
"vim.autoSwitchInputMethod.switchIMCmd": "/usr/bin/ibus engine {im}"

xkb-switch

@VEL4EG 提供了此 xkb-switch 配置

"vim.autoSwitchInputMethod.enable": true,
"vim.autoSwitchInputMethod.defaultIM": "us",
"vim.autoSwitchInputMethod.obtainIMCmd": "/usr/local/bin/xkb-switch",
"vim.autoSwitchInputMethod.switchIMCmd": "/usr/local/bin/xkb-switch -s {im}"

fcitx

@yunhao94 提供了此 fcitx 配置

"vim.autoSwitchInputMethod.enable": true,
"vim.autoSwitchInputMethod.defaultIM": "1",
"vim.autoSwitchInputMethod.obtainIMCmd": "/usr/bin/fcitx-remote",
"vim.autoSwitchInputMethod.switchIMCmd": "/usr/bin/fcitx-remote -t {im}",

gdbus

@d-r-q 为 gdbus 提供此配置

gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().currentSource.index" | awk -F'[^0-9]*' '{print $2}' 放入 get-im.sh。

gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().inputSources[$1].activate()" 放入 set-im.sh。

"vim.autoSwitchInputMethod.enable": true,
"vim.autoSwitchInputMethod.defaultIM": "0",
"vim.autoSwitchInputMethod.obtainIMCmd": "<path to get-im.sh>",
"vim.autoSwitchInputMethod.switchIMCmd": "<path to set-im.sh> {im}",

qdbus (KDE)

@igorechek06 提供了此 qdbus 配置

"vim.autoSwitchInputMethod.enable": true,
"vim.autoSwitchInputMethod.defaultIM": "0",
"vim.autoSwitchInputMethod.obtainIMCmd": "/usr/bin/qdbus org.kde.keyboard /Layouts getLayout",
"vim.autoSwitchInputMethod.switchIMCmd": "/usr/bin/qdbus org.kde.keyboard /Layouts setLayout {im}",

windows

im-select.exe 是一个命令行程序,但它无法在 cmd 或 powershell 中运行。这是微软的 bug,键盘 API 不支持在 cmd 和 powershell 中使用。我建议你使用 git-bash。

注意:git-bash 并非必需。它仅用于获取当前输入法按键,这在 VSCodeVim 的配置中是必需的。

Run tests

To get current keyboard locale

/path/to/im-select.exe

切换当前键盘区域设置

/path/to/im-select.exe locale

注意:Windows 中的路径格式如下:C:\Users\path\to\file

作者

🤝 贡献

如果您发现一些问题,欢迎创建拉取请求!

表达您的支持

如果这个项目对您有帮助,请给一个 ⭐️!

如果您喜欢它,请请我喝杯咖啡!如果您有任何问题,可以通过电子邮件联系我!

📝 许可证

本项目依据 MIT 许可证的条款进行授权。