zsh-users
 help / color / mirror / code / Atom feed
* Path does not update until I logout/log in
@ 2012-12-04 14:33 John
  2012-12-04 15:35 ` Norbert Zeh
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: John @ 2012-12-04 14:33 UTC (permalink / raw)
  To: zsh-users

If I install a new executable via my package manager, zsh doesn't allow me to see it via auto-completion until I either source my ~/.zshrc again.  Is there a setting that would control this?  Note that under bash, I don't need to tweak anything to get this behavior.

Here is another tangible example:

1) Open two xterms
2) In one xterm do this:  sudo ln -s /usr/bin/top /usr/bin/newsymlink

Now, if in the 2nd xterm I start typing, nothing happens for autocomplete:  newsy<TAB>

Here is my config file:

$ cat ~/.zshrc
ZSH=$HOME/.zsh

for config_file ($ZSH/lib/*.zsh) source $config_file


for i in aliases commonrc functions zsh ; do [[ -f $HOME/.$i ]] && . $HOME/.$i ; done


PROMPT='%(!.%{$fg_bold[red]%}.%{$fg_bold[white]%}%n@)%m %{$fg_bold[blue]%}%(!.%1~.%~) %#%{$reset_color%} '


REPORTTIME=5

autoload -U compinit

compinit -i


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

* Re: Path does not update until I logout/log in
  2012-12-04 14:33 Path does not update until I logout/log in John
@ 2012-12-04 15:35 ` Norbert Zeh
  2012-12-04 16:25   ` Bart Schaefer
  2012-12-04 15:38 ` Guillaume Brunerie
       [not found] ` <20121204153753.GG19774@Hailey>
  2 siblings, 1 reply; 7+ messages in thread
From: Norbert Zeh @ 2012-12-04 15:35 UTC (permalink / raw)
  To: zsh-users

On 12-12-04 10:33 AM, John wrote:
> If I install a new executable via my package manager, zsh doesn't allow me to see it via auto-completion until I either source my ~/.zshrc again.  Is there a setting that would control this?  Note that under bash, I don't need to tweak anything to get this behavior.
>
> Here is another tangible example:
>
> 1) Open two xterms
> 2) In one xterm do this:  sudo ln -s /usr/bin/top /usr/bin/newsymlink
>
> Now, if in the 2nd xterm I start typing, nothing happens for autocomplete:  newsy<TAB>
>
> Here is my config file:
>
> $ cat ~/.zshrc
> ZSH=$HOME/.zsh
>
> for config_file ($ZSH/lib/*.zsh) source $config_file
>
>
> for i in aliases commonrc functions zsh ; do [[ -f $HOME/.$i ]] && . $HOME/.$i ; done
>
>
> PROMPT='%(!.%{$fg_bold[red]%}.%{$fg_bold[white]%}%n@)%m %{$fg_bold[blue]%}%(!.%1~.%~) %#%{$reset_color%} '
>
>
> REPORTTIME=5
>
> autoload -U compinit
>
> compinit -i
zsh uses a hash table to store the list of known commands.  When you 
install a new command in your path, you need to update this hashtable by 
invoking "rehash".  This is similar to csh, I believe (been a while 
since I used this last).  bash, on the other hand, does a search for 
valid commands every single time.  zsh provides this possibility, too, 
by setting the "rehash" option, but this is disabled by default because 
it incurs a speed penalty.

Cheers,
Norbert


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

* Re: Path does not update until I logout/log in
  2012-12-04 14:33 Path does not update until I logout/log in John
  2012-12-04 15:35 ` Norbert Zeh
@ 2012-12-04 15:38 ` Guillaume Brunerie
       [not found] ` <20121204153753.GG19774@Hailey>
  2 siblings, 0 replies; 7+ messages in thread
From: Guillaume Brunerie @ 2012-12-04 15:38 UTC (permalink / raw)
  To: John; +Cc: zsh-users

Hello,

You can use the `rehash' command which will update the list of known commands.
You can put this command in your precmd() if you don’t want to have to
do it everytime.

Guillaume

2012/12/4 John <da_audiophile@yahoo.com>:
> If I install a new executable via my package manager, zsh doesn't allow me to see it via auto-completion until I either source my ~/.zshrc again.  Is there a setting that would control this?  Note that under bash, I don't need to tweak anything to get this behavior.
>
> Here is another tangible example:
>
> 1) Open two xterms
> 2) In one xterm do this:  sudo ln -s /usr/bin/top /usr/bin/newsymlink
>
> Now, if in the 2nd xterm I start typing, nothing happens for autocomplete:  newsy<TAB>
>
> Here is my config file:
>
> $ cat ~/.zshrc
> ZSH=$HOME/.zsh
>
> for config_file ($ZSH/lib/*.zsh) source $config_file
>
>
> for i in aliases commonrc functions zsh ; do [[ -f $HOME/.$i ]] && . $HOME/.$i ; done
>
>
> PROMPT='%(!.%{$fg_bold[red]%}.%{$fg_bold[white]%}%n@)%m %{$fg_bold[blue]%}%(!.%1~.%~) %#%{$reset_color%} '
>
>
> REPORTTIME=5
>
> autoload -U compinit
>
> compinit -i


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

* Re: Path does not update until I logout/log in
  2012-12-04 15:35 ` Norbert Zeh
