3 unstable releases
0.2.1 | Jul 13, 2023 |
---|---|
0.2.0 | Mar 29, 2023 |
0.1.0 | Feb 6, 2021 |
#181 in Text editors
43KB
872 lines
GhostText-Any
A GhostText server for any $EDITOR
.
Built on idanarye's ghost-text-file
.
GhostText-Any allows you to edit any text box in your browser (Firefox/Chromium-based) with anything you can set your $EDITOR
to.
It does this by saving any edit request from the GhostText extension (sent over a WebSocket) as a file and opening said file with your preferred $EDITOR
. Whenever the file is written to or your $EDITOR
closes, the contents are sent back to the browser. Whenever the textbox is updated in your browser, the file is updated with the new text.
Want to reply to the comments on any website with ed
? Go right ahead.
Getting Started
To use it:
- Install the browser extension
- Install this:
cargo install ghosttext-any
(requires cargo/rust) - Run
gtany
in a terminal. - Click on a textbox in your browser and trigger the GhostText extension.
- Tada! Your
$EDITOR
is opened in the same terminal with the content of the textbox. Write, quit, and the same content will be updated in your browser.
By default, gtany
only spawns a single instance at a time (based on the assumption that your $EDITOR
uses the terminal it's spawned in, and you don't want multiple instances fighting over /dev/tty
). If you'd like multiple concurrent instances to be spawned, use the -m
/--multi
flag.
If you don't have $EDITOR
set or you'd like to run something else, you can specify a command to run with the -e
/--editor
flag.
For example, if you'd like to spawn a new terminal window with your $EDITOR
whenever you use GhostText, you could use a command like this:
gtany --multi --editor "x-terminal-emulator -e $EDITOR"
(If you don't use a Unix-y OS or do but not with X11 or do but not with a terminal emulator that supports -e
, you'll need to figure something else out).
Systemd Socket Activation
If you use a Linux distribution with systemd, you can run GhostText-Any as a socket-activated service, where systemd watches the GhostText port and only starts GhostText-Any when you use the browser extension. Combined with the --idle-timeout
flag, it will automatically start up and shut down when the browser extension is closed.
- Build GhostText-Any with systemd support enabled:
cargo install ghosttext-any --features systemd
- Copy the example systemd files from this repo,
gtany.socket
andgtany.service
, to~/.config/systemd/user/
- Update the
ExecStart
field ingtany.service
to call your preferred$EDITOR
. - Load the units:
systemctl --user daemon-reload
- Enable the socket:
systemctl --user enable gtany.socket
- Check the status:
systemctl --user status gtany.{socket,service}
Dependencies
~15–30MB
~393K SLoC