diff --git a/bin/rclaude b/bin/rclaude index f4e22cc..9ebeeab 100755 --- a/bin/rclaude +++ b/bin/rclaude @@ -20,10 +20,15 @@ # Usage: # rclaude # local, $PWD # rclaude . # local, $PWD -# rclaude # remote $HOME on +# rclaude # remote: $PWD mirrored under remote $HOME +# rclaude . # same as above (explicit form) # rclaude # remote (or local) at # rclaude list # show active sessions across hosts # rclaude resume [pattern] # reattach (interactive if pattern matches >1) +# +# Mirror semantics: if local $PWD is $HOME/X/Y, the remote dir defaults to +# ~/X/Y on the remote (the remote's $HOME, not $HOME from this machine). +# If $PWD is outside $HOME, falls back to the remote's $HOME. set -eu @@ -221,11 +226,16 @@ if is_local "$host"; then .|"") dir=$PWD ;; esac else - if [ "$dir" = "." ]; then - echo "error: '.' as dir requires a local target; pass an explicit remote path" >&2 - exit 2 + # Remote default: mirror local $PWD relative to $HOME onto the remote's + # $HOME. Same behavior for omitted dir or explicit `.`. Falls back to + # remote $HOME if local $PWD isn't under $HOME. + if [ "$dir" = "." ] || [ -z "$dir" ]; then + case $PWD in + "$HOME") dir=\~ ;; + "$HOME"/*) _rel=${PWD#"$HOME"/}; dir="~/$_rel" ;; + *) dir=\~ ;; + esac fi - [ -z "$dir" ] && dir=\~ fi slug=$(printf %s "$dir" | sed -e 's|^[~/]*||' -e 's|[^A-Za-z0-9]|-|g')