Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sometimes my shell (zsh) takes longer to start than usual (I open the terminal, and it hangs a bit until I can input commands).

I have a few aliases on my .zshrc (well, actually they're in a different file that .zshrc does a source on).

If you make an alias with the shell open, it remains valid only through the current session, so I started to wonder if all this source and alias actually harm the shell's startup performance (I'm assuming it has to go through a lengthy process of running all those commands on start).

If that does happen, wouldn't it just be more effective to have those aliases as shell scripts and put them somewhere in my PATH?

share|improve this question
    
I'm fairly sure aliases don't significantly contribute to shell startup times. Initializing modules such as completion, or sourcing other files such as oh-my-zsh might have a much higher impact. Have you done some experiments on how your performance is when you disable the aliases? –  slhck Jan 29 '13 at 21:10
    
I'd rather suspect an illegal amount of completions. Show the output of set | wc. Or some dns lookup may happen. –  ott-- Jan 29 '13 at 21:19

2 Answers 2

up vote 4 down vote accepted

It's unlikely that having a few extra alias definitions in your startup files are responsible for noticeable startup delays. Even if you had so many it actually mattered, the delay wouldn't be sporadic, it'd be the same every time.

What's more likely is that something along the way in your startup sequence is waiting for the network. An example would be a path directory that's on a network drive that isn't ready or perhaps isn't powered up at all. Network timeouts are often many seconds.

share|improve this answer

Perhaps you are NOT doing a 'dump' of your completion system when calling compinit? (that could slow down zsh at start up...). If you are using compinit, make sure you are just calling

autoload -U compinit
compinit

(without any funny options for compinit, specifically without -D).

After using that, the first time you start a shell it will be slow (as it will generate the dump, but the next ones will not).

Other thoughts, perhaps your system messes with the completion functions, and a new dump is forcefully generated each time? Try setting compinit in your .zshrc with -C (after generating the dump at least once).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.