I've been playing with es the last couple of days, and it (like rc) has the quirk/feature that it only runs its startup script (.esrc) on login. The usual way to run code in each interactive session is to put that code in the %prompt function.

Of course, there's no %prompt function if es -l has never been run.

So, the question: how do you set the login environment when you come in via gdm or similar, which only source .profile (or .xprofile, .xsession, etc.)? The best I've come up with is:

if [ -f "$HOME/.esrc" ]; then
    eval "`es -l <<-x
        sh <<<'export -p'

Which seems... horrifying. Any better approaches?

  • I gather that es is not your login shell. What about setting alias es='es -l' in .bashrc?
    – cjm
    Aug 22, 2012 at 8:39
  • es is my login shell. Sorry if I didn't make that clear. But login shells aren't run in X sessions before terminals are launched, at least as far as I know. Aug 22, 2012 at 8:43
  • I use bash, not es. But when I open a new terminal window, it runs bash as a login shell.
    – cjm
    Aug 22, 2012 at 9:32
  • At least with most X terminals, this is an option that is disabled by default (as it should be, IMO). So yes, it is a workaround, but there's no reason this stuff should be run multiple times when it could be run once. Aug 22, 2012 at 9:34
  • Hmm, not sure I agree with your edit, Gilles. Why do you think this only applies to es? (and not *csh or rc or ...?) And why remove gdm and lightdm, since they're the ones that control the environment? Aug 23, 2012 at 0:10

1 Answer 1


Since no one has a real answer, here's my horrible hack. Some shells (*rxvt for example) have settings that allow to force a login shell. So, in your .Xdefaults, you can add something akin to

urxvt256c-ml:loginShell: true

Which means that all urxvt256c-ml terminal you launch will have a login shell by default.

Does that help at all?

  • Well, being an annoying person (see comments above?), I'll say I already knew about this. It's a toss-up whether this or my slightly disturbing code is a better option; one lacks conceptual elegance (I'm claiming that I log in for every terminal, when I create 100s over a single real login?), the other lacks implementation elegance (but I really feel the environment should be set up on login). Aug 23, 2012 at 10:14
  • Ah, I see what you mean now. Personally, I consider a terminal to be a the unit of login not the X11 environment so it makes sense to me to be logged in three times if I have three terminals open. I'll leave the answer here just in case it is useful for others -- let's see how many down votes is attracts. ^_~ Aug 23, 2012 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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