Menu

#701 lxterminal cannot open login shells in new tabs.

None
closed
nobody
lxterminal (81)
5
2015-06-21
2014-10-30
No

Due to a bug in "lxterminal -l" the only way to make lxterminal start a /bin/bash login shell is to run "lxterminal -e 'bash -il'".

This works for the first tab opened, but the '-e' command is not run for new tabs, so the shell in those tabs will not be login shells (and thus will not have path changes from ~/.bash_profile etc).

There doesn't seem to be a way to make lxterminal always start login bash shells in every tab.

Can we make '-e' apply for every tab opened in that lxterminal window? If that is too surprising, can we add a config option to .config/lxterminal/lxterminal.conf to set a default command to run when the '-e' option is not used (ie when not provided or when opening new tabs)?

I don't fully understand why shells started by xterms are not login shells by default. The recommended practice with shells are to put things like PATH=foo:$PATH additions in ~/.profile or ~/.bash_profile which are only invoked in login shells to avoid them being re-executed in every sub-shell. In an X environment there is no parent login shell that will have done this for you, so the recommended practice for xterm's is to make them spawn login shells. Is there a better practice than this?

Discussion

  • Donovan Baarda

    Donovan Baarda - 2014-10-30

    For the record, I'm currently using the following nasty hacks to workaround this problem.

    In .profile (only read by /bin/sh login shells since I have .bash_profile);

    # for login /bin/sh shells, run bash instead.
    shopt -q login_shell && exec bash -il
    

    At the end of .bash_profile (only ready by /bin/bash for login shells);

    export PROFILE_DONE=1
    if [ -f ~/.bashrc ]; then
        source ~/.bashrc
    fi
    

    At the top of .bashrc (read by /bin/bash for all shells);

    # If running interactively, then...
    if [ "$PS1" ]; then
      # If .bash_profile has not been sourced exec a bash login shell instead.
      [ -v PROFILE_DONE ] || exec bash -il "$@"
    :
    
     
  • FinboySlick

    FinboySlick - 2015-03-30

    How about an option (-L would make sense) that would make the window spawn login shell (same as -l) but would also make all subsequent tabs (for that window) a login shell as well?

     

    Last edit: FinboySlick 2015-03-30
  • Donovan Baarda

    Donovan Baarda - 2015-04-01

    Is there any reason why -l should not apply to tabs as well? What about some way to specify a command for all tabs too? Dunno.

    In things like gnome-terminal these kinds of differences are handled by having profiles, and you can pick a profile when you start a new tab or terminal. I dunno if lxterminal needs that, but if it was cheap&easy (ie, not too much bloat) then it might be nice.

    If we assume lxterminal doesn't support "profiles", then I think it would make sense to behave like all tabs have the "same profile", which means things like -e and -l should apply to all tabs in the same lxterminal.

     
  • FinboySlick

    FinboySlick - 2015-06-21

    Fixed in git. -l/--loginshell now applies to all tabs created by the the terminal window.

     
  • FinboySlick

    FinboySlick - 2015-06-21
    • status: open --> closed
    • Group: -->
     

Log in to post a comment.