Mailing List Archive

zsh question
I use zsh as my primary shell. Whenever I install a new package on
my system, I have to source my ~/.zshrc for tab completion to work
on the new binary. Note that I can still run the new program (as
long as it's in my $PATH).

By default, it appears that bash doesn't behave like this---it seems
as though it always scans $PATH before attempting tab completion.

How can I enable this feature in zsh? That is, how can I have
application tab-completion auto-update (without having to source my
~/.zshrc)?

Thanks!
Matt

--
Matt Garman
email at: http://raw-sewage.net/index.php?file=email

--
gentoo-user@gentoo.org mailing list
Re: zsh question [ In reply to ]
On Mon, 11 Oct 2004, Matt Garman wrote:

> I use zsh as my primary shell. Whenever I install a new package on
> my system, I have to source my ~/.zshrc for tab completion to work
> on the new binary. Note that I can still run the new program (as
> long as it's in my $PATH).
>
> By default, it appears that bash doesn't behave like this---it seems
> as though it always scans $PATH before attempting tab completion.
>
> How can I enable this feature in zsh? That is, how can I have
> application tab-completion auto-update (without having to source my
> ~/.zshrc)?


The problem is that the programs in your PATH are stored in a data
structure that isn't automatically updated when you install new software.

Csh has a command to update the data structure - the command is "rehash" -
maybe csh has a similar command? Maybe (just maybe), "man zsh" will help.



--
touristic adj.

Having the quality of a tourist. Often
used as a pejorative, as in `losing touristic scum'. Often
spelled `turistic' or `turistik', so that phrase might be more
properly rendered `lusing turistic scum'.


--
gentoo-user@gentoo.org mailing list
Re: zsh question [ In reply to ]
On Tue, 12 Oct 2004, Ajai Khattri wrote:

> Csh has a command to update the data structure - the command is "rehash" -
> maybe csh has a similar command?


Of course, I meant to say "maybe zsh has a similar command?"


--

--
gentoo-user@gentoo.org mailing list
Re: zsh question [ In reply to ]
Hi,

* Matt Garman <garman@raw-sewage.net> [12/10/04 04:15]:
>
> I use zsh as my primary shell. Whenever I install a new package on
> my system, I have to source my ~/.zshrc for tab completion to work
> on the new binary. Note that I can still run the new program (as
> long as it's in my $PATH).
>
> By default, it appears that bash doesn't behave like this---it seems
> as though it always scans $PATH before attempting tab completion.
>
> How can I enable this feature in zsh? That is, how can I have
> application tab-completion auto-update (without having to source my
> ~/.zshrc)?

There is no need to source ~/.zshrc. Use the 'rehash' command to rebuild
the hash of commands. If you want this to be run each time you try
completion, I think something like this will work:

###

rehashComplete() {
rehash;
zle expand-or-complete;
}

zle -N rehash-complete rehashComplete

bindkey "\t" rehash-complete

###

This will run rehash and then complete whenever you press the tab key.
It will, of course, make completion slower.

See zshzle for more details.

HTH
Moshe

>
> Thanks!
> Matt
>
> --
> Matt Garman
> email at: http://raw-sewage.net/index.php?file=email
>
> --
> gentoo-user@gentoo.org mailing list
>

--
I love deadlines. I like the whooshing sound they make as they fly by.
-- Douglas Adams

Moshe Kaminsky <kaminsky@math.huji.ac.il>
Home: 08-9456841
Re: zsh question [ In reply to ]
On Tue, Oct 12, 2004 at 07:33:29AM +0200, Moshe Kaminsky wrote:
> * Matt Garman <garman@raw-sewage.net> [12/10/04 04:15]:
> > How can I enable this feature in zsh? That is, how can I have
> > application tab-completion auto-update (without having to source my
> > ~/.zshrc)?
>
> There is no need to source ~/.zshrc. Use the 'rehash' command to rebuild
> the hash of commands. If you want this to be run each time you try
> completion, I think something like this will work:

No need to do anything that complicated: man zshoptions. HASH_LIST_ALL is the option you want. You can get it to behave just like bash.
Tom
Re: Re: zsh question [ In reply to ]
On Tue, Oct 12, 2004 at 05:00:50PM -0400, Thomas Kirchner wrote:
> No need to do anything that complicated: man zshoptions.
> HASH_LIST_ALL is the option you want. You can get it to behave
> just like bash.

According to the man page, HASH_LIST_ALL is turned on by default.
Also, running "setopt" (with no arguments) lists all the options
that the user has changed from the default.

So my "setopt" output looks like the following:

interactive
login
monitor
shinstdin
zle

After doing a "setopt hashlistall", the output of "setopt" (with no
arguments) is the same as above.

As far as I can tell, I have HASH_LIST_ALL enabled, it just isn't
working as expected (and hasn't for at least a couple years).

I'm guessing that I'm just missing/overlooking something, but I
can't seem to figure it out.

Any more thoughts?

Thanks again,
Matt

--
Matt Garman
email at: http://raw-sewage.net/index.php?file=email

--
gentoo-user@gentoo.org mailing list
Re: Re: zsh question [ In reply to ]
On Tue, Oct 12, 2004 at 05:10:49PM -0500, Matt Garman wrote:
> As far as I can tell, I have HASH_LIST_ALL enabled, it just isn't
> working as expected (and hasn't for at least a couple years).

Hmm... yeah, I just tried it too, and don't see hash_list_all in my options. However, if I do setopt no_hash_list_all, that works.
I guess I'm not sure. It could be that it requires HASH_CMDS and HASH_DIRS, but I tried those and they did the same thing as hash_list_all; they didn't show.
Sorry I can't help more. I personally don't use/like hashing just for the speed effect. 'reh<tab>' is pretty easy after the rare emerge where I need a new command right away.
Tom