zsh-users
 help / color / mirror / code / Atom feed
From: TJ Luoma <luomat@gmail.com>
To: Zsh MailingList <zsh-users@zsh.org>
Subject: ssh and chdir to my PWD on the local computer
Date: Fri, 19 Jul 2019 13:40:02 -0400	[thread overview]
Message-ID: <CADjGqHts+Kjj3Ogw3kNUkUaJerWBeNN+2HDJ0f=XDnO3e3kbng@mail.gmail.com> (raw)

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

             reply	other threads:[~2019-07-19 17:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-19 17:40 TJ Luoma [this message]
2019-07-19 21:45 ` Roman Perepelitsa
2019-07-20 16:36 ` gi1242+zsh
2019-07-22 15:55 ` Philippe Troin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADjGqHts+Kjj3Ogw3kNUkUaJerWBeNN+2HDJ0f=XDnO3e3kbng@mail.gmail.com' \
    --to=luomat@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).