From 2a4e9d8301794946d8a5d44c7b1edf43845b3893 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 6 Jan 2019 17:27:04 -0500 Subject: [PATCH 01/11] workaround vscode tasks showing cmder debug output --- vendor/init.bat | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vendor/init.bat b/vendor/init.bat index d670e84..b525daa 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -51,7 +51,9 @@ call "%cmder_root%\vendor\lib\lib_profile" ) else if /i "%1"=="/v" ( set verbose_output=1 ) else if /i "%1"=="/d" ( - set debug_output=1 + if not defined VSCODE_CWD ( + set debug_output=1 + ) ) else if /i "%1" == "/max_depth" ( if "%~2" geq "1" if "%~2" leq "5" ( set "max_depth=%~2" From 6d8f7a290abfef5d997357b313aa089719c6a81c Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 6 Jan 2019 17:46:50 -0500 Subject: [PATCH 02/11] ignore all args if running inside vscode --- vendor/init.bat | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index b525daa..fc6402d 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -41,6 +41,9 @@ call "%cmder_root%\vendor\lib\lib_console" call "%cmder_root%\vendor\lib\lib_git" call "%cmder_root%\vendor\lib\lib_profile" +if defined VSCODE_CWD ( + goto start +) :var_loop if "%~1" == "" ( goto :start @@ -51,9 +54,7 @@ call "%cmder_root%\vendor\lib\lib_profile" ) else if /i "%1"=="/v" ( set verbose_output=1 ) else if /i "%1"=="/d" ( - if not defined VSCODE_CWD ( - set debug_output=1 - ) + set debug_output=1 ) else if /i "%1" == "/max_depth" ( if "%~2" geq "1" if "%~2" leq "5" ( set "max_depth=%~2" From 760f4e579e3feaad76b4a77c08d7d7c54dd65a4f Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 6 Jan 2019 18:09:06 -0500 Subject: [PATCH 03/11] ignore all /d arg if running inside vscode --- vendor/init.bat | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index fc6402d..b525daa 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -41,9 +41,6 @@ call "%cmder_root%\vendor\lib\lib_console" call "%cmder_root%\vendor\lib\lib_git" call "%cmder_root%\vendor\lib\lib_profile" -if defined VSCODE_CWD ( - goto start -) :var_loop if "%~1" == "" ( goto :start @@ -54,7 +51,9 @@ if defined VSCODE_CWD ( ) else if /i "%1"=="/v" ( set verbose_output=1 ) else if /i "%1"=="/d" ( - set debug_output=1 + if not defined VSCODE_CWD ( + set debug_output=1 + ) ) else if /i "%1" == "/max_depth" ( if "%~2" geq "1" if "%~2" leq "5" ( set "max_depth=%~2" From 98a64b71b24d0c5bdde26c73ddbc95523bc2a359 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 16 Mar 2019 13:52:47 -0400 Subject: [PATCH 04/11] Allow full ps1 prompt customization by 'config/*.ps1' scripts --- vendor/profile.ps1 | 79 ++++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/vendor/profile.ps1 b/vendor/profile.ps1 index 73fde18..498bdc0 100644 --- a/vendor/profile.ps1 +++ b/vendor/profile.ps1 @@ -27,7 +27,7 @@ $ENV:CMDER_ROOT = (($ENV:CMDER_ROOT).trimend("\")) # do not load bundled psget if a module installer is already available # -> recent PowerShell versions include PowerShellGet out of the box -$moduleInstallerAvailable = [bool](Get-Command -Name 'Install-Module' -ErrorAction SilentlyContinue | Out-Null) +$moduleInstallerAvailable = [bool](Get-Command -Name 'Install-Module' -ErrorAction SilentlyContinue) # Add Cmder modules directory to the autoload path. $CmderModulePath = Join-path $PSScriptRoot "psmodules/" @@ -96,31 +96,6 @@ $env:Path = "$Env:CMDER_ROOT\bin;$Env:CMDER_ROOT\vendor\bin;$env:Path;$Env:CMDER # Users should modify their user_profile.ps1 as it will be safe from updates. # -# Pre assign the hooks so the first run of cmder gets a working prompt. -[ScriptBlock]$PrePrompt = {} -[ScriptBlock]$PostPrompt = {} -[ScriptBlock]$CmderPrompt = { - $Host.UI.RawUI.ForegroundColor = "White" - Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green - checkGit($pwd.ProviderPath) -} - -<# -This scriptblock runs every time the prompt is returned. -Explicitly use functions from MS namespace to protect from being overridden in the user session. -Custom prompt functions are loaded in as constants to get the same behaviour -#> -[ScriptBlock]$Prompt = { - $realLASTEXITCODE = $LASTEXITCODE - $host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf - PrePrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline - CmderPrompt - Microsoft.PowerShell.Utility\Write-Host "`nλ " -NoNewLine -ForegroundColor "DarkGray" - PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline - $global:LASTEXITCODE = $realLASTEXITCODE - return " " -} - # Drop *.ps1 files into "$ENV:CMDER_ROOT\config\profile.d" # to source them at startup. if (-not (test-path "$ENV:CMDER_ROOT\config\profile.d")) { @@ -154,7 +129,7 @@ if ($ENV:CMDER_USER_CONFIG -ne "" -and (test-path "$ENV:CMDER_USER_CONFIG\profil } popd } - + # Renaming to "config\user_profile.ps1" to "user_profile.ps1" for consistency. if (test-path "$env:CMDER_ROOT\config\user-profile.ps1") { rename-item "$env:CMDER_ROOT\config\user-profile.ps1" user_profile.ps1 @@ -185,11 +160,47 @@ if (! (Test-Path $CmderUserProfilePath) ) { Copy-Item "$env:CMDER_ROOT\vendor\user_profile.ps1.default" -Destination $CmderUserProfilePath } -# Once Created these code blocks cannot be overwritten -Set-Item -Path function:\PrePrompt -Value $PrePrompt -Options Constant -Set-Item -Path function:\CmderPrompt -Value $CmderPrompt -Options Constant -Set-Item -Path function:\PostPrompt -Value $PostPrompt -Options Constant +# Only set the prompt if it is currently set to the default +# This allows users to configure the prompt in their user_profile.ps1 or config\profile.d\*.ps1 +if ( $(get-command prompt).Definition -match 'PS \$\(\$executionContext.SessionState.Path.CurrentLocation\)\$\(' -and ` + $(get-command prompt).Definition -match '\(\$nestedPromptLevel \+ 1\)\) ";') { + # Pre assign the hooks so the first run of cmder gets a working prompt. + [ScriptBlock]$PrePrompt = {} + [ScriptBlock]$PostPrompt = {} + [ScriptBlock]$CmderPrompt = { + $Host.UI.RawUI.ForegroundColor = "White" + Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green + checkGit($pwd.ProviderPath) + } -# Functions can be made constant only at creation time -# ReadOnly at least requires `-force` to be overwritten -Set-Item -Path function:\prompt -Value $Prompt -Options ReadOnly + <# + This scriptblock runs every time the prompt is returned. + Explicitly use functions from MS namespace to protect from being overridden in the user session. + Custom prompt functions are loaded in as constants to get the same behaviour + #> + [ScriptBlock]$Prompt = { + $realLASTEXITCODE = $LASTEXITCODE + $host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf + PrePrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline + CmderPrompt + Microsoft.PowerShell.Utility\Write-Host "`nλ " -NoNewLine -ForegroundColor "DarkGray" + PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline + $global:LASTEXITCODE = $realLASTEXITCODE + return " " + } + + + # Once Created these code blocks cannot be overwritten + # if (-not $(get-command PrePrompt).Options -match 'Constant') {Set-Item -Path function:\PrePrompt -Value $PrePrompt -Options Constant} + # if (-not $(get-command CmderPrompt).Options -match 'Constant') {Set-Item -Path function:\CmderPrompt -Value $CmderPrompt -Options Constant} + # if (-not $(get-command PostPrompt).Options -match 'Constant') {Set-Item -Path function:\PostPrompt -Value $PostPrompt -Options Constant} + + Set-Item -Path function:\PrePrompt -Value $PrePrompt -Options Constant + Set-Item -Path function:\CmderPrompt -Value $CmderPrompt -Options Constant + Set-Item -Path function:\PostPrompt -Value $PostPrompt -Options Constant + + # Functions can be made constant only at creation time + # ReadOnly at least requires `-force` to be overwritten + # if (!$(get-command Prompt).Options -match 'ReadOnly') {Set-Item -Path function:\prompt -Value $Prompt -Options ReadOnly} + Set-Item -Path function:\prompt -Value $Prompt -Options ReadOnly +} From 8abfa9d4134a1ee0ff81eb9a2e8a8bfc209d6052 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 16 Mar 2019 19:15:36 -0400 Subject: [PATCH 05/11] add back shell context menu to drives on register unregister --- launcher/src/CmderLauncher.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index d9e17c9..e399a47 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -20,6 +20,8 @@ #define MB_TITLE L"Cmder Launcher" #define SHELL_MENU_REGISTRY_PATH_BACKGROUND L"Directory\\Background\\shell\\Cmder" #define SHELL_MENU_REGISTRY_PATH_LISTITEM L"Directory\\shell\\Cmder" +#define SHELL_MENU_REGISTRY_DRIVE_PATH_BACKGROUND L"Drive\\Background\\shell\\Cmder" +#define SHELL_MENU_REGISTRY_DRIVE_PATH_LISTITEM L"Drive\\shell\\Cmder" #define streqi(a, b) (_wcsicmp((a), (b)) == 0) @@ -665,11 +667,15 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, { RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); + RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_DRIVE_PATH_BACKGROUND, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); + RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_DRIVE_PATH_LISTITEM, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); } else if (cmderOptions.unRegisterApp == true) { UnregisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND); UnregisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM); + UnregisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_DRIVE_PATH_BACKGROUND); + UnregisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_DRIVE_PATH_LISTITEM); } else if (cmderOptions.error == true) { From a93fff6798ad5b4b7c4eda1d933cc8578cf24462 Mon Sep 17 00:00:00 2001 From: Dax T Games Date: Sun, 17 Mar 2019 15:09:02 -0400 Subject: [PATCH 06/11] Update init.bat --- vendor/init.bat | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index 20676f6..5cc29ab 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -51,9 +51,7 @@ call "%cmder_root%\vendor\lib\lib_profile" ) else if /i "%1"=="/v" ( set verbose_output=1 ) else if /i "%1"=="/d" ( - if not defined VSCODE_CWD ( - set debug_output=1 - ) + set debug_output=1 ) else if /i "%1" == "/max_depth" ( if "%~2" geq "1" if "%~2" leq "5" ( set "max_depth=%~2" From 081624d88e3bac96306451b1751b5c01c3c0cbde Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 23 Mar 2019 15:03:44 -0400 Subject: [PATCH 07/11] cleanup --- vendor/profile.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vendor/profile.ps1 b/vendor/profile.ps1 index 498bdc0..53b4e5a 100644 --- a/vendor/profile.ps1 +++ b/vendor/profile.ps1 @@ -25,7 +25,7 @@ if (! $ENV:CMDER_ROOT ) { # Remove trailing '\' $ENV:CMDER_ROOT = (($ENV:CMDER_ROOT).trimend("\")) -# do not load bundled psget if a module installer is already available +# Do not load bundled psget if a module installer is already available # -> recent PowerShell versions include PowerShellGet out of the box $moduleInstallerAvailable = [bool](Get-Command -Name 'Install-Module' -ErrorAction SilentlyContinue) @@ -91,11 +91,6 @@ if (Get-Module PSReadline -ErrorAction "SilentlyContinue") { # Enhance Path $env:Path = "$Env:CMDER_ROOT\bin;$Env:CMDER_ROOT\vendor\bin;$env:Path;$Env:CMDER_ROOT" -# -# Prompt Section -# Users should modify their user_profile.ps1 as it will be safe from updates. -# - # Drop *.ps1 files into "$ENV:CMDER_ROOT\config\profile.d" # to source them at startup. if (-not (test-path "$ENV:CMDER_ROOT\config\profile.d")) { @@ -160,6 +155,11 @@ if (! (Test-Path $CmderUserProfilePath) ) { Copy-Item "$env:CMDER_ROOT\vendor\user_profile.ps1.default" -Destination $CmderUserProfilePath } +# +# Prompt Section +# Users should modify their user_profile.ps1 as it will be safe from updates. +# + # Only set the prompt if it is currently set to the default # This allows users to configure the prompt in their user_profile.ps1 or config\profile.d\*.ps1 if ( $(get-command prompt).Definition -match 'PS \$\(\$executionContext.SessionState.Path.CurrentLocation\)\$\(' -and ` From 192c2f4dd102140144db656a739da1f36226659d Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 31 Mar 2019 09:47:50 -0400 Subject: [PATCH 08/11] fix git detection --- vendor/lib/lib_git.cmd | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vendor/lib/lib_git.cmd b/vendor/lib/lib_git.cmd index bfbcdb2..02f156b 100644 --- a/vendor/lib/lib_git.cmd +++ b/vendor/lib/lib_git.cmd @@ -88,8 +88,11 @@ exit /b ::: [SCOPE]_BUILD Scoped Build version. :::------------------------------------------------------------------------------- - setlocal enabledelayedexpansion :: process a `x.x.x.xxxx.x` formatted string + set "%~1_MAJOR=" + set "%~1_MINOR=" + set "%~1_PATCH=" + set "%~1_BUILD=" %lib_console% debug_output :parse_version "ARGV[1]=%~1, ARGV[2]=%~2" for /F "tokens=1-3* delims=.,-" %%A in ("%2") do ( set "%~1_MAJOR=%%A" @@ -98,7 +101,6 @@ exit /b set "%~1_BUILD=%%D" ) - endlocal & set "%~1_MAJOR=!%~1_MAJOR!" & set "%~1_MINOR=!%~1_MINOR!" & set "%~1_PATCH=!%~1_PATCH!" & set "%~1_BUILD=!%~1_BUILD!" exit /b :validate_version From b424012a08f4645d5c61423867e9dcc0b7276fd5 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 31 Mar 2019 09:48:58 -0400 Subject: [PATCH 09/11] make debug messages more verbose --- vendor/init.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index 20676f6..3907beb 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -235,7 +235,7 @@ for /F "delims=" %%F in ('where git.exe 2^>nul') do ( :VENDORED_GIT if exist "%CMDER_ROOT%\vendor\git-for-windows" ( set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows" - %lib_console% debug_output "Using vendored Git from '!GIT_INSTALL_ROOT!..." + %lib_console% debug_output "Using vendored Git '!GIT_VERSION_VENDORED!' from '!GIT_INSTALL_ROOT!..." goto :CONFIGURE_GIT ) else ( goto :NO_GIT @@ -246,7 +246,7 @@ if exist "%CMDER_ROOT%\vendor\git-for-windows" ( goto :CONFIGURE_GIT :FOUND_GIT -%lib_console% debug_output "Using found Git from '%GIT_INSTALL_ROOT%..." +%lib_console% debug_output "Using found Git '!GIT_VERSION_USER!' from '%GIT_INSTALL_ROOT%..." goto :CONFIGURE_GIT :CONFIGURE_GIT From 13de4924ca3ca0426db5bbb0febfc4a6ca91aeb5 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 31 Mar 2019 16:47:36 -0400 Subject: [PATCH 10/11] make powershell use of bash commands more bash like --- vendor/profile.ps1 | 50 ++++++++++++++++++++------------- vendor/user_profile.ps1.default | 17 +++++++++++ 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/vendor/profile.ps1 b/vendor/profile.ps1 index 498bdc0..781cba6 100644 --- a/vendor/profile.ps1 +++ b/vendor/profile.ps1 @@ -36,26 +36,21 @@ if(-not $moduleInstallerAvailable -and -not $env:PSModulePath.Contains($CmderMod $env:PSModulePath = $env:PSModulePath.Insert(0, "$CmderModulePath;") } -try { - Get-command -Name "vim" -ErrorAction Stop >$null -} catch { - # # You could do this but it may be a little drastic and introduce a lot of - # # unix tool overlap with powershel unix like aliases - # $env:Path += $(";" + $env:CMDER_ROOT + "\vendor\git-for-windows\usr\bin") - # set-alias -name "vi" -value "vim" - # # I think the below is safer. +function Configure-Git($GIT_INSTALL_ROOT){ + $env:Path += $(";" + $GIT_INSTALL_ROOT + "\cmd") - new-alias -name "vim" -value $($ENV:CMDER_ROOT + "\vendor\git-for-windows\usr\bin\vim.exe") - new-alias -name "vi" -value vim -} - -try { - # Check if git is on PATH, i.e. Git already installed on system - Get-command -Name "git" -ErrorAction Stop >$null -} catch { - $env:Path += $(";" + $env:CMDER_ROOT + "\vendor\git-for-windows\cmd") - # for bash.exe, which in the cmd version is found as \usr\bin\bash.exe - $env:Path += $(";" + $env:CMDER_ROOT + "\vendor\git-for-windows\bin") + # Add "$GIT_INSTALL_ROOT\usr\bin" to the path if exists and not done already + $GIT_INSTALL_ROOT_ESC=$GIT_INSTALL_ROOT.replace('\','\\') + if ((test-path "$GIT_INSTALL_ROOT\usr\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\usr\\bin")) { + $env:path = "$env:path;$GIT_INSTALL_ROOT\usr\bin" + } + + # Add "$GIT_INSTALL_ROOT\mingw[32|64]\bin" to the path if exists and not done already + if ((test-path "$GIT_INSTALL_ROOT\mingw32\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\mingw32\\bin")) { + $env:path = "$env:path;$GIT_INSTALL_ROOT\mingw32\bin" + } elseif ((test-path "$GIT_INSTALL_ROOT\mingw64\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\mingw64\\bin")) { + $env:path = "$env:path;$GIT_INSTALL_ROOT\mingw64\bin" + } } $gitLoaded = $false @@ -84,6 +79,19 @@ function checkGit($Path) { } } +try { + # Check if git is on PATH, i.e. Git already installed on system + Get-command -Name "git" -ErrorAction Stop >$null +} catch { + if (test-path "$env:CMDER_ROOT\vendor\git-for-windows") { + Configure-Git "$env:CMDER_ROOT\vendor\git-for-windows" + } +} + +if ( Get-command -Name "vim" -ErrorAction silentlycontinue) { + new-alias -name "vi" -value vim +} + if (Get-Module PSReadline -ErrorAction "SilentlyContinue") { Set-PSReadlineOption -ExtraPromptLineCount 1 } @@ -170,7 +178,9 @@ if ( $(get-command prompt).Definition -match 'PS \$\(\$executionContext.SessionS [ScriptBlock]$CmderPrompt = { $Host.UI.RawUI.ForegroundColor = "White" Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green - checkGit($pwd.ProviderPath) + if (get-command git -erroraction silentlycontinue) { + checkGit($pwd.ProviderPath) + } } <# diff --git a/vendor/user_profile.ps1.default b/vendor/user_profile.ps1.default index b85ebee..27cc47b 100644 --- a/vendor/user_profile.ps1.default +++ b/vendor/user_profile.ps1.default @@ -23,3 +23,20 @@ ## +# Delete default powershell aliases that conflict with bash commands +# If you prefer the powershell aliases remove this. +if (get-command git) { + del -force alias:cat + del -force alias:clear + del -force alias:cp + del -force alias:diff + del -force alias:echo + del -force alias:kill + del -force alias:ls + del -force alias:mv + del -force alias:ps + del -force alias:pwd + del -force alias:rm + del -force alias:sleep + del -force alias:tee +} From a813e359c5c75d819b6c166c40c968dc2037101e Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Mon, 1 Apr 2019 09:09:32 -0400 Subject: [PATCH 11/11] don't delete aliases by default but provide an easy way for users to do so. --- vendor/bin/alias.cmd | 46 ++++++++++++++++++++++++++------- vendor/user_profile.ps1.default | 33 ++++++++++++----------- 2 files changed, 52 insertions(+), 27 deletions(-) diff --git a/vendor/bin/alias.cmd b/vendor/bin/alias.cmd index 1a1739d..8e10d1d 100644 --- a/vendor/bin/alias.cmd +++ b/vendor/bin/alias.cmd @@ -48,6 +48,9 @@ goto parseargument set _x=%* ) ) + +echo _x=%_x% + rem #endregion parseargument if "%ALIASES%" neq "%CMDER_ROOT%\config\user_aliases.cmd" ( @@ -63,18 +66,41 @@ if "%ALIASES%" neq "%CMDER_ROOT%\config\user_aliases.cmd" ( ) ) -:: validate alias -for /f "delims== tokens=1,* usebackq" %%G in (`echo "%_x%"`) do ( - set alias_name=%%G - set alias_value=%%H +:: create with multiple parameters +if [%1] == [create] ( + if not [%2] == [] ( + if not [%3] == [] ( + set _x=%1=%2 + :: if command create was submitted + set alias_name=%~2 + shift + shift + echo %* + set alias_value=%* + + for /f "tokens=1,2,* usebackq" %%G in (`echo %*`) do ( + set alias_name=%%H + set alias_value=%%I + ) + ) + ) +) else ( + :: validate alias + echo %_x% + set x=!_x:%=^^%! + echo !_x! + for /f "delims== tokens=1,* usebackq" %%G in (`echo "!_x!"`) do ( + set alias_name=%%G + set alias_value=%%H + ) + + :: leading quotes added while validating + set alias_name=!alias_name:~1! + + :: trailing quotes added while validating + set alias_value=!alias_value:~1,-1! ) -:: leading quotes added while validating -set alias_name=%alias_name:~1% - -:: trailing quotes added while validating -set alias_value=%alias_value:~0,-1% - ::remove spaces set _temp=%alias_name: =% diff --git a/vendor/user_profile.ps1.default b/vendor/user_profile.ps1.default index 27cc47b..8ed5b81 100644 --- a/vendor/user_profile.ps1.default +++ b/vendor/user_profile.ps1.default @@ -23,20 +23,19 @@ ## -# Delete default powershell aliases that conflict with bash commands -# If you prefer the powershell aliases remove this. -if (get-command git) { - del -force alias:cat - del -force alias:clear - del -force alias:cp - del -force alias:diff - del -force alias:echo - del -force alias:kill - del -force alias:ls - del -force alias:mv - del -force alias:ps - del -force alias:pwd - del -force alias:rm - del -force alias:sleep - del -force alias:tee -} +# # Delete default powershell aliases that conflict with bash commands +# if (get-command git) { +# del -force alias:cat +# del -force alias:clear +# del -force alias:cp +# del -force alias:diff +# del -force alias:echo +# del -force alias:kill +# del -force alias:ls +# del -force alias:mv +# del -force alias:ps +# del -force alias:pwd +# del -force alias:rm +# del -force alias:sleep +# del -force alias:tee +# }