Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ssh and chdir to my PWD on the local computer
- X-seq: zsh-users 24084
- From: Philippe Troin <phil@xxxxxxxx>
- To: TJ Luoma <luomat@xxxxxxxxx>, Zsh MailingList <zsh-users@xxxxxxx>
- Subject: Re: ssh and chdir to my PWD on the local computer
- Date: Mon, 22 Jul 2019 08:55:43 -0700
- In-reply-to: <CADjGqHts+Kjj3Ogw3kNUkUaJerWBeNN+2HDJ0f=XDnO3e3kbng@mail.gmail.com>
- 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
- References: <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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author