2

My zshrc is filled with export statements like this and as a result the export time becomes a bit long

zsh -i -c exit 0.82s user 0.44s system 105% cpu 1.196 total

whereas it's quite fast if i exlude the export statements

zsh -i -c exit 0.11s user 0.02s system 101% cpu 0.125 total

is there any way to reduce the time without excluding the export statements ?

export PATH=$PATH:/home/{{user}}/.gem/ruby/2.7.0/bin
export PATH=$PATH:~/.yarn/bin
export PATH=$PATH:/run/media/{{user}}/others/Programs/flutter/bin
export PATH=$PATH:/opt/proverif2.01
export PATH=$PATH:/opt/lampp
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

# opam configuration
test -r /home/{{user}}/.opam/opam-init/init.zsh && . /home/{{user}}/.opam/opam-init/init.zsh > /dev/null 2> /dev/null || true
  • 2
    I doubt it's the `export`s that are to blame for any slowdown; more likely one or more of the scripts that are being sourced. (Why are you trying to load a file named **bash** \_completion in **zsh** anyways?) – Shawn Jul 12 '20 at 09:35
  • 1
    You could combine those into one single export that adds all the additional directories to the path all at once, though. – Shawn Jul 12 '20 at 09:37
  • Tthe `bash completion` was for the node version manager. It was added to the zsh rc file by defalult. I followed [this](https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix/14638025#14638025) which solved my problem. – Nostradamus Jul 12 '20 at 20:39
  • Back to : `zsh -i -c exit 0.11s user 0.02s system 101% cpu 0.130 total` now. Thanks. – Nostradamus Jul 12 '20 at 20:40
  • @Nostradamus : I wouldn't set the PATH like this anyway. Every time you create a new interactive zsh child process, the PATH gets extended and extended again by the same directories. I also don't trust nvm.sh etc. whether they protect against repeated invocation. You should at least check them. – user1934428 Jul 13 '20 at 11:42
  • Hi @user1934428, i tried creating multiple interactive terminals and also multiple zsh child processes, then saved the contents `$PATH` variable to a file and then checked it with the contents of the file when there is only a single zsh process running. however i found no differences between the two. Is there any way i could check if the error you pointed out exists in my system ? – Nostradamus Jul 14 '20 at 12:11
  • What's the point in comparing the contents of the file????? What you should do is looking at the PATH before executing gcc, and verify that it is correct. You need just your eyes, not some comparision tool. – user1934428 Jul 14 '20 at 14:18
  • That's the first thing i did. I didn't think i would need to say that as well.i did that already, yeah. – Nostradamus Jul 15 '20 at 06:27

0 Answers0