9

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'
    x`"
fi

Which seems... horrifying. Any better approaches?

james.haggerty
  • 211
  • 1
  • 3
  • I gather that `es` is not your login shell. What about setting `alias es='es -l'` in `.bashrc`? – cjm Aug 22 '12 at 08: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. – james.haggerty Aug 22 '12 at 08:43
  • I use `bash`, not `es`. But when I open a new terminal window, it runs `bash` as a login shell. – cjm Aug 22 '12 at 09: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. – james.haggerty Aug 22 '12 at 09: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? – james.haggerty Aug 23 '12 at 00:10

1 Answers1

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). – james.haggerty Aug 23 '12 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. ^_~ – Sardathrion - against SE abuse Aug 23 '12 at 10:17