Skip to content

Feature request: local snippets/actions templated with selected host credentials #87

@Nab0y

Description

@Nab0y

Summary

It would be useful to extend Purple snippets with a mode that runs the snippet command on the local host machine, while still using the currently selected Purple host/credentials to build the command.

The main use case is quickly opening remote config files in local tools such as Fresh, which supports SSH remote editing from a local command.

Use case

Fresh can open remote files/directories via SSH using command-line arguments:

fresh user@host:/etc/nginx/nginx.conf
fresh ssh://deploy@server.example.com:2222/etc/nginx/nginx.conf
fresh ssh://alice@host/home/alice/src/main.rs:42:7

Docs: https://getfresh.dev/docs/features/ssh

Today, Purple snippets are great for commands that should run on the remote server. However, for this workflow I would like to select a host in Purple and run a local command such as:

fresh ssh://{{user}}@{{host}}:{{port}}/opt

or:

fresh {{user}}@{{host}}:/etc/nginx/nginx.conf

The command should execute locally, not over SSH on the remote machine, but the placeholders should be populated from the selected Purple host entry.

Proposed behavior

Add a snippet execution mode, for example:

[[snippets]]
name = "Open /opt in Fresh"
mode = "local"
command = "fresh ssh://{{user}}@{{host}}:{{port}}/opt"

When the snippet is run for the selected host, Purple would expand the host-related placeholders and execute the resulting command on the local machine.

Example:

fresh ssh://deploy@app-01.example.com:2222/opt

Possible placeholders
Useful placeholders could include:

{{host}}
{{hostname}}
{{user}}
{{port}}
{{alias}}
{{identity_file}}
{{proxy_jump}}

If Purple already has a canonical internal host model, exposing the same fields used for SSH config generation would probably be enough.

Why this is useful

This would make Purple a launcher for local tools that operate on remote hosts, without duplicating connection details manually.

Example workflows:

  • Open /etc/nginx/nginx.conf on the selected server in Fresh
  • Open /opt, /var/log, or an app directory in Fresh's remote file explorer
  • Launch other local SSH-aware tools using Purple's selected host context
  • Avoid manually copying usernames, hosts, ports, and aliases from ~/.ssh/config

Notes
Fresh itself performs the SSH connection, so Purple would only need to build and launch the local command. This keeps the feature generic: Fresh is just one example, while the same local-snippet mode could support other SSH-aware local tools too.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions