beectl.mirror
beectl - Crystal implementation of host program for Browser's External Editor
Browser's External Editor, aka chrome-bee, is a browser extension by Ruslan Osmanov that allows you to use an external editor to edit text areas in browser forms. It communicates with a host program called beectl that runs the editor and returns the edited text. The chrome-bee repository linked to above provides a Python implementation of the host program, and there is also a separate C implementation.
This Crystal implementation of beectl requires only an installation of the Crystal compiler, and has no other dependencies.
Installation
Build the program with either:
make
or:
crystal build --no-color src/beectl.cr
To make browser configuration a little simpler, I chose to copy the resulting binary file beectl
to /usr/local/bin
:
sudo cp beectl /usr/local/bin
Install the browser extension
Install the "Browser's External Editor" extension in Chrome or Firefox, using the normal sources for extensions. Then in the settings page for the extension, make the following changes:
- Set the path to your editor.
- Optionally, set some regular expressions and file extensions for specific sites. This isn't strictly necessary; I suspect it is only useful for editors that change their behavior based on file extensions (e.g., EMACS modes).
Now you have to create a native messaging manifest file for your browser, and also set a shortcut key.
Chrome
The full path of the manifest file is:
$HOME/.config/chromium/NativeMessagingHosts/com.ruslan_osmanov.bee.json
Create the directory $HOME/.config/chromium/NativeMessagingHosts
if it does not already exist. Then in that directory, create the file com.ruslan_osmanov.bee.json
with the following contents:
{
"allowed_origins" : [
"chrome-extension://haenebhcepllcpneciadjchacagagfkc/",
"chrome-extension://moakhilhbeednkjahjmomncgigcoemoi/",
"chrome-extension://hpjfedijojbkggipmcnoadekibdpcjde/"
],
"description" : "Bee - Browser's external editor",
"name" : "com.ruslan_osmanov.bee",
"path" : "/usr/local/bin/beectl",
"type" : "stdio"
}
The ID in the third chrome-extension
setting is the one I had to use for ungoogled-chromium. You can find the exact ID for your installation of the chrome-bee extension by going to your browser's extension settings and copying the ID you see there.
I have not tried standard Chrome, and do not know if the third chrome-extension
setting is necessary there.
Replace the value for the path
setting with the correct path to beectl
.
Finally, you will need to set the keyboard shortcut that will invoke the external editor. Visit chrome://extensions/shortcuts in chromium/chrome. Then set the shorcut for Browser's External Editor. I used Alt-E
to avoid conflict with Ctrl-E
, which is used for editing in entry fields.
Firefox
The full path of the manifest file is:
$HOME/.mozilla/native-messaging-hosts/com.ruslan_osmanov.bee.json
Create the directory $HOME/.mozilla/native-messaging-hosts
if it does not already exist. Then in that directory, create the file com.ruslan_osmanov.bee.json
with the following contents:
{
"name": "com.ruslan_osmanov.bee",
"description": "Bee - Browser's external editor",
"path": "/usr/local/bin/beectl",
"type": "stdio",
"allowed_extensions": [
"bee@ruslan_osmanov.com"
]
}
Replace the value for the path
setting with the correct path to beectl
.
Finally, you will need to set the keyboard shortcut that will invoke the external editor. In the settings page for the extension, click on the gear icon at the upper right corner of the settings, and select Manage Extension Shortcuts. I used Ctrl-7
to avoid conflict with the numerous existing shortcuts for Firefox and the other extensions I use.
Testing.
There is a simple spec test that simulates how the browser runs beectl. Run the test using:
make test
or
crystal spec --no-color
beectl.mirror
- 0
- 0
- 0
- 0
- 0
- 5 days ago
- May 15, 2025
MIT License
Wed, 21 May 2025 12:29:58 GMT