Skip to content

Handle Include directive with absolute paths #29

Open
@svenk-ct

Description

@svenk-ct

The code only handles Include directives in the SSH config with relative paths or in the home dir (~). To also support absolute paths, we need another alternative:

diff --git a/zsh-ssh.zsh b/zsh-ssh.zsh
index 9d0ce5d..ad175c8 100644
--- a/zsh-ssh.zsh
+++ b/zsh-ssh.zsh
@@ -19,7 +19,10 @@ _parse_config_file() {
   while IFS= read -r line || [[ -n "$line" ]]; do
     if [[ $line =~ ^[Ii]nclude[[:space:]]+(.*) ]] && (( $#match > 0 )); then
       local include_path="${match[1]}"
-      if [[ $include_path == ~* ]]; then
+      if [[ $include_path == /* ]]; then
+        # Absolute path, use as-is
+        expanded_include_path="$include_path"
+      elif [[ $include_path == ~* ]]; then
         # Replace the first occurrence of "~" in the string with the value of the environment variable HOME.
         local expanded_include_path=${include_path/#\~/$HOME}
       else

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions