diff options
author | Cristian Adam <[email protected]> | 2023-04-19 20:00:04 +0200 |
---|---|---|
committer | Cristian Adam <[email protected]> | 2023-04-25 09:23:22 +0000 |
commit | dad415b884b17df7e54e077c3fc5202237278dba (patch) | |
tree | 5df7f5ff995e50d586147e26222acb1866994cc7 /src/plugins/terminal/shellintegration.cpp | |
parent | 411b2e05b8ac4442d1ef179381dc7c37492ab37b (diff) |
Terminal: add cmd shell integration when using clink
The script was provided at https://github.com/chrisant996/clink/discussions/453
If clink is not installed cmd will not have any issues, since only
the environment variable CLINK_PATH will be set.
Change-Id: I9f1d16933ae6bbcb3da1243e8704af6dc86b9a4d
Reviewed-by: Cristian Adam <[email protected]>
Reviewed-by: <[email protected]>
Diffstat (limited to 'src/plugins/terminal/shellintegration.cpp')
-rw-r--r-- | src/plugins/terminal/shellintegration.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/plugins/terminal/shellintegration.cpp b/src/plugins/terminal/shellintegration.cpp index fd4c1364696..00f1b75cd69 100644 --- a/src/plugins/terminal/shellintegration.cpp +++ b/src/plugins/terminal/shellintegration.cpp @@ -41,6 +41,10 @@ struct { FilePath script{":/terminal/shellintegrations/shellintegration.ps1"}; } pwsh; + struct + { + FilePath script{":/terminal/shellintegrations/shellintegration-clink.lua"}; + } clink; } filesToCopy; // clang-format on @@ -64,6 +68,9 @@ bool ShellIntegration::canIntegrate(const Utils::CommandLine &cmdLine) return true; } + if (cmdLine.executable().baseName() == "cmd") + return true; + return false; } @@ -105,6 +112,7 @@ void ShellIntegration::prepareProcess(Utils::QtcProcess &process) return; env.set("VSCODE_INJECTION", "1"); + env.set("TERM_PROGRAM", "vscode"); if (cmd.executable().baseName() == "bash") { const FilePath rcPath = filesToCopy.bash.rcFile; @@ -134,6 +142,14 @@ void ShellIntegration::prepareProcess(Utils::QtcProcess &process) cmd.addArgs(QString("-noexit -command try { . \"%1\" } catch {}{1}").arg(tmpRc.nativePath()), CommandLine::Raw); + } else if (cmd.executable().baseName() == "cmd") { + const FilePath rcPath = filesToCopy.clink.script; + const FilePath tmpRc = FilePath::fromUserInput( + m_tempDir.filePath(filesToCopy.clink.script.fileName())); + rcPath.copyFile(tmpRc); + + env.set("CLINK_HISTORY_LABEL", "QtCreator"); + env.appendOrSet("CLINK_PATH", tmpRc.parentDir().nativePath(), ";"); } process.setCommand(cmd); |