Closed mgcyung closed 5 years ago
exec-path-from-shell-initialize
runs a shell, often a login or interactive shell depending on exec-path-from-shell-arguments
. By design, you can have multiple interactive shells running at the same time, so if you've put things in your shell startup files that have system-wide effects, like startx
, then you should remove them.
@purcell ~/.zprofile runs in a login shell and the login shell invokes startx to init X windows. If startx should not be in ~/.zprofile, is there another script it can be in?
Not every login shell is a shell in which you want to run startx
: imagine you log on one of the console VTs, for example, or connect into your machine via ssh
.
Usually you would either run a desktop manager via systemd or similar, or you would call exec startx
from a console manually.
To do it automatically via your login shell anyway, you can apparently do this -- note the test for $DISPLAY
, so that startx
does not get run when there is already an X display.
@purcell Thanks for explanation.
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then exec startx; fi
works for me.
It seems exec-path-from-shell-initialize invoke ~/.zprofile in which I run startx. It makes a new X is started and all the windows are gone.