@ 2012-12-04 16:25   ` Bart Schaefer
  0 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2012-12-04 16:25 UTC (permalink / raw)
  To: zsh-users

On Dec 4, 11:35am, Norbert Zeh wrote:
}
} zsh uses a hash table to store the list of known commands.  When you 
} install a new command in your path, you need to update this hashtable by 
} invoking "rehash".  This is similar to csh, I believe (been a while 
} since I used this last).  bash, on the other hand, does a search for 
} valid commands every single time.  zsh provides this possibility, too, 
} by setting the "rehash" option, but this is disabled by default because 
} it incurs a speed penalty.

Just to clarify, "rehash" is a zstyle (manual section for Completion
System Configuration), not an option.

The manual probably ought to have an example of how to set this.  It may
never make sense to use a context other than ":completion:*", but I'm not
sure.


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

* Re: Path does not update until I logout/log in
       [not found] ` <20121204153753.GG19774@Hailey>
@ 2012-12-04 18:27   ` John
  2012-12-04 20:10     ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: John @ 2012-12-04 18:27 UTC (permalink / raw)
  To: Daniel Wallace, zsh-users

> You need to run rehash

> 
> or use something like 
> _force_rehash() {
>     (( CURRENT == 1 )) && rehash
>     return 1    # Because we didn't really complete anything
> }
> zstyle ':completion:::::' completer _force_rehash _complete _approximate


Thank you all for the replies and especially to Daniel for the above which is working for me.


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

* Re: Path does not update until I logout/log in
  2012-12-04 18:27   ` John
@ 2012-12-04 20:10     ` Bart Schaefer
  2012-12-05  0:37       ` John
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2012-12-04 20:10 UTC (permalink / raw)
  To: John, Daniel Wallace, zsh-users@zsh.org 

On Dec 4, 10:27am, John wrote:
}
} > zstyle ':completion:::::' completer _force_rehash _complete _approximate
} 
} Thank you all for the replies and especially to Daniel for the above
} which is working for me.

One more clarification -- this:

    zstyle ':completion:*' rehash yes

accomplishes the same thing as Daniel's _force_rehash, without requiring
that you add a new function to your completer zstyle.

I suppose there might be some middling-old versions of zsh that don't
support the rehash style, in which case Daniel's solution would be a
good workaround.


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

* Re: Path does not update until I logout/log in
  2012-12-04 20:10     ` Bart Schaefer
@ 2012-12-05  0:37       ` John
  0 siblings, 0 replies; 7+ messages in thread
From: John @ 2012-12-05  0:37 UTC (permalink / raw)
  To: Bart Schaefer, Daniel Wallace, zsh-users@zsh.org 

Nice, thank you.


----- Original Message -----
> From: Bart Schaefer <schaefer@brasslantern.com>
> To: John <da_audiophile@yahoo.com>; Daniel Wallace <daniel.wallace@gatech.edu>; "zsh-users@zsh.org " <zsh-users@zsh.org>
> Cc: 
> Sent: Tuesday, December 4, 2012 3:10 PM
> Subject: Re: Path does not update until I logout/log in
> 
> On Dec 4, 10:27am, John wrote:
> }
> } > zstyle ':completion:::::' completer _force_rehash _complete 
> _approximate
> } 
> } Thank you all for the replies and especially to Daniel for the above
> } which is working for me.
> 
> One more clarification -- this:
> 
>     zstyle ':completion:*' rehash yes
> 
> accomplishes the same thing as Daniel's _force_rehash, without requiring
> that you add a new function to your completer zstyle.
> 
> I suppose there might be some middling-old versions of zsh that don't
> support the rehash style, in which case Daniel's solution would be a
> good workaround.
>


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

end of thread, other threads:[~2012-12-05  0:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-04 14:33 Path does not update until I logout/log in John
2012-12-04 15:35 ` Norbert Zeh
2012-12-04 16:25   ` Bart Schaefer
2012-12-04 15:38 ` Guillaume Brunerie
     [not found] ` <20121204153753.GG19774@Hailey>
2012-12-04 18:27   ` John
2012-12-04 20:10     ` Bart Schaefer
2012-12-05  0:37       ` John

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