purcell / exec-path-from-shell

Make Emacs use the $PATH set up by the user's shell
Other
1.41k stars 81 forks source link

exec-path-from-shell-initialize invoke ~/.zprofile #89

Closed mgcyung closed 5 years ago

mgcyung commented 5 years ago

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.

purcell commented 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.

mgcyung commented 5 years ago

@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?

purcell commented 5 years ago

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.

mgcyung commented 5 years ago

@purcell Thanks for explanation. if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then exec startx; fi works for me.