diff --git a/app/main.cpp b/app/main.cpp
index c648430..a5893b3 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -31,18 +31,27 @@ int main(int argc, char *argv[])
QStringList args = app.arguments();
if (args.contains("-h") || args.contains("--help")) {
qDebug() << "Usage: " + args.at(0) + " [--default-settings] [--workdir
] [--program ] [-p|--profile ] [--fullscreen] [-h|--help]";
- qDebug() << " --default-settings Run cool-retro-term with the default settings";
- qDebug() << " --workdir Change working directory to 'dir'";
- qDebug() << " --program Run the 'prog' in the new terminal.";
- qDebug() << " --fullscreen Run cool-retro-term in fullscreen.";
- qDebug() << " -p|--profile Run cool-retro-term with the given profile.";
- qDebug() << " -h|--help Print this help.";
- qDebug() << " --verbose Print additional informations such as profiles and settings.";
+ qDebug() << " --default-settings Run cool-retro-term with the default settings";
+ qDebug() << " --workdir Change working directory to 'dir'";
+ qDebug() << " -e Command to execute. This option will catch all following arguments, so use it as the last option.";
+ qDebug() << " --fullscreen Run cool-retro-term in fullscreen.";
+ qDebug() << " -p|--profile Run cool-retro-term with the given profile.";
+ qDebug() << " -h|--help Print this help.";
+ qDebug() << " --verbose Print additional informations such as profiles and settings.";
return 0;
}
+ // Manage default command
+ QStringList cmdList;
+ if (args.contains("-e")) {
+ cmdList << args.mid(args.indexOf("-e") + 1);
+ }
+ QVariant command(cmdList.empty() ? QVariant() : cmdList[0]);
+ QVariant commandArgs(cmdList.size() <= 1 ? QVariant() : QVariant(cmdList.mid(1)));
+ engine.rootContext()->setContextProperty("defaultCmd", command);
+ engine.rootContext()->setContextProperty("defaultCmdArgs", commandArgs);
+
engine.rootContext()->setContextProperty("workdir", getNamedArgument(args, "--workdir", "$HOME"));
- engine.rootContext()->setContextProperty("shellProgram", getNamedArgument(args, "--program"));
// Manage import paths for Linux and OSX.
QStringList importPathList = engine.importPathList();
diff --git a/app/qml/PreprocessedTerminal.qml b/app/qml/PreprocessedTerminal.qml
index 0e9c361..911b93e 100644
--- a/app/qml/PreprocessedTerminal.qml
+++ b/app/qml/PreprocessedTerminal.qml
@@ -129,9 +129,10 @@ Item{
appSettings.terminalFontChanged.connect(handleFontChange);
// Retrieve the variable set in main.cpp if arguments are passed.
- if (shellProgram) {
- ksession.setShellProgram(shellProgram);
- } else if (!shellProgram && Qt.platform.os === "osx") {
+ if (defaultCmd) {
+ ksession.setShellProgram(defaultCmd);
+ ksession.setArgs(defaultCmdArgs);
+ } else if (!defaultCmd && Qt.platform.os === "osx") {
// OSX Requires the following default parameters for auto login.
ksession.setArgs(["-i", "-l"]);
}