* Running additional shell startup commands
@ 2015-07-30 6:24 Dominik Vogt
2015-07-30 7:45 ` Mateusz Karbowy
2015-07-30 7:49 ` lilydjwg
0 siblings, 2 replies; 5+ messages in thread
From: Dominik Vogt @ 2015-07-30 6:24 UTC (permalink / raw)
To: Zsh Users
Often, I ssh to another machine, and the first thing I do there is
to change the working directory, e.g.
$ ssh <some machine>
$ cd ~/src/git/...
I'm looking for a way to specify that in some way on the ssh
command line but cannot figure out how to do that. Zsh takes
either input from stdin, or from a command specified with -c, or
from a script, so things like
$ ssh <...> zsh -c 'cd ~/src/git' -s
or
$ ssh <...> zsh -s <script>
don't work. The only thing I can think of would be to copy a
script to the machine with scp and source that at shell startup,
but that is way too much bother and too limited in application to
be useful (works only if the config on the target machine is
changed).
(Is there a good reason why -s cannot be combined with -c or a
script name anyway?)
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
IBM Germany
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Running additional shell startup commands
2015-07-30 6:24 Running additional shell startup commands Dominik Vogt
@ 2015-07-30 7:45 ` Mateusz Karbowy
2015-07-30 7:55 ` Dominik Vogt
2015-07-30 7:49 ` lilydjwg
1 sibling, 1 reply; 5+ messages in thread
From: Mateusz Karbowy @ 2015-07-30 7:45 UTC (permalink / raw)
To: vogt, Zsh Users
http://serverfault.com/questions/167416/change-directory-automatically-on-ssh-login
On 30 July 2015 at 07:24, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> Often, I ssh to another machine, and the first thing I do there is
> to change the working directory, e.g.
>
> $ ssh <some machine>
> $ cd ~/src/git/...
>
> I'm looking for a way to specify that in some way on the ssh
> command line but cannot figure out how to do that. Zsh takes
> either input from stdin, or from a command specified with -c, or
> from a script, so things like
>
> $ ssh <...> zsh -c 'cd ~/src/git' -s
>
> or
>
> $ ssh <...> zsh -s <script>
>
> don't work. The only thing I can think of would be to copy a
> script to the machine with scp and source that at shell startup,
> but that is way too much bother and too limited in application to
> be useful (works only if the config on the target machine is
> changed).
>
> (Is there a good reason why -s cannot be combined with -c or a
> script name anyway?)
>
> Ciao
>
> Dominik ^_^ ^_^
>
> --
>
> Dominik Vogt
> IBM Germany
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Running additional shell startup commands
2015-07-30 6:24 Running additional shell startup commands Dominik Vogt
2015-07-30 7:45 ` Mateusz Karbowy
@ 2015-07-30 7:49 ` lilydjwg
1 sibling, 0 replies; 5+ messages in thread
From: lilydjwg @ 2015-07-30 7:49 UTC (permalink / raw)
To: zsh-users
On Thu, Jul 30, 2015 at 07:24:19AM +0100, Dominik Vogt wrote:
> Often, I ssh to another machine, and the first thing I do there is
> to change the working directory, e.g.
>
> $ ssh <some machine>
> $ cd ~/src/git/...
>
> I'm looking for a way to specify that in some way on the ssh
> command line but cannot figure out how to do that. Zsh takes
> either input from stdin, or from a command specified with -c, or
> from a script, so things like
>
> $ ssh <...> zsh -c 'cd ~/src/git' -s
> [...]
I would use this for that:
ssh -t host 'sh -c "cd ~/src/git && exec zsh -l"'
--
Best regards,
lilydjwg
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Running additional shell startup commands
2015-07-30 7:45 ` Mateusz Karbowy
@ 2015-07-30 7:55 ` Dominik Vogt
2015-07-30 9:31 ` Julien Jehannet
0 siblings, 1 reply; 5+ messages in thread
From: Dominik Vogt @ 2015-07-30 7:55 UTC (permalink / raw)
To: Zsh Users
> On 30 July 2015 at 07:24, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> > Often, I ssh to another machine, and the first thing I do there is
> > to change the working directory, e.g.
> >
> > $ ssh <some machine>
> > $ cd ~/src/git/...
> >
> > I'm looking for a way to specify that in some way on the ssh
> > command line but cannot figure out how to do that. Zsh takes
> > either input from stdin, or from a command specified with -c, or
> > from a script, so things like
> >
> > $ ssh <...> zsh -c 'cd ~/src/git' -s
> >
> > or
> >
> > $ ssh <...> zsh -s <script>
> >
> > don't work. The only thing I can think of would be to copy a
> > script to the machine with scp and source that at shell startup,
> > but that is way too much bother and too limited in application to
> > be useful (works only if the config on the target machine is
> > changed).
> >
> > (Is there a good reason why -s cannot be combined with -c or a
> > script name anyway?)
On Thu, Jul 30, 2015 at 08:45:00AM +0100, Mateusz Karbowy wrote:
> http://serverfault.com/questions/167416/change-directory-automatically-on-ssh-login
This does it:
$ ssh -Y <machine> -t 'cd <dir>; exec zsh -i --login'
^^^^
The "-t" is important.
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
IBM Germany
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Running additional shell startup commands
2015-07-30 7:55 ` Dominik Vogt
@ 2015-07-30 9:31 ` Julien Jehannet
0 siblings, 0 replies; 5+ messages in thread
From: Julien Jehannet @ 2015-07-30 9:31 UTC (permalink / raw)
To: vogt, Zsh Users
[-- Attachment #1: Type: text/plain, Size: 1741 bytes --]
In case, you wish a ssh wrapper:
#!/bin/zsh -f
# Usage: ssh -ARG login@hostname:/go/to/directory/path
t=(${(s.:.)@[-1]})
if [ -n "${t[2]}" ]; then
exec /usr/bin/ssh -t ${@[1,-2]} ${t[1]} "cd ${t[2]}; exec \$SHELL -l"
else
exec /usr/bin/ssh $@
fi
2015-07-30 9:55 GMT+02:00 Dominik Vogt <vogt@linux.vnet.ibm.com>:
>
> > On 30 July 2015 at 07:24, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> > > Often, I ssh to another machine, and the first thing I do there is
> > > to change the working directory, e.g.
> > >
> > > $ ssh <some machine>
> > > $ cd ~/src/git/...
> > >
> > > I'm looking for a way to specify that in some way on the ssh
> > > command line but cannot figure out how to do that. Zsh takes
> > > either input from stdin, or from a command specified with -c, or
> > > from a script, so things like
> > >
> > > $ ssh <...> zsh -c 'cd ~/src/git' -s
> > >
> > > or
> > >
> > > $ ssh <...> zsh -s <script>
> > >
> > > don't work. The only thing I can think of would be to copy a
> > > script to the machine with scp and source that at shell startup,
> > > but that is way too much bother and too limited in application to
> > > be useful (works only if the config on the target machine is
> > > changed).
> > >
> > > (Is there a good reason why -s cannot be combined with -c or a
> > > script name anyway?)
>
> On Thu, Jul 30, 2015 at 08:45:00AM +0100, Mateusz Karbowy wrote:
> >
> http://serverfault.com/questions/167416/change-directory-automatically-on-ssh-login
>
> This does it:
>
> $ ssh -Y <machine> -t 'cd <dir>; exec zsh -i --login'
> ^^^^
>
> The "-t" is important.
>
> Ciao
>
> Dominik ^_^ ^_^
>
> --
>
> Dominik Vogt
> IBM Germany
>
>
--
J u l i e n J e h a n n e t
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-07-30 9:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-30 6:24 Running additional shell startup commands Dominik Vogt
2015-07-30 7:45 ` Mateusz Karbowy
2015-07-30 7:55 ` Dominik Vogt
2015-07-30 9:31 ` Julien Jehannet
2015-07-30 7:49 ` lilydjwg
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).