zsh-users
 help / color / mirror / code / Atom feed
* known hosts tab completion
@ 2012-04-04  7:58 Daniel Shahaf
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Shahaf @ 2012-04-04  7:58 UTC (permalink / raw)
  To: zsh-users

(4.3.15, FreeBSD port. I already tried manpages and IRC.)

In ~/.ssh/config I have three hosts: foo.tld foo-1.tld foo-2.tld

At a new prompt, under 'zsh -f; autoload compinit; compinit', 
I type:   ssh foo<tab>

I get:    ssh foo<cursor>.tld

What I want to do: complete to 'foo.tld' and move to the end of the
input line, in order enter a command (e.g., 'ssh foo.tld <cursor>'
in order to run 'ssh foo.tld date')

I don't see how to do that.

I see two workarounds: (a) press <tab> three times, to cycle through the
completions once; (b) 'setopt MENU_COMPLETE' (but that loses me
the ability to complete an unambiguous prefix (namely, 'cd ~/d<tab>' ->
'cd ~/do<cursor>' when ~/docs and ~/dots exist), which is a deal breaker
for me).

As to possible solutions, I'd be happy with something that doesn't fill
the ".tld" part to the right of the cursor, as then I could just type
'.<tab>' to get what I want (with the trailing space, even).

Pointers, please?


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

* Re: known hosts tab completion
  2012-06-23 18:28   ` Mikael Magnusson
@ 2012-06-24  8:39     ` Daniel Shahaf
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Shahaf @ 2012-06-24  8:39 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Bart Schaefer, Matt Woodson, zsh-users

Mikael Magnusson wrote on Sat, Jun 23, 2012 at 20:28:00 +0200:
> On 23 June 2012 20:18, Bart Schaefer <schaefer@brasslantern.com> wrote:
> > On Jun 22,  2:48pm, Matt Woodson wrote:
> > }
> > } Let's say I have these hosts:
> > }
> > } host01.stage.example.com
> > } host02.stage.example.com
> > } host01.prod.example.com
> > } host02.prod.example.com
> > }
> > } now, in my prompt, I will type:
> > }
> > } $ ssh hos<tab>
> > }
> > } zsh will show me:
> > }
> > } $ ssh host..example.com
> > }
> > } with the cursor right after "host" and shows me a menu with the host
> > } names in it. I like the menu showing me hostnames, I just don't want
> > } it to complete everything.
> >
> > This similar to the confusion about the default matcher-list that was
> > discussed about a month ago in the "completion oddity" thread (starts
> > with zsh-users/17099 if you want to check the archives).
> >
> > In this case, though, the default matcher-list does not include the
> > dot character, so you must have a zstyle that does.  Disable it for
> > this context and you should be able to get the behavior you want.
> 
> The default matcher-list for host completion does have the . in it, or
> rather it uses a hardcoded compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=*
> r:|=*', as do a couple of other completions. zsh -f gives me the
> "magic" behaviour with just compinit, and I don't think you can

I get the same behaviour I describe in the original post under 'zsh -f'
with compinit, too.

> override compadd -M 'foo' provided stuff with styles.
> 
> -- 
> Mikael Magnusson


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

* Re: known hosts tab completion
  2012-06-23 18:18 ` Bart Schaefer
  2012-06-23 18:28   ` Mikael Magnusson
@ 2012-06-23 22:48   ` Matt Woodson
  1 sibling, 0 replies; 6+ messages in thread
From: Matt Woodson @ 2012-06-23 22:48 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users, d.s

On Sat, Jun 23, 2012 at 2:18 PM, Bart Schaefer
<schaefer@brasslantern.com> wrote:

> This similar to the confusion about the default matcher-list that was
> discussed about a month ago in the "completion oddity" thread (starts
> with zsh-users/17099 if you want to check the archives).
>
> In this case, though, the default matcher-list does not include the
> dot character, so you must have a zstyle that does.  Disable it for
> this context and you should be able to get the behavior you want.


I don't know if this is true.  I only have one matcher-list:

$ zstyle -L | grep matcher
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
$

Is there something else I need to change?


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

* Re: known hosts tab completion
  2012-06-23 18:18 ` Bart Schaefer
