zsh-users
 help / color / mirror / code / Atom feed
* from tcsh to zsh (alias)
@ 2010-06-08 10:24 Leander Jedamus
  2010-06-08 10:32 ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Leander Jedamus @ 2010-06-08 10:24 UTC (permalink / raw)
  To: zsh-users

Hi!

When I log in on antother machine with ssh, i want, that in the terminal 
window the address of this machine is shown. When I log out, the 
original machine name should be displayed. In tcsh I do the following:
alias cwdcmd  'echo -n 
"\033]2;${USER}@${HOST}:$cwd\007\033]1;${USER}@${HOST}:$cwd\007"'
alias   ssh     'ssh \!* ; cd .'
Now all parameters for the alias go to the original ssh-program. After 
that a "cd ." is done and everything is okay.

Now I want that under zsh:
if [ -n "$DISPLAY" ]; then
     chpwd()
     {
       echo -n 
"\e]2;${USER}@${HOST}:${PWD}\007\e]1;${USER}@${HOST}:${PWD}\007";
     };# chpwd()
     cd .
   fi

but now:
alias ssh="ssh $* ; cd ."
doesn't work as extpected.

What do I have to do now?

Thanks in advance
Leander Jedamus


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: from tcsh to zsh (alias)
  2010-06-08 10:24 from tcsh to zsh (alias) Leander Jedamus
@ 2010-06-08 10:32 ` Peter Stephenson
  2010-06-08 10:43   ` Leander Jedamus
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2010-06-08 10:32 UTC (permalink / raw)
  To: zsh-users

On Tue, 08 Jun 2010 12:24:08 +0200
Leander Jedamus <ljedamus@googlemail.com> wrote:
> alias ssh="ssh $* ; cd ."
> doesn't work as extpected.

This needs to be a function since aliases don't take arguments (because
functions are generally more powerful and replace many uses of aliases):

ssh() {
   ssh "$@"
   cd .
}

See http://zsh.sourceforge.net/FAQ/zshfaq02.html#l12

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: from tcsh to zsh (alias)
  2010-06-08 10:32 ` Peter Stephenson
@ 2010-06-08 10:43   ` Leander Jedamus
  2010-06-08 11:04     ` Sebastian Stark
  0 siblings, 1 reply; 6+ messages in thread
From: Leander Jedamus @ 2010-06-08 10:43 UTC (permalink / raw)
  To: zsh-users

Am 08.06.2010 12:32, schrieb Peter Stephenson:
> ssh "$@"
Now it says:
ssh:2: maximum nested function level reached
How can I prevent loops? Ah, I read some further:
ssh() {
   command ssh "$@"
   cd .
}


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: from tcsh to zsh (alias)
  2010-06-08 10:43   ` Leander Jedamus
@ 2010-06-08 11:04     ` Sebastian Stark
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Stark @ 2010-06-08 11:04 UTC (permalink / raw)
  To: Leander Jedamus; +Cc: zsh-users


Am 08.06.2010 um 12:43 schrieb Leander Jedamus:

> Am 08.06.2010 12:32, schrieb Peter Stephenson:
>> ssh "$@"
> Now it says:
> ssh:2: maximum nested function level reached
> How can I prevent loops? Ah, I read some further:
> ssh() {
>  command ssh "$@"
>  cd .
> }

A function like this even works in case of failure of the ssh command as well as when ssh is still trying to connect:

ssh () {
        set_title ${*##-*}
        {
                command ssh "$@"
        } always {
                set_title ${HOST/.*}
        }
}




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: from tcsh to zsh (alias)
  2010-06-08 10:22 Leander Jedamus
@ 2010-06-08 20:22 ` Wayne Davison
  0 siblings, 0 replies; 6+ messages in thread
From: Wayne Davison @ 2010-06-08 20:22 UTC (permalink / raw)
  To: Leander Jedamus; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 248 bytes --]

On Tue, Jun 8, 2010 at 3:22 AM, Leander Jedamus <ljedamus@web.de> wrote:

> alias ssh="ssh $* ; cd ."
>

$* has no special meaning in an alias.  You should instead use a function,
like this:

function ssh
{
    command ssh $@
    cd .
}

..wayne..

^ permalink raw reply	[flat|nested] 6+ messages in thread

* from tcsh to zsh (alias)
@ 2010-06-08 10:22 Leander Jedamus
  2010-06-08 20:22 ` Wayne Davison
  0 siblings, 1 reply; 6+ messages in thread
From: Leander Jedamus @ 2010-06-08 10:22 UTC (permalink / raw)
  To: zsh-users

Hi!

When I log in on antother machine with ssh, i want, that in the terminal 
window the address of this machine is shown. When I log out, the 
original machine name should be displayed. In tcsh I do the following:
alias cwdcmd  'echo -n 
"\033]2;${USER}@${HOST}:$cwd\007\033]1;${USER}@${HOST}:$cwd\007"'
alias   ssh     'ssh \!* ; cd .'
Now all parameters for the alias go to the original ssh-program. After 
that a "cd ." is done and everything is okay.

Now I want that under zsh:
if [ -n "$DISPLAY" ]; then
     chpwd()
     {
       echo -n 
"\e]2;${USER}@${HOST}:${PWD}\007\e]1;${USER}@${HOST}:${PWD}\007";
     };# chpwd()
     cd .
   fi

but now:
alias ssh="ssh $* ; cd ."
doesn't work as extpected.

What do I have to do now?

Thanks in advance
Leander Jedamus


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-06-08 20:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-08 10:24 from tcsh to zsh (alias) Leander Jedamus
2010-06-08 10:32 ` Peter Stephenson
2010-06-08 10:43   ` Leander Jedamus
2010-06-08 11:04     ` Sebastian Stark
  -- strict thread matches above, loose matches on Subject: below --
2010-06-08 10:22 Leander Jedamus
2010-06-08 20:22 ` Wayne Davison

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).