Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
zsh not reloading newly installed packages.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
_______0
Guru
Guru


Joined: 15 Oct 2012
Posts: 521

PostPosted: Sun Jan 13, 2013 2:44 pm    Post subject: zsh not reloading newly installed packages. Reply with quote

hi,

Does anyone know how to make zsh to learn about newly installed packages? It does not show the command and I have to close a terminal and open a new one then the new package command is recognized.

Is it possible to have zsh like bash that automagically recognizes newly installed apps?

thansk
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Sun Jan 13, 2013 2:49 pm    Post subject: Reply with quote

The same as for bash:
Code:
rehash

If a special completion file is provided, this will not be used until you reload the whole completion system (also the same as for bash); I never tried how to do that, but probably repeating the compinit command with your original options should do the trick.
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3256

PostPosted: Sun Jan 13, 2013 3:05 pm    Post subject: Reply with quote

You need something like this
Code:
# Enable automatic rehash of commands
_force_rehash() {
  (( CURRENT == 1 )) && rehash
  return 1   # Because we didn't really complete anything
}
zstyle ':completion:*' completer _oldlist _expand _force_rehash _complete
I can't remember where I got this from. I suspect it is from the zsh wiki, which has lots of nice tips.
_________________
emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Sun Jan 13, 2013 5:34 pm    Post subject: Reply with quote

This is a nice trick: It calls rehash practically in every line as soon as you invoke completion. I guess that it will not work if you enter the command without completion, so I guess calling rehash in precmd_function or some other hook is more reliable if you really want to spend the time to rehash in every line.
In any case, the problem of not picking up new completion files remains.
Back to top
View user's profile Send private message
_______0
Guru
Guru


Joined: 15 Oct 2012
Posts: 521

PostPosted: Sun Jan 13, 2013 6:41 pm    Post subject: Reply with quote

ha, this is just a hack. And not very elegant as it's wasting cpu cycles on every return to achieve something that only needs upon new packages installed. I am not installing packages every return line.

So how does bash know about ALL new installed packages with virtually an EMPTY .bashrc and zsh needs this ugly hack?

Odd, is zsh threading? when I do:

Code:
while> do
while> rehash
while> done


only one core is stressed up to 100% usage. Or is the problem in while? while could use more cores.

ls which does more than rehash stresses less the cpu.

Code:
while
do
ls
done


By the way, the above command don't be showing neither while nor ls commands/processes in htop oO. wussup wit dat??
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Sun Jan 13, 2013 8:11 pm    Post subject: Reply with quote

_______0 wrote:
it's wasting cpu cycles on every return

No, only when you complete a command (not even when you complete arguments of a command).
Quote:
So how does bash know about ALL new installed packages

It does not. Maybe we speak about something different: I talked about a new file appearing in $PATH which is not found if you call it without a pathname: First, the shell must realize that something new is in $PATH. This is not different for bash.
Quote:
while could use more cores.

No, it cannot. The purpose of while is to execute sequentially.
Quote:
ls which does more than rehash stresses less the cpu.

It causes that zsh uses less cpu, because it calls the external program "ls", generates output etc.
Quote:
By the way, the above command don't be showing neither while nor ls commands/processes in htop

For while and rehash this is clear since zsh need not start a new process for them (and if zsh does start a new process, it is normally called "zsh"). For ls this is probably because the program lives too short. Try "sleep 1" instead.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum