What does "Login shell" do?
"Login shell" runs the usual shell (zsh or bash) in login mode, in which the shell processes additional configuration files – such as .zlogin
or .bash_profile
. Chances are that those files have too many unnecessary commands – try to keep them as lightweight as possible.
You can try running zsh -l
and comparing it with regular zsh
. (While -l
is not a standard "login mode" switch, it's pretty common.)
(Though IMHO, it is a bit odd for a terminal app to even run shells in "login mode" at all… It sort of defeats the whole idea of being able to configure different startup commands.)
Related videos on Youtube
![xhg](https://i.stack.imgur.com/54TDP.png?s=256&g=1)
Comments
-
xhg almost 2 years
Recently I experience slow terminal launch time, so I looked into it and found an interesting thing. I am using iTerm on MacBook. There is an option choosing the default behavior:
If I chose "Login shell", it will prompt
Last login: Fri Mar 24 17:27:28 on ttys007
(left side below); if I chose "zsh", it won't prompt anything and launch time is very fast (right side below).The default shell I use is
zsh
, I wonder what's happening inside "login shell" and why it is so slow compared to purezsh
. -
xhg over 7 yearsI think your answer helped me out of my problem. There is one line
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
which after I commented out "login shell" became incredibly fast. Thanks dude -
user1686 over 7 yearsYeah, rvm was horribly slow the last time I tried it as well. But in general, anything that defines functions ought to go to the main config file –
.zshrc
or.bashrc
– not to the "login" one. -
xhg over 7 yearsthx for your advice. I cannot remember why it is there