Repository navigation
docs: document --template variables and add SSHFS and RDP examples - #160
Arnaudmyges wants to merge 3 commits into
Conversation
The --template option is the way to run something other than ssh (see quantumsheep#84), but the README did not mention it. Add a section listing the variables a template can use, explaining that the command runs without a shell, and giving two examples: SSHFS and RDP through FreeRDP. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
|
||
| ```bash | ||
| sshs --config ~/.config/rdp-hosts \ | ||
| --template 'xfreerdp3 /v:{{{destination}}}{{#if port}}:{{{port}}}{{/if}}{{#if user}} "/u:{{{user}}}"{{/if}} /dynamic-resolution +clipboard' |
There was a problem hiding this comment.
This is specific to X11 FreeRDP 3, can it also be forward compatible by using xfreerdp without the 3?
| --template 'xfreerdp3 /v:{{{destination}}}{{#if port}}:{{{port}}}{{/if}}{{#if user}} "/u:{{{user}}}"{{/if}} /dynamic-resolution +clipboard' | |
| --template 'xfreerdp /v:{{{destination}}}{{#if port}}:{{{port}}}{{/if}}{{#if user}} "/u:{{{user}}}"{{/if}} /dynamic-resolution +clipboard' |
There was a problem hiding this comment.
Good point, done in 1bfb015. One catch: Arch Linux and Debian/Ubuntu ship FreeRDP 3 as xfreerdp3 / sdl-freerdp3 (Fedora and Homebrew keep xfreerdp), so I added a short note below the example for those distributions.
…ributions Co-Authored-By: Claude Opus 5.5 <[email protected]>
| | Variable | Value | | ||
| | --------------- | -------------------------------------------------------- | | ||
| | `name` | First pattern of the `Host` line | | ||
| | `aliases` | Other patterns of the `Host` line, joined with `, ` | |
There was a problem hiding this comment.
| | `aliases` | Other patterns of the `Host` line, joined with `, ` | | |
| | `aliases` | Other identical patterns, joined with `, ` | |
Aliases are created when all options of the host are exactly the same. It's possible for multiple hosts on the same line to have different configuration.
|
|
||
| ## Custom commands with templates | ||
|
|
||
| By default, selecting a host runs `ssh "{{{name}}}"`. The `--template` option replaces that command with your own [Handlebars](https://handlebarsjs.com/guide/) template, so sshs can launch any tool from the same host list. |
There was a problem hiding this comment.
| By default, selecting a host runs `ssh "{{{name}}}"`. The `--template` option replaces that command with your own [Handlebars](https://handlebarsjs.com/guide/) template, so sshs can launch any tool from the same host list. | |
| By default, selecting a host runs `ssh "{{{name}}}"`. The `--template` / `-t` option replaces that command with your own [Handlebars](https://handlebarsjs.com/guide/) template, so sshs can launch any tool from the same host list. |
| Mount a host with [SSHFS](https://github.com/libfuse/sshfs): | ||
|
|
||
| ```bash | ||
| sshs --template 'sshfs "{{{name}}}":/path/to/remote /path/to/local' |
There was a problem hiding this comment.
This mounts the filesystem, what about using --on-session-end-template the unmount?
| sshs --template 'sshfs "{{{name}}}":/path/to/remote /path/to/local' | |
| sshs --template 'sshfs "{{{name}}}":/path/to/remote /path/to/local' --on-session-end-template "fusermount -u /path/to/local" |
Note: I'm not sure of the syntax
There was a problem hiding this comment.
Good idea, done in 788054a, with one change: sshfs goes to the background as soon as the filesystem is mounted, so as the main template it returns right away and the end template would unmount immediately. The example now mounts in --on-session-start-template, opens ranger on the mount point as the main command, and unmounts in --on-session-end-template when you quit it (same idea as the ranger workflow in #84). I checked the order with sshs 4.8.0: start, main, then end. I used fusermount3 -u, since sshfs 3 depends on FUSE 3 and Arch only ships fusermount with the separate fuse2 package; there is a note for umount on macOS.
Mount in --on-session-start-template (sshfs goes to the background once mounted), browse with a file manager, unmount in --on-session-end-template. Co-Authored-By: Claude Opus 5.5 <[email protected]>
--templateis how sshs runs something other thanssh(you pointed to it for SSHFS in #84), but the README does not mention it, so its variables can only be found in the source.This adds a "Custom commands with templates" section:
name,aliases,destination,user,port,proxy_command), taken fromssh::Host;shlexand run without a shell, so pipes,&&and$VARdo not work (with ash -cworkaround);--on-session-start-template/--on-session-end-template;I use the RDP one to get the same picker for my Windows hosts; it was tested with sshs 4.8.0. The SSHFS command is the one from #84.
Docs only, no code change.
🤖 Generated with Claude Code