2024-05-24 01:31:11 +00:00
# terminal-url-handler
## motivation
It would be great to put a link in my notes to the directory I working in on a project, and it opens a terminal right to there.
2024-05-24 02:33:48 +00:00
Something simple like a [URI ](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier ) to the directory you had a terminal open.
2024-05-24 01:31:11 +00:00
## install
2024-05-25 15:41:39 +00:00
This requires a golang compiler.
2024-05-24 01:31:11 +00:00
```shell
2024-05-25 15:44:10 +00:00
git clone https://git.batts.cloud/vbatts/terminal-url-handler
2024-05-24 02:33:48 +00:00
cd terminal-url-handler
2024-05-24 01:31:11 +00:00
make user-install
```
2024-05-24 02:33:48 +00:00
## examples
Say you keep a notebook/journal/whatever in an app that allows hyperlinks (markdown, html, etc.).
Create a link:
```markdown
2024-05-25 15:44:10 +00:00
[terminal-url-handler ](terminal:///$HOME/src/terminal-url-handler )
2024-05-24 02:33:48 +00:00
```
2024-05-25 15:44:10 +00:00
i.e. [terminal-url-handler ](terminal:///$HOME/src/terminal-url-handler )
2024-05-24 02:33:48 +00:00
```html
< a href = "terminal://~/src/terminal-url-handler" > terminal-url-handler< / a >
```
2024-05-25 15:41:39 +00:00
## Types of URIs
2024-05-24 01:31:11 +00:00
2024-05-25 15:41:39 +00:00
multiple cases of URIs, and we are not dealing with query parameters.
No shell execution.
2024-05-24 01:31:11 +00:00
2024-05-25 15:41:39 +00:00
- terminal:///home/user
- terminal://host:/home/user
- terminal://host/home/user
- terminal://user@host:/home/user
- terminal://user@host:port/home/user
## default terminal?
On most Linux desktops, the `x-terminal-emulator` is an [`update-alternatives` ](https://www.man7.org/linux/man-pages/man1/update-alternatives.1.html ) symlink to a Terminal app like `gnome-terminal` or whatever.
To see alternatives for `x-terminal-emulator` , run:
```shell
$ update-alternatives --list x-terminal-emulator
/usr/bin/gnome-terminal.wrapper
/usr/bin/koi8rxterm
/usr/bin/lxterm
/usr/bin/uxterm
/usr/bin/xfce4-terminal.wrapper
/usr/bin/xterm
```
2024-05-24 01:31:11 +00:00
2024-05-25 15:41:39 +00:00
To change this, say to `xfce4-terminal` , run:
2024-05-24 01:31:11 +00:00
```shell
2024-05-25 15:41:39 +00:00
sudo update-alternatives --set x-terminal-emulator /usr/bin/xfce4-terminal.wrapper
2024-05-24 01:31:11 +00:00
```
2024-05-25 15:41:39 +00:00
## development
happy to take contributions or enhancements.
This seems like something that ought to be built-in for most desktops.
2024-05-24 01:31:11 +00:00
### XDG
all this business of `x-scheme-handlers` and desktop files, I am surprised there isn't a simple GUI that can help creating and indexing them.
Discovering `x-scheme-handlers` is a programatic enough, but is currently primarily from shell?
Whatever.
https://portland.freedesktop.org/doc/xdg-settings.html
2024-05-24 02:33:48 +00:00
### Future improvements?
2024-05-25 15:44:10 +00:00
- [x] if a `user@host` is included, then ssh to the host
- [ ] YOUR CHOICE
2024-05-24 02:33:48 +00:00
2024-05-24 01:31:11 +00:00
## LICENSE
See [LICENSE ](./LICENSE )