qterminal
qterminal copied to clipboard
Option to start shell as login shell
I haven't found a way to start bash as login shell other than invoking qterminal with 'qterminal -e "bash --login"'. It would be much more convenient if that could be a configurable option in qterminal instead.
That's not really qterminal's job is it? Just use chsh to change your default shell...
The term login shell is very ambiguous unfortunately. This is an excellent article that explains the whats and whys that I am looking for: http://www.slackwiki.com/Login_Shell
All the terminal emulators I know have an option to start the shell as login shell. /bin/login does it by prepending a - to the shell name and the shell looks for that character when it is started.
Most newer terminal emulators I know have some kind of preference setting where you enable or disable starting the shell as login shell. Older terminal emulators often take the "-ls" command line parameter. A preference setting is more convenient. A command line parameter on the other hand allows to choose the behavior for each terminal instance individually.
Thanks @ritzmann this "fix" works for me. :smile:
Hi there, I'm a bit late, but stumbled across this issue today, too. Is there a way to configure qterminal such that it'll run bash as a login shell? I wasn't able to do so.
I need that to complete my RVM setup, as described in https://rvm.io/integration/gnome-terminal
@datenimperator Currently a login shell is not implemented yet. You may want to add a line source /etc/profile in your ~/.bashrc.
@yan12125 can we implement an option to start shells as login shell - to be honest, i'm selfish, i would like this option too :)
Why not :) Just that this feature seems to require lots of time on survey behaviors of different shells, so it may take some time.
I'm a new user and liking qterminal. I resolved this on my system by editing MainWindow::newTerminalWindow() in src/mainwindow.cpp, replacing:
MainWindow *w = new MainWindow(cfg, false);
w->show();
to this:
QString command = QStringLiteral("qterminal");
QStringList args = {QStringLiteral("-e"), QStringLiteral("bash --login")};
if (!QProcess::startDetached(command, args))
qDebug() << "Failed to start command" << command << args;
Thank you, for qterminal.
The following is my second attempt so that it honors the UseCWD config setting; i.e. Open new terminals in current working directory.
Original newTerminalWindow()
void MainWindow::newTerminalWindow()
{
TerminalConfig cfg;
TermWidgetHolder *ch = consoleTabulator->terminalHolder();
if (ch)
cfg.provideCurrentDirectory(ch->currentTerminal()->impl()->workingDirectory());
MainWindow *w = new MainWindow(cfg, false);
w->show();
}
Modified newTerminalWindow()
void MainWindow::newTerminalWindow()
{
TermWidgetHolder *ch = consoleTabulator->terminalHolder();
QString command = QStringLiteral("qterminal");
QStringList args;
if (ch && Properties::Instance()->useCWD)
args << QStringLiteral("-w") << ch->currentTerminal()->impl()->workingDirectory();
args << QStringLiteral("-e") << QStringLiteral("bash --login");
if (!QProcess::startDetached(command, args))
qDebug() << "Failed to start command" << command << args;
}
For new tabs to work similarly, I set SHELL in ~/.bashrc with the --login argument. Code is currently there in termwidget.cpp to extract any arguments from the SHELL environment variable from what I can tell and pass on to shell.
export SHELL="/bin/bash --login"
Log out and back in. New windows and tabs including split horizontally and vertically behave the same with regards to calling bash with --login. Note that bash is hard-coded in the code above and may not be the user's desired shell.
As an example of how this could be annoying, Ubuntu's set up by default to add $HOME/bin and $/.local/bin to the $PATH in $HME/.profile when such folders exist. However, that file is sourced only for login shells.
As a workaround in Linux, you can set the $SHELL environment variable to any command like this:
SHELL="bash -l" qterminal
and it will be opened as a shell in every new tab.
Since I use qterminal.desktop to launch it, I create another file with the same name in ~/.local/share/applications and change the line Exec=... with Exec=qterminal -e "bash".