From: Philippe Troin <phil@fifi.org>
To: TJ Luoma <luomat@gmail.com>, Zsh MailingList <zsh-users@zsh.org>
Subject: Re: ssh and chdir to my PWD on the local computer
Date: Mon, 22 Jul 2019 08:55:43 -0700 [thread overview]
Message-ID: <7b08e19cf12d115c40e47139417591be24c7d6c2.camel@fifi.org> (raw)
In-Reply-To: <CADjGqHts+Kjj3Ogw3kNUkUaJerWBeNN+2HDJ0f=XDnO3e3kbng@mail.gmail.com>
On Fri, 2019-07-19 at 13:40 -0400, TJ Luoma wrote:
> 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.
I use this function:
scd() {
local term=
case $# in
(0)
echo "usage: $0 <host> [<command> [<arguments>...]]"
return 1
;;
(1)
term=-t
;;
esac
local host=$1
shift
ssh $term $host cd ${(q)PWD} '&& exec $SHELL' ${1+-c} ${(qj: :)*}
}
Phil.
prev parent reply other threads:[~2019-07-22 15:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-19 17:40 TJ Luoma
2019-07-19 21:45 ` Roman Perepelitsa
2019-07-20 16:36 ` gi1242+zsh
2019-07-22 15:55 ` Philippe Troin [this message]
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=7b08e19cf12d115c40e47139417591be24c7d6c2.camel@fifi.org \
--to=phil@fifi.org \
--cc=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).