Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Include directive with absolute paths #29

Open
svenk-ct opened this issue Jul 1, 2024 · 0 comments
Open

Handle Include directive with absolute paths #29

svenk-ct opened this issue Jul 1, 2024 · 0 comments

Comments

@svenk-ct
Copy link

svenk-ct commented Jul 1, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant