mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-11 00:39:08 +08:00
Merge pull request #798 from JanSchulz/cmder_here
Make "cmder here" work again
This commit is contained in:
commit
5b7c008202
@ -63,10 +63,12 @@ optpair GetOption()
|
|||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
|
// no commandline argument...
|
||||||
pair = optpair(L"/START", L"");
|
pair = optpair(L"/START", L"");
|
||||||
}
|
}
|
||||||
else if (argc == 2 && argv[1][0] != L'/')
|
else if (argc == 2 && argv[1][0] != L'/')
|
||||||
{
|
{
|
||||||
|
// only a single argument: this should be a path...
|
||||||
pair = optpair(L"/START", argv[1]);
|
pair = optpair(L"/START", argv[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -152,7 +154,10 @@ 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());
|
if (!streqi(path.c_str(), L""))
|
||||||
|
{
|
||||||
|
SetEnvironmentVariable(L"CMDER_START", path.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// Send out the Settings Changed message - Once using ANSII...
|
// Send out the Settings Changed message - Once using ANSII...
|
||||||
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
|
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
|
||||||
@ -160,13 +165,6 @@ void StartCmder(std::wstring path, bool is_single_mode)
|
|||||||
// ...and once using UniCode (because Windows 8 likes it that way).
|
// ...and once using UniCode (because Windows 8 likes it that way).
|
||||||
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) L"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
|
//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);
|
||||||
#if USE_TASKBAR_API
|
#if USE_TASKBAR_API
|
||||||
|
6
vendor/init.bat
vendored
6
vendor/init.bat
vendored
@ -76,12 +76,10 @@
|
|||||||
:: Set home path
|
:: Set home path
|
||||||
@if not defined HOME set HOME=%USERPROFILE%
|
@if not defined HOME set HOME=%USERPROFILE%
|
||||||
|
|
||||||
|
:: This is either a env variable set by the user or the result of
|
||||||
|
:: cmder.exe setting this variable due to a commandline argument or a "cmder here"
|
||||||
@if defined CMDER_START (
|
@if defined CMDER_START (
|
||||||
@cd /d "%CMDER_START%"
|
@cd /d "%CMDER_START%"
|
||||||
) else (
|
|
||||||
@if "%CD%\" == "%CMDER_ROOT%\" (
|
|
||||||
@cd /d "%HOME%"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@if exist "%CMDER_ROOT%\config\user-profile.cmd" (
|
@if exist "%CMDER_ROOT%\config\user-profile.cmd" (
|
||||||
|
27
vendor/profile.ps1
vendored
27
vendor/profile.ps1
vendored
@ -82,34 +82,15 @@ if ($gitStatus) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Move to the wanted location
|
# Move to the wanted location
|
||||||
$cmderStartKey = 'HKCU:\Software\cmder'
|
# This is either a env variable set by the user or the result of
|
||||||
$cmderStartSubKey = 'CMDER_START'
|
# cmder.exe setting this variable due to a commandline argument or a "cmder here"
|
||||||
|
if ( $ENV:CMDER_START ) {
|
||||||
$cmderStart = (Get-Item -Path $cmderStartKey -ErrorAction SilentlyContinue)
|
Set-Location -Path "$ENV:CMDER_START"
|
||||||
|
|
||||||
if ( $cmderStart ) {
|
|
||||||
$cmderStart = $cmderStart.GetValue($cmderStartSubKey)
|
|
||||||
$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
|
||||||
$env:Path = "$Env:CMDER_ROOT\bin;$env:Path;$Env:CMDER_ROOT"
|
$env:Path = "$Env:CMDER_ROOT\bin;$env:Path;$Env:CMDER_ROOT"
|
||||||
|
|
||||||
|
|
||||||
$CmderUserProfilePath = Join-Path $env:CMDER_ROOT "config\user-profile.ps1"
|
$CmderUserProfilePath = Join-Path $env:CMDER_ROOT "config\user-profile.ps1"
|
||||||
if(Test-Path $CmderUserProfilePath) {
|
if(Test-Path $CmderUserProfilePath) {
|
||||||
# Create this file and place your own command in there.
|
# Create this file and place your own command in there.
|
||||||
|
Loading…
Reference in New Issue
Block a user