Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
ssh and chdir to my PWD on the local computer
- X-seq: zsh-users 24078
- From: TJ Luoma <luomat@xxxxxxxxx>
- To: Zsh MailingList <zsh-users@xxxxxxx>
- Subject: ssh and chdir to my PWD on the local computer
- Date: Fri, 19 Jul 2019 13:40:02 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=U1BnbX7TjxK/4ciODgq9EN8XG17trdl7gTHhGZVTD3I=; b=lIxh3Fn5I42q8sHh2jTv19tdUG/qxNC/kFdXYTJEqIEyHtN16IfT1cyS5eUCnHkV2g 3ZvbldXn1w1ShxNCmcgcUVZJW4J109BTmyB4QJjAbF0LQg73FH+IIQOegVuHSLprdB7E 0R8F9QbDyO60/GIB+VZccmNFdoESH3qLrB4tV4Ft9DEs+P/+BEgh74U1jKi3VG+ldsmX 8BcpgBZbVRknHpADewGhVW8Cw0eHKP7CrNbWO3AsaKTOdVabssiY7CY2KnaS37OmjtlQ RlEI20Zk13IvpYOUJnkTFqaN1yUDf3QwZO879WCTp6NugFKwxvQAQfF6c2AtECfoZWyN CV+Q==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
I wanted to be able to ssh to another computer and immediately chdir
to the same directory that I was using locally.
I came up with _a_ solution, but I'm not sure if it's a good one, or
if there would be other ways to do this more easily/better, so I'm
sharing it here.
Since all of the computers are under my own control, I was able to
accomplish this by editing the ssh_config and sshd_config files to add
`SendEnv CWD` and `AcceptEnv CWD` respectively.
/etc/ssh/ssh_config: SendEnv CWD
/etc/ssh/sshd_config: AcceptEnv CWD
I also added this to the end of my .zshrc file:
if [[ "$CWD" != "" ]]
then
echo "changing to '$CWD'"
cd "$CWD"
fi
Then I was able to use this by connecting to my remote computer like this:
CWD=$PWD ssh remote.host.tld
The last part seems a little clunky, although I'm sure I could make a
function or something, but I wondered if anyone else has solved this a
different way, and if so, how… or does anyone have a suggestion how to
do this differently / better?
Thanks for your time
Tj
--
TJ Luoma
TJ @ MacStories
Personal Website: luo.ma (aka RhymesWithDiploma.com)
Twitter: @tjluoma
Messages sorted by:
Reverse Date,
Date,
Thread,
Author