Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
+1 for using rc/es! –  Sardathrion Aug 22 '12 at 6:40
    
I gather that es is not your login shell. What about setting alias es='es -l' in .bashrc? –  cjm Aug 22 '12 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. –  james.haggerty Aug 22 '12 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 '12 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. –  james.haggerty Aug 22 '12 at 9:34

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?

share|improve this answer
    
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 Aug 23 '12 at 10:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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