@ 2012-06-23 18:28   ` Mikael Magnusson
  2012-06-24  8:39     ` Daniel Shahaf
  2012-06-23 22:48   ` Matt Woodson
  1 sibling, 1 reply; 6+ messages in thread
From: Mikael Magnusson @ 2012-06-23 18:28 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Matt Woodson, zsh-users, d.s

On 23 June 2012 20:18, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Jun 22,  2:48pm, Matt Woodson wrote:
> }
> } Let's say I have these hosts:
> }
> } host01.stage.example.com
> } host02.stage.example.com
> } host01.prod.example.com
> } host02.prod.example.com
> }
> } now, in my prompt, I will type:
> }
> } $ ssh hos<tab>
> }
> } zsh will show me:
> }
> } $ ssh host..example.com
> }
> } with the cursor right after "host" and shows me a menu with the host
> } names in it. I like the menu showing me hostnames, I just don't want
> } it to complete everything.
>
> This similar to the confusion about the default matcher-list that was
> discussed about a month ago in the "completion oddity" thread (starts
> with zsh-users/17099 if you want to check the archives).
>
> In this case, though, the default matcher-list does not include the
> dot character, so you must have a zstyle that does.  Disable it for
> this context and you should be able to get the behavior you want.

The default matcher-list for host completion does have the . in it, or
rather it uses a hardcoded compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=*
r:|=*', as do a couple of other completions. zsh -f gives me the
"magic" behaviour with just compinit, and I don't think you can
override compadd -M 'foo' provided stuff with styles.

-- 
Mikael Magnusson


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

* Re: known hosts tab completion
  2012-06-22 18:48 Matt Woodson
@ 2012-06-23 18:18 ` Bart Schaefer
  2012-06-23 18:28   ` Mikael Magnusson
  2012-06-23 22:48   ` Matt Woodson
  0 siblings, 2 replies; 6+ messages in thread
From: Bart Schaefer @ 2012-06-23 18:18 UTC (permalink / raw)
  To: Matt Woodson, zsh-users; +Cc: d.s

On Jun 22,  2:48pm, Matt Woodson wrote:
}
} Let's say I have these hosts:
} 
} host01.stage.example.com
} host02.stage.example.com
} host01.prod.example.com
} host02.prod.example.com
} 
} now, in my prompt, I will type:
} 
} $ ssh hos<tab>
} 
} zsh will show me:
} 
} $ ssh host..example.com
} 
} with the cursor right after "host" and shows me a menu with the host
} names in it. I like the menu showing me hostnames, I just don't want
} it to complete everything.

This similar to the confusion about the default matcher-list that was
discussed about a month ago in the "completion oddity" thread (starts
with zsh-users/17099 if you want to check the archives).

In this case, though, the default matcher-list does not include the
dot character, so you must have a zstyle that does.  Disable it for
this context and you should be able to get the behavior you want.


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

* Re: known hosts tab completion
@ 2012-06-22 18:48 Matt Woodson
  2012-06-23 18:18 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Matt Woodson @ 2012-06-22 18:48 UTC (permalink / raw)
  To: zsh-users; +Cc: d.s

I am reviving this question from a few months ago.  I have asked this
question on stack exchange, and didn't get any answers.  I am really
hoping someone here can help me out.

http://unix.stackexchange.com/questions/35483/zsh-host-name-completion-behaviour-change

I have been using ZSH to do host name completion, and want to change
the default behaviour. When I have multiple hosts with similar names,
the completion does stuff that I don't care for. An example is best:

Let's say I have these hosts:

host01.stage.example.com
host02.stage.example.com
host01.prod.example.com
host02.prod.example.com

now, in my prompt, I will type:

$ ssh hos<tab>

zsh will show me:

$ ssh host..example.com

with the cursor right after "host" and shows me a menu with the host
names in it. I like the menu showing me hostnames, I just don't want
it to complete everything. Weird things happen. Most of the time I tab
through and either have to delete host names or have extra stuff on
the line i have to delete.

A preferred way would be to not complete the rest of the hostname.
something like:

$ ssh hos<tab>

zsh would hopefully show me:

$ ssh host
host01.stage.example.com  host01.prod.example.com
host02.stage.example.com  host02.prod.example.com

I have also noticed when i start putting in host names like:

host-server01.stg.example.com
host-server01.prod.example.com

and I do my "ssh host<tab>", it will take me to the subdomain first.

All i really want is this to complete like normal completion, and not
dance around on me.  Any thoughts?


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

end of thread, other threads:[~2012-06-24  8:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-04  7:58 known hosts tab completion Daniel Shahaf
2012-06-22 18:48 Matt Woodson
2012-06-23 18:18 ` Bart Schaefer
2012-06-23 18:28   ` Mikael Magnusson
2012-06-24  8:39     ` Daniel Shahaf
2012-06-23 22:48   ` Matt Woodson

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