Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add /x "CONEMU ARGS" command line argument. #2096

Merged
merged 2 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

* Question issue: [#2094](https://github.com/cmderdev/cmder/issues/2094)
* Pull Request : [#2096](https://github.com/cmderdev/cmder/pull/2096)
* New argument created to ConEmu forwarding arguments.
* Syntax: `/x [ConEmu extras arguments]`
* e.g.: `Cmder.exe /x "-min -tsa"`

### Fixes

* Pull Request: [#2002](https://github.com/cmderdev/cmder/pull/2002)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The Cmder's user interface is also designed to be more eye pleasing, and you can
| `/SINGLE` | Start Cmder in single mode. |
| `/START [start_path]` | Folder path to start in. |
| `/TASK [task_name]` | Task to start after launch. |
| `/X [ConEmu extras pars]` | Forwads parameters to ConEmu |

## Context Menu Integration

Expand Down
21 changes: 17 additions & 4 deletions launcher/src/CmderLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bool FileExists(const wchar_t * filePath)
return false;
}

void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstring taskName = L"", std::wstring cfgRoot = L"", bool use_user_cfg = true)
void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstring taskName = L"", std::wstring cfgRoot = L"", bool use_user_cfg = true, std::wstring conemu_args = L"")
{
#if USE_TASKBAR_API
wchar_t appId[MAX_PATH] = { 0 };
Expand All @@ -98,6 +98,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr

std::wstring cmderStart = path;
std::wstring cmderTask = taskName;
std::wstring cmderConEmuArgs = conemu_args;

std::copy(cfgRoot.begin(), cfgRoot.end(), userConfigDirPath);
userConfigDirPath[cfgRoot.length()] = 0;
Expand Down Expand Up @@ -391,6 +392,11 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
swprintf_s(args, L"%s -loadcfgfile \"%s\"", args, userConEmuCfgPath);
}

if (!streqi(cmderConEmuArgs.c_str(), L""))
{
swprintf_s(args, L"%s %s", args, cmderConEmuArgs.c_str());
}

SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
if (wcscmp(userConfigDirPath, configDirPath) != 0)
{
Expand Down Expand Up @@ -527,6 +533,7 @@ struct cmderOptions
std::wstring cmderStart = L"";
std::wstring cmderTask = L"";
std::wstring cmderRegScope = L"USER";
std::wstring cmderConEmuArgs = L"";
bool cmderSingle = false;
bool cmderUserCfg = true;
bool registerApp = false;
Expand Down Expand Up @@ -620,6 +627,12 @@ cmderOptions GetOption()
}
}
}
/* Used for passing arguments to conemu prog */
else if (_wcsicmp(L"/x", szArgList[i]) == 0)
{
cmderOptions.cmderConEmuArgs = szArgList[i + 1];
i++;
}
else if (cmderOptions.cmderStart == L"")
{
int len = wcslen(szArgList[i]);
Expand All @@ -635,13 +648,13 @@ cmderOptions GetOption()
}
else
{
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\n /m\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\n /m\n\n /x [ConEmu extra arguments]\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
cmderOptions.error = true;
}
}
else
{
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\n /m\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\n /m\n\n /x [ConEmu extra arguments]\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
cmderOptions.error = true;
}
}
Expand Down Expand Up @@ -683,7 +696,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
}
else
{
StartCmder(cmderOptions.cmderStart, cmderOptions.cmderSingle, cmderOptions.cmderTask, cmderOptions.cmderCfgRoot, cmderOptions.cmderUserCfg);
StartCmder(cmderOptions.cmderStart, cmderOptions.cmderSingle, cmderOptions.cmderTask, cmderOptions.cmderCfgRoot, cmderOptions.cmderUserCfg, cmderOptions.cmderConEmuArgs);
}

return 0;
Expand Down