From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id fb4abca3 for ; Mon, 22 Jul 2019 15:56:33 +0000 (UTC) Received: (qmail 21545 invoked by alias); 22 Jul 2019 15:56:21 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24084 Received: (qmail 27376 invoked by uid 1010); 22 Jul 2019 15:56:21 -0000 X-Qmail-Scanner-Diagnostics: from granite.fifsource.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25517. spamassassin: 3.4.2. Clear:RC:0(173.255.216.206):SA:0(-1.9/5.0):. Processed in 1.922946 secs); 22 Jul 2019 15:56:21 -0000 X-Envelope-From: phil@fifi.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at fifi.org designates 173.255.216.206 as permitted sender) Message-ID: <7b08e19cf12d115c40e47139417591be24c7d6c2.camel@fifi.org> Subject: Re: ssh and chdir to my PWD on the local computer From: Philippe Troin To: TJ Luoma , Zsh MailingList Date: Mon, 22 Jul 2019 08:55:43 -0700 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.4 (3.32.4-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 [ [...]]" return 1 ;; (1) term=-t ;; esac local host=$1 shift ssh $term $host cd ${(q)PWD} '&& exec $SHELL' ${1+-c} ${(qj: :)*} } Phil.