mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-10 16:29: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)
|
||||
{
|
||||
// no commandline argument...
|
||||
pair = optpair(L"/START", L"");
|
||||
}
|
||||
else if (argc == 2 && argv[1][0] != L'/')
|
||||
{
|
||||
// only a single argument: this should be a path...
|
||||
pair = optpair(L"/START", argv[1]);
|
||||
}
|
||||
else
|
||||
@ -152,7 +154,10 @@ void StartCmder(std::wstring path, bool is_single_mode)
|
||||
}
|
||||
|
||||
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...
|
||||
//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).
|
||||
//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 };
|
||||
si.cb = sizeof(STARTUPINFO);
|
||||
#if USE_TASKBAR_API
|
||||
|
6
vendor/init.bat
vendored
6
vendor/init.bat
vendored
@ -76,12 +76,10 @@
|
||||
:: Set home path
|
||||
@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 (
|
||||
@cd /d "%CMDER_START%"
|
||||
) else (
|
||||
@if "%CD%\" == "%CMDER_ROOT%\" (
|
||||
@cd /d "%HOME%"
|
||||
)
|
||||
)
|
||||
|
||||
@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
|
||||
$cmderStartKey = 'HKCU:\Software\cmder'
|
||||
$cmderStartSubKey = 'CMDER_START'
|
||||
|
||||
$cmderStart = (Get-Item -Path $cmderStartKey -ErrorAction SilentlyContinue)
|
||||
|
||||
if ( $cmderStart ) {
|
||||
$cmderStart = $cmderStart.GetValue($cmderStartSubKey)
|
||||
$cmderStart = ($cmderStart).Trim('"').Trim("'")
|
||||
if ( $cmderStart.EndsWith(':') ) {
|
||||
$cmderStart += '\'
|
||||
# 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 ( $ENV:CMDER_START ) {
|
||||
Set-Location -Path "$ENV:CMDER_START"
|
||||
}
|
||||
|
||||
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
|
||||
$env:Path = "$Env:CMDER_ROOT\bin;$env:Path;$Env:CMDER_ROOT"
|
||||
|
||||
|
||||
$CmderUserProfilePath = Join-Path $env:CMDER_ROOT "config\user-profile.ps1"
|
||||
if(Test-Path $CmderUserProfilePath) {
|
||||
# Create this file and place your own command in there.
|
||||
|
Loading…
Reference in New Issue
Block a user