Skip to content

macOS: SSH detection fails due to BSD awk not supporting \s regex #27

@Traumt3nzer

Description

@Traumt3nzer

Description

On macOS, the plugin fails to detect SSH sessions when splitting panes. New panes open on the local machine instead of SSHing to the remote server.

Root Cause

The get_child_cmds() function in scripts/tmux-ssh-split.sh uses \s in the awk regex pattern (line 273):

ps -o ppid=,pid=,command= | \
  awk '/^\s*'"${ppid}"'\s+/ { $1=""; print $0 }'

macOS uses BSD awk, which does not support \s (Perl-style regex). The pattern silently fails to match, so no SSH process is ever found.

Reproduction

# On macOS, this returns nothing:
echo " 6485  6512 ssh" | awk '/^\s*6485\s+/ { print }'

# But this works:
echo " 6485  6512 ssh" | awk '/^[[:space:]]*6485[[:space:]]+/ { print }'

Fix

Replace \s with the POSIX character class [[:space:]]:

ps -o ppid=,pid=,command= | \
  awk '/^[[:space:]]*'"${ppid}"'[[:space:]]+/ { $1=""; print $0 }'

This works on both Linux (GNU awk) and macOS (BSD awk).

Environment

  • macOS (Darwin)
  • BSD awk (default on macOS)
  • tmux-ssh-split installed via TPM

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