Skip to content

Commit 0950e86

Browse files
feat: add ability to set Path option in .sshconfig (#58)
1 parent 8b0974c commit 0950e86

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,19 @@ With this plugin you can:
173173
To learn more about SSH configs and how to write/style one you can read more [here](https://linuxize.com/post/using-the-ssh-config-file/)
174174

175175

176+
### Custom `Path` Option
177+
178+
`Path` is **not** a valid OpenSSH option — adding it directly to `~/.ssh/config` will fail.
179+
Instead, store it as a comment so SSH ignores it but the plugin can read it:
180+
181+
```sshconfig
182+
Host my-alias
183+
HostName example.com
184+
User myuser
185+
# Path=/home/myuser/projects
186+
```
187+
188+
176189
### 🔔 Callback
177190

178191
You can manage callbacks on events like `on_connect_success` using the following methods:

lua/remote-sshfs/utils.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ M.parse_hosts_from_configs = function(ssh_configs)
5555
local current_config = vim.fn.expand(path)
5656
if vim.fn.filereadable(current_config) == 1 then
5757
for line in io.lines(current_config) do
58+
-- Check for our custom Path comment
59+
local path_value = line:match "^%s*#%s*Path=(.+)$"
60+
if path_value and #current_hosts > 0 then
61+
for _, host in ipairs(current_hosts) do
62+
hosts[host]["Path"] = path_value
63+
end
64+
end
5865
-- Ignore comments and empty lines
5966
if line:sub(1, 1) ~= "#" and line:match "%S" then
6067
-- Check if the line is a Host entry

0 commit comments

Comments
 (0)