From ebf287f9f60fbeb22f0f7bd02555edc28f304591 Mon Sep 17 00:00:00 2001 From: Lonny Wong Date: Thu, 15 Jun 2023 22:55:30 +0800 Subject: [PATCH] config: support `~` as user's home directory for `Include` e.g., `Include ~/other/config` on Linux, `Include ~\other\config` on Windows. --- config.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.go b/config.go index 4816e67..ac5bfd6 100644 --- a/config.go +++ b/config.go @@ -732,6 +732,8 @@ func NewInclude(directives []string, hasEquals bool, pos Position, comment strin path = directives[i] } else if system { path = filepath.Join("/etc/ssh", directives[i]) + } else if strings.HasPrefix(directives[i], "~/") || strings.HasPrefix(directives[i], "~\\") { + path = filepath.Join(homedir(), directives[i][2:]) } else { path = filepath.Join(homedir(), ".ssh", directives[i]) }