zsh-users
 help / color / mirror / code / Atom feed
* ssh and chdir to my PWD on the local computer
@ 2019-07-19 17:40 TJ Luoma
  2019-07-19 21:45 ` Roman Perepelitsa
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: TJ Luoma @ 2019-07-19 17:40 UTC (permalink / raw)
  To: Zsh MailingList

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-07-22 15:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-19 17:40 ssh and chdir to my PWD on the local computer TJ Luoma
2019-07-19 21:45 ` Roman Perepelitsa
2019-07-20 16:36 ` gi1242+zsh
2019-07-22 15:55 ` Philippe Troin

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).