mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-11 00:39:08 +08:00
Enable the '/single' switch by using the registry as statemachine for the current location ('CMDER_START')
Fixed issue #577
This commit is contained in:
parent
5e07567a72
commit
a57c11e171
@ -139,7 +139,20 @@ void StartCmder(std::wstring path, bool is_single_mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
||||||
SetEnvironmentVariable(L"CMDER_START", path.c_str());
|
//SetEnvironmentVariable(L"CMDER_START", path.c_str());
|
||||||
|
|
||||||
|
// Send out the Settings Changed message - Once using ANSII...
|
||||||
|
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
|
||||||
|
|
||||||
|
// ...and once using UniCode (because Windows 8 likes it that way).
|
||||||
|
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) L"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
|
||||||
|
|
||||||
|
HKEY cmderStartRegistryKey;
|
||||||
|
if (RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\cmder", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &cmderStartRegistryKey, 0) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
RegSetValueEx(cmderStartRegistryKey, L"CMDER_START", 0, REG_SZ, (const BYTE*) path.c_str(), path.size() * 2);
|
||||||
|
RegCloseKey(cmderStartRegistryKey);
|
||||||
|
}
|
||||||
|
|
||||||
STARTUPINFO si = { 0 };
|
STARTUPINFO si = { 0 };
|
||||||
si.cb = sizeof(STARTUPINFO);
|
si.cb = sizeof(STARTUPINFO);
|
||||||
|
23
vendor/profile.ps1
vendored
23
vendor/profile.ps1
vendored
@ -61,10 +61,25 @@ if ($gitStatus) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Move to the wanted location
|
# Move to the wanted location
|
||||||
if (Test-Path Env:\CMDER_START) {
|
$cmderStartKey = 'HKCU:\Software\cmder'
|
||||||
Set-Location -Path $Env:CMDER_START
|
$cmderStartSubKey = 'CMDER_START'
|
||||||
} elseif ($Env:CMDER_ROOT -and $Env:CMDER_ROOT.StartsWith($pwd)) {
|
|
||||||
Set-Location -Path $Env:USERPROFILE
|
$cmderStart = (Get-Item -Path $cmderStartKey).GetValue($cmderStartSubKey)
|
||||||
|
if ( $cmderStart ) {
|
||||||
|
$cmderStart = ($cmderStart).Trim('"').Trim("'")
|
||||||
|
if ( $cmderStart.EndsWith(':') ) {
|
||||||
|
$cmderStart += '\'
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( Get-Item $cmderStart -Force ) -is [System.IO.FileInfo] ) {
|
||||||
|
$cmderStart = Split-Path $cmderStart
|
||||||
|
}
|
||||||
|
|
||||||
|
Set-Location -Path "${cmderStart}"
|
||||||
|
|
||||||
|
Set-ItemProperty -Path $cmderStartKey -Name $cmderStartSubKey -Value $null
|
||||||
|
} else {
|
||||||
|
Set-Location -Path "${env:HOME}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Enhance Path
|
# Enhance Path
|
||||||
|
Loading…
Reference in New Issue
Block a user