Skip to content

Conversation

@lox
Copy link
Owner

@lox lox commented Oct 5, 2025

Summary

Simplify Match exec quoting to fix zsh completion parsing error

Problem

The complex quoting in the Match exec directive was breaking zsh's SSH host completion:

zsh:1: unmatched '
Missing Match criteria for $SSH_CONNECTION\\'

The issue occurred because zsh's SSH completion system parses ~/.ssh/config to extract hostnames, and it couldn't handle the nested quotes in:

Match host * exec "sh -c 'test -z \"$SSH_CONNECTION\"'"

Solution

Simplify to direct test command without sh -c wrapper:

Match host * exec "test -z $SSH_CONNECTION"

This simpler form:

  • Works correctly for SSH (tested with ssh -G)
  • Doesn't break zsh completion
  • Still provides the same behavior

Behavior

SSH_CONNECTION Result
Unset (local) Uses 1Password IdentityAgent ✓
Set (SSH session) Skips IdentityAgent, uses forwarded agent ✓

Fixes the zsh completion error while maintaining agent forwarding functionality.

Remove complex quoting from Match exec directive that was causing zsh
completion to fail with "unmatched '" error.

Changed from:
  Match host * exec "sh -c 'test -z \"$SSH_CONNECTION\"'"

To:
  Match host * exec "test -z $SSH_CONNECTION"

The simpler form works correctly:
- SSH_CONNECTION unset → uses 1Password IdentityAgent
- SSH_CONNECTION set → skips IdentityAgent, uses forwarded agent

And avoids breaking zsh's SSH host completion which parses the config file.
@lox lox merged commit d16b0cd into main Oct 5, 2025
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants