|
1 | 1 | # MacVimSwitch |
2 | | -> Except for the code from [macism](https://github.com/laishulu/macism), all other parts of this project are generated by AI, as I don't know Swift. |
| 2 | +> 这个项目的代码除了 [macism](https://github.com/laishulu/macism) 的部分,其他完全由 AI 生成,我本人不会 swift |
3 | 3 |
|
4 | | -[English](README.md) | [中文说明](README_CN.md) |
| 4 | +[English](README_EN.md) | [中文说明](README.md) |
5 | 5 |
|
6 | | -MacVimSwitch is a utility for macOS that automatically switches input sources, designed specifically for Vim users and those who frequently switch between CJKV(Chinese/Japanese/Korean/Vietnamese) input methods. Thx to [macism](https://github.com/laishulu/macism) for the input method switching solution. |
| 6 | +MacVimSwitch 是一个 macOS 输入法切换工具,专为 Vim 用户和经常需要切换中文输入法的用户设计。感谢 [macism](https://github.com/laishulu/macism) 提供的输入法切换方案。 |
7 | 7 |
|
8 | | -## Features |
| 8 | +## 功能特点 |
9 | 9 |
|
10 | | -- Automatically switches to ABC input method when pressing ESC |
11 | | -- Built-in Shift key switching feature (enabled by default), switch between ABC English input method and Chinese/Japanese/Korean/Vietnamese input method |
12 | | - - Important: Before using, please disable the "Use Shift to switch between English and Chinese/Japanese/Korean/Vietnamese" option in your input method settings |
13 | | - - Can be disabled in the status bar menu if needed |
14 | | -- If you don't want to use Shift key switching, on Mac, CapsLock short press to switch input method, long press for caps lock |
15 | | -- Runs in the background with a status bar icon |
16 | | -- Auto-starts on system login (can be disabled from menu bar) |
17 | | -- Recommend: Use [inputsource.pro](https://inputsource.pro/) to automatically switch input method for each application. You can set a default input method for each application, for example, set the default input method to English in the browser and to Chinese in Vim. |
| 10 | +- 按 ESC 键时自动切换到 ABC 英文输入法,可以设置只在部分应用中生效(如 Vscode、Terminal、Obsidian、Cursor) |
| 11 | +- Shift 键切换 ABC 英文输入法 和 中文/日文/韩文/越南文输入法(可以是任何中文输入法, 如搜狗、讯飞、微信输入法等) |
| 12 | + - 重要提示:使用前请先关闭输入法中的"使用 Shift 切换中英文"选项 |
| 13 | + - 如需关闭可在状态栏菜单中设置 |
| 14 | +- 后台运行,状态栏显示图标 |
| 15 | +- 温馨提示:如果你不想使用 Shift 键切换输入法,在 Mac 上,CapsLock 短按可以切换输入法,长按才是锁定大写 |
| 16 | +- 系统登录时自动启动(可在菜单栏中关闭) |
| 17 | +- 推荐:配合上 [inputsource.pro](https://inputsource.pro/)这类能设置每个应用默认输入法的程序使用体验更佳。举个例子,你进入到浏览器中默认是中文输入法,进入 Vim 中默认是英文输入法。就不需要自己频繁切换输入法了。 |
18 | 18 |
|
19 | | - |
| 19 | +<img width="383" alt="Image" src="https://github.com/user-attachments/assets/0eb4b7a0-c229-4334-b1ff-cd78dd477196" /> |
20 | 20 |
|
| 21 | +## 安装方法 |
21 | 22 |
|
22 | | -## Installation |
| 23 | +从 [GitHub Releases](https://github.com/Jackiexiao/macvimswitch/releases) 下载并手动安装。 |
23 | 24 |
|
24 | | -Download from [GitHub Releases](https://github.com/Jackiexiao/macvimswitch/releases) and install it manually. |
| 25 | +## 使用方法 |
25 | 26 |
|
26 | | -## Usage |
| 27 | +1. 首次启动: |
| 28 | + - 解压后打开 MacVimSwitch |
| 29 | + - 根据提示授予辅助功能权限 |
| 30 | + - 打开系统偏好设置 → 安全性与隐私 → 隐私 → 辅助功能 |
| 31 | + - 添加并启用 MacVimSwitch |
| 32 | + - 重启应用程序,状态栏图标应该出现了。 |
27 | 33 |
|
28 | | -1. First Launch: |
29 | | - - Unzip and open MacVimSwitch |
30 | | - - Grant Accessibility permissions when prompted |
31 | | - - Go to System Preferences → Security & Privacy → Privacy → Accessibility |
32 | | - - Add and enable MacVimSwitch |
33 | | - - Restart the app |
| 34 | +2. 首次使用重要设置: |
| 35 | + - 关闭输入法中的"使用 Shift 切换中英文"选项,避免冲突 |
| 36 | + - 可以在状态栏菜单中选择您偏好的中文输入法 |
| 37 | + - 您必须为“选择上一个输入源”启用 MacOS 键盘快捷键,该快捷键可在“首选项 - > 键盘 - > 快捷键 - > InputSource”中找到。 |
| 38 | + - 快捷方式可以是您想要的任何内容,macism 将从该条目中读取快捷方式并在需要时通过仿真触发它。只是为了确保您已经启用了快捷方式。 |
34 | 39 |
|
35 | | -2. Important first-time setup: |
36 | | - - Disable the "Use Shift to switch between English and Chinese" option in your input method settings |
37 | | - - You can select your preferred Chinese input method from the status bar menu |
38 | | - - You must enable the MacOS keyboard shortcut for "Select the previous input source", which can be found in "Preference -> Keyboard -> Shortcuts -> Input Source". |
39 | | - - The shortcut can be anything as your wish, macism will read the shortcut from that entry and trigger it by emulation when needed. Just to make sure you have already enabled the shortcut. |
| 40 | +3. 菜单栏选项: |
| 41 | + - 点击状态栏的键盘图标可以: |
| 42 | + - 查看使用说明 |
| 43 | + - 选择偏好的中文输入法 |
| 44 | + - 开启/关闭 Shift 键切换功能 |
| 45 | + - 选择 Esc 生效的应用(可多选,默认在 Terminal、VSCode、MacVim、windsurf、obsidian、warp 中生效) |
| 46 | + - 开启/关闭开机自动启动 |
| 47 | + - 退出应用程序 |
40 | 48 |
|
41 | | -3. Menu Bar Options: |
42 | | - - Click the keyboard icon in the menu bar to: |
43 | | - - View instructions |
44 | | - - Select your preferred Chinese input method |
45 | | - - Enable/Disable Shift key switching |
46 | | - - Select the applications that you want to enable `Esc` to switch input source, by default, vscode, terminal, obsidian, cursor, windsurf, warp are enabled. |
47 | | - - Enable/Disable launch at login |
48 | | - - Quit the application |
| 49 | +## 开发者指南 |
49 | 50 |
|
| 51 | +### 发布流程 |
50 | 52 |
|
51 | | -## Why MacVimSwitch? |
52 | | - |
53 | | -MacVimSwitch offers several advantages over other input source switching solutions: |
54 | | - |
55 | | -1. Universal Compatibility |
56 | | - - Works across all applications (VSCode, Terminal, Obsidian, Cursor, etc.) |
57 | | - - No need for application-specific configurations |
58 | | - - No plugins required for different editors |
59 | | - |
60 | | -2. Input Method Agnostic |
61 | | - - Works with any Chinese/Japanese/Korean/Vietnamese input method |
62 | | - - Supports popular input methods like Sogou, iFlytek, WeChat Input, etc. |
63 | | - - Easy to switch between different input methods |
64 | | - |
65 | | -3. Flexible Switching Options |
66 | | - - Use Shift key for quick switching (enabled by default) |
67 | | - - Or use CapsLock if you prefer (macOS built-in feature) |
68 | | - - ESC key always switches to ABC input method (perfect for Vim users) |
69 | | - |
70 | | -### Input Method Switching Options |
71 | | - |
72 | | -1. Using Shift (Default) |
73 | | - - Quick and convenient |
74 | | - - Similar to CapsLock behavior |
75 | | - - Can be disabled if not needed |
76 | | - |
77 | | -2. Using CapsLock (Built-in macOS Feature) |
78 | | - - System-level feature |
79 | | - - Short press to switch input methods |
80 | | - - Long press for caps lock |
81 | | - - Works alongside MacVimSwitch |
82 | | - |
83 | | -Choose the method that best suits your workflow! |
84 | | - |
85 | | - |
86 | | -## For Developers |
87 | | - |
88 | | -### How to Release |
89 | | - |
90 | | -1. Create GitHub Repository |
91 | | -Create a new repository at github.com/jackiexiao/macvimswitch |
92 | | -2. Clone and initialize the repository |
93 | | -``` |
| 53 | +1. 创建 GitHub 仓库 |
| 54 | +```bash |
| 55 | +# 1. 在 github.com/jackiexiao/macvimswitch 创建新仓库 |
| 56 | +# 2. 克隆并初始化仓库 |
94 | 57 | git clone https://github.com/jackiexiao/macvimswitch.git |
95 | 58 | cd macvimswitch |
96 | 59 | ``` |
97 | | -3. Release |
| 60 | + |
| 61 | +2. 准备发布文件 |
| 62 | +```bash |
| 63 | +# 添加所有必要文件 |
| 64 | +git add macvimswitch.swift README.md README_CN.md LICENSE |
| 65 | +git commit -m "Initial commit" |
| 66 | +git push origin main |
98 | 67 | ``` |
99 | | -Tag the release |
| 68 | + |
| 69 | +3. 创建发布版本 |
| 70 | +```bash |
| 71 | +# 标记版本 |
100 | 72 | git tag -a v1.0.0 |
101 | 73 | git push origin v1.0.0 |
102 | 74 | ``` |
103 | | -4. Formula |
104 | | -``` |
105 | | -bash |
106 | | -1. Create a new repository: github.com/jackiexiao/homebrew-tap (if not exists) |
107 | | -2. Clone the repository |
108 | | -``` |
| 75 | +GitHub Actions 工作流会自动: |
| 76 | +- 构建应用程序 |
| 77 | +- 创建包含应用程序包(.app)和源代码包(.tar.gz)的发布版本 |
| 78 | +- 计算并显示用于更新 Homebrew formula 的 SHA256 值 |
| 79 | +更新 Homebrew Formula |
| 80 | + |
| 81 | + |
| 82 | +4. 创建 Homebrew Tap |
| 83 | +```bash |
| 84 | +# 1. 创建新仓库:github.com/jackiexiao/homebrew-tap(如果不存在) |
| 85 | +# 2. 克隆仓库 |
109 | 86 | git clone https://github.com/jackiexiao/homebrew-tap.git |
110 | 87 | cd homebrew-tap |
111 | | -``` |
112 | | -3. Update the SHA256 in macvimswitch.rb with the one from GitHub Release |
113 | | -4. Commit and push the formula |
| 88 | + |
| 89 | +# 3. 使用 GitHub Release 中提供的 SHA256 值更新 macvimswitch.rb |
| 90 | +# 4. 提交并推送 formula |
114 | 91 | git add macvimswitch.rb |
115 | | -git commit -m "Update MacVimSwitch formula to v1.0.0" |
| 92 | +git commit -m "更新 MacVimSwitch formula 到 v1.0.0" |
116 | 93 | git push origin main |
117 | 94 | ``` |
118 | | -5. Apply for a tap |
119 | 95 |
|
120 | | -### Development |
| 96 | +### 本地开发 |
121 | 97 |
|
122 | | -To build and test locally: |
| 98 | +本地构建和测试: |
123 | 99 | ```bash |
124 | 100 | ./build.sh |
125 | 101 | pkill -f MacVimSwitch |
| 102 | +# 人工测试方法1: |
126 | 103 | ./dist/MacVimSwitch.app/Contents/MacOS/MacVimSwitch |
127 | | -# first, open MacVimSwitch, delete permissions |
| 104 | + |
| 105 | +# 人工测试方法2: |
| 106 | +# 如果你使用 双击打开 dist/MacVimSwitch.app,你可能需要这样做 |
| 107 | +# 打开第一次,辅助功能先把之前的 MacVimSwitch 删除,看起来好像必须得这么做 |
128 | 108 | open dist/MacVimSwitch.app |
129 | | -# second, open MacVimSwitch, allow permissions |
| 109 | +# 打开第二次,启动辅助功能 |
130 | 110 | open dist/MacVimSwitch.app |
131 | | -# third, open MacVimSwitch, now it works |
| 111 | +# 打开第三次,相当于重启应用,这个时候你才能正确获取授权 |
132 | 112 | open dist/MacVimSwitch.app |
133 | 113 | ``` |
134 | 114 |
|
135 | | -Build for release |
| 115 | +构建发布版本: |
136 | 116 | ```bash |
137 | 117 | ./build.sh --create-dmg |
138 | 118 | tccutil reset All com.jackiexiao.macvimswitch # Reset permissions |
139 | 119 | # open MacVimSwitch.dmg |
140 | 120 | ``` |
141 | 121 |
|
142 | | -### Contributing |
| 122 | +Github Actions 工作流会在 git push --tag v1.0.0 时自动构建 |
| 123 | + |
| 124 | +如果想要在本地调试 Github Actions 工作流,以 mac 为例,可以使用 |
| 125 | +``` |
| 126 | +brew install act |
| 127 | +act -l |
| 128 | +act push -e .github/workflows/push.event.json --container-architecture linux/amd64 |
| 129 | +``` |
| 130 | + |
| 131 | +### 贡献代码 |
| 132 | + |
| 133 | +1. Fork 本仓库 |
| 134 | +2. 创建特性分支 (`git checkout -b feature/amazing-feature`) |
| 135 | +3. 提交更改 (`git commit -m '添加某个很棒的特性'`) |
| 136 | +4. 推送到分支 (`git push origin feature/amazing-feature`) |
| 137 | +5. 提交 Pull Request |
| 138 | + |
| 139 | +## 许可证 |
| 140 | + |
| 141 | +本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件。 |
| 142 | + |
| 143 | +## 为什么选择 MacVimSwitch? |
| 144 | + |
| 145 | +MacVimSwitch 相比其他输入法切换方案有以下优势: |
| 146 | + |
| 147 | +1. 通用兼容性 |
| 148 | + - 可在所有应用程序中使用(VSCode、终端、Obsidian、Cursor、Warp、Windsurf 等) |
| 149 | + - 无需针对不同应用进行配置 |
| 150 | + - 不需要为不同编辑器安装插件 |
| 151 | + |
| 152 | +2. 输入法无关性 |
| 153 | + - 支持任何中文输入法 |
| 154 | + - 兼容搜狗、讯飞、微信输入法等主流输入法 |
| 155 | + - 可以方便地在不同输入法间切换 |
| 156 | + |
| 157 | +3. 灵活的切换选项 |
| 158 | + - 使用 Shift 键快速切换(默认开启) |
| 159 | + - 或使用 CapsLock(macOS 内置功能) |
| 160 | + - ESC 键始终切换到英文(对 Vim 用户很友好) |
143 | 161 |
|
144 | | -1. Fork the repository |
145 | | -2. Create your feature branch (`git checkout -b feature/amazing-feature`) |
146 | | -3. Commit your changes (`git commit -m 'Add some amazing feature'`) |
147 | | -4. Push to the branch (`git push origin feature/amazing-feature`) |
148 | | -5. Open a Pull Request |
| 162 | +### 输入法切换选项 |
149 | 163 |
|
150 | | -## License |
| 164 | +1. 使用 Shift 键(默认方式) |
| 165 | + - 快速便捷 |
| 166 | + - 类似 CapsLock 的行为 |
| 167 | + - 可根据需要关闭 |
151 | 168 |
|
152 | | -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 169 | +2. 使用 CapsLock(macOS 内置功能) |
| 170 | + - 系统级功能 |
| 171 | + - 短按切换输入法 |
| 172 | + - 长按锁定大写 |
| 173 | + - 可与 MacVimSwitch 同时使用 |
153 | 174 |
|
| 175 | +选择最适合您工作流程的方式! |
154 | 176 |
|
155 | | -## Acknowledgments |
| 177 | +# 感谢 |
156 | 178 |
|
157 | | -- [macism](https://github.com/laishulu/macism) for the input method switching solution |
| 179 | +- [macism](https://github.com/laishulu/macism) 提供的输入法切换方案 |
0 commit comments