mirror of
				https://github.com/cmderdev/cmder.git
				synced 2025-10-31 09:22:15 +08:00 
			
		
		
		
	Merge branch 'master' of https://github.com/cmderdev/cmder into alias
This commit is contained in:
		
							
								
								
									
										13
									
								
								.github/issue_template.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								.github/issue_template.md
									
									
									
									
										vendored
									
									
								
							| @@ -44,6 +44,11 @@ | |||||||
|  |  | ||||||
|     (Be sure to also check “Closed” issues in the labels section!) |     (Be sure to also check “Closed” issues in the labels section!) | ||||||
|      |      | ||||||
|  |   • If you have a request to provide auto-complete support for a new tool, | ||||||
|  |     please post your request here: | ||||||
|  |      | ||||||
|  |     https://github.com/vladimir-kotikov/clink-completions/issues | ||||||
|  |      | ||||||
|   • If you are having an issue with any of the **upstream technologies** |   • If you are having an issue with any of the **upstream technologies** | ||||||
|     that are used by Cmder, please make sure that the issue is reproducible |     that are used by Cmder, please make sure that the issue is reproducible | ||||||
|     _only_ when used in combination with Cmder. |     _only_ when used in combination with Cmder. | ||||||
| @@ -52,9 +57,9 @@ | |||||||
|        - Clink, the default shell in Cmder |        - Clink, the default shell in Cmder | ||||||
|        - ConEmu, the terminal emulator |        - ConEmu, the terminal emulator | ||||||
|        - Git/MinGW, which also provide *NIX tools |        - Git/MinGW, which also provide *NIX tools | ||||||
|        - clink-completions, which provide autocomplete |        - clink-completions, which provide autocompletion | ||||||
|      |      | ||||||
|     The issues related to upstream technologies are marked as 👆 [name]. |     The issues related to upstream technologies are labeled as 👆 [name]. | ||||||
|      |      | ||||||
|     We'll try our best to help you -- but we recommend creating an issue |     We'll try our best to help you -- but we recommend creating an issue | ||||||
|     specifically at each of the corresponding repositories for the best |     specifically at each of the corresponding repositories for the best | ||||||
| @@ -78,7 +83,7 @@ | |||||||
|  |  | ||||||
| <!--  | <!--  | ||||||
|   Some tips on how to write a better report: |   Some tips on how to write a better report: | ||||||
|   - Put an `x` into all the boxes [ ] relevant to your issue (correct example: [x] • not like this: [ x] or [x ]). |   - Put an `x` into all the boxes [ ] relevant to your issue (correct example: [x] -- not like this: [ x] or [x ]). | ||||||
|   - Use the *Preview* tab to see how your issue will actually look like, before sending it. |   - Use the *Preview* tab to see how your issue will actually look like, before sending it. | ||||||
|   - Make sure the description is worded well enough to be understood, and with as much context and examples as possible. |   - Make sure the description is worded well enough to be understood, and with as much context and examples as possible. | ||||||
|   - Post a screenshot or the command the triggered the problem, if applicable. |   - Post a screenshot or the command the triggered the problem, if applicable. | ||||||
| @@ -98,5 +103,7 @@ | |||||||
| ### Version Information | ### Version Information | ||||||
| <!-- Please write your Cmder and ConEmu version here --> | <!-- Please write your Cmder and ConEmu version here --> | ||||||
|  |  | ||||||
|  | <!-- If applicable, write down your Windows edition too (e.g. Windows 10 Pro 1809) --> | ||||||
|  |  | ||||||
| ### Description of the issue  | ### Description of the issue  | ||||||
| <!-- Provide a clear, simple description of your issue here --> | <!-- Provide a clear, simple description of your issue here --> | ||||||
|   | |||||||
| @@ -20,6 +20,8 @@ | |||||||
| #define MB_TITLE L"Cmder Launcher" | #define MB_TITLE L"Cmder Launcher" | ||||||
| #define SHELL_MENU_REGISTRY_PATH_BACKGROUND L"Directory\\Background\\shell\\Cmder" | #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_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) | #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_BACKGROUND, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); | ||||||
| 		RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM, 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) | 	else if (cmderOptions.unRegisterApp == true) | ||||||
| 	{ | 	{ | ||||||
| 		UnregisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND); | 		UnregisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND); | ||||||
| 		UnregisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM); | 		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) | 	else if (cmderOptions.error == true) | ||||||
| 	{ | 	{ | ||||||
|   | |||||||
							
								
								
									
										21
									
								
								vendor/bin/alias.cmd
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								vendor/bin/alias.cmd
									
									
									
									
										vendored
									
									
								
							| @@ -69,9 +69,6 @@ set args= | |||||||
|     ) |     ) | ||||||
|   ) |   ) | ||||||
|  |  | ||||||
| :: echo _x=%_x% |  | ||||||
| :: echo args=%args% |  | ||||||
|  |  | ||||||
| rem #endregion parseargument | rem #endregion parseargument | ||||||
|  |  | ||||||
| if "%ALIASES%" neq "%CMDER_ROOT%\config\user_aliases.cmd" ( | if "%ALIASES%" neq "%CMDER_ROOT%\config\user_aliases.cmd" ( | ||||||
| @@ -88,11 +85,29 @@ if "%ALIASES%" neq "%CMDER_ROOT%\config\user_aliases.cmd" ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| :: create with multiple parameters | :: create with multiple parameters | ||||||
|  | <<<<<<< HEAD | ||||||
| if [%action%] == [create] ( | if [%action%] == [create] ( | ||||||
|   if not ["%args%"] == [""] ( |   if not ["%args%"] == [""] ( | ||||||
|     for /f "tokens=1,* usebackq" %%G in (`echo %args%`) do ( |     for /f "tokens=1,* usebackq" %%G in (`echo %args%`) do ( | ||||||
|       set alias_name=%%G |       set alias_name=%%G | ||||||
|       set alias_value=%%H |       set alias_value=%%H | ||||||
|  | ======= | ||||||
|  | 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 | ||||||
|  |       ) | ||||||
|  | >>>>>>> ac2082d56d59b3731824e11227eae396278b9f37 | ||||||
|     ) |     ) | ||||||
|   ) |   ) | ||||||
| ) else ( | ) else ( | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								vendor/init.bat
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								vendor/init.bat
									
									
									
									
										vendored
									
									
								
							| @@ -51,9 +51,7 @@ call "%cmder_root%\vendor\lib\lib_profile" | |||||||
|     ) else if /i "%1"=="/v" ( |     ) else if /i "%1"=="/v" ( | ||||||
|         set verbose_output=1 |         set verbose_output=1 | ||||||
|     ) else if /i "%1"=="/d" ( |     ) else if /i "%1"=="/d" ( | ||||||
|         if not defined VSCODE_CWD ( |         set debug_output=1 | ||||||
|             set debug_output=1 |  | ||||||
|         ) |  | ||||||
|     ) else if /i "%1" == "/max_depth" ( |     ) else if /i "%1" == "/max_depth" ( | ||||||
|         if "%~2" geq "1" if "%~2" leq "5" ( |         if "%~2" geq "1" if "%~2" leq "5" ( | ||||||
|             set "max_depth=%~2" |             set "max_depth=%~2" | ||||||
| @@ -235,7 +233,7 @@ for /F "delims=" %%F in ('where git.exe 2^>nul') do ( | |||||||
| :VENDORED_GIT | :VENDORED_GIT | ||||||
| if exist "%CMDER_ROOT%\vendor\git-for-windows" ( | if exist "%CMDER_ROOT%\vendor\git-for-windows" ( | ||||||
|     set "GIT_INSTALL_ROOT=%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 |     goto :CONFIGURE_GIT | ||||||
| ) else ( | ) else ( | ||||||
|     goto :NO_GIT |     goto :NO_GIT | ||||||
| @@ -246,7 +244,7 @@ if exist "%CMDER_ROOT%\vendor\git-for-windows" ( | |||||||
| goto :CONFIGURE_GIT | goto :CONFIGURE_GIT | ||||||
|  |  | ||||||
| :FOUND_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 | goto :CONFIGURE_GIT | ||||||
|  |  | ||||||
| :CONFIGURE_GIT | :CONFIGURE_GIT | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								vendor/lib/lib_git.cmd
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/lib/lib_git.cmd
									
									
									
									
										vendored
									
									
								
							| @@ -88,8 +88,11 @@ exit /b | |||||||
| :::  [SCOPE]_BUILD <out> Scoped Build version. | :::  [SCOPE]_BUILD <out> Scoped Build version. | ||||||
| :::------------------------------------------------------------------------------- | :::------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|     setlocal enabledelayedexpansion |  | ||||||
|     :: process a `x.x.x.xxxx.x` formatted string |     :: 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" |     %lib_console% debug_output :parse_version "ARGV[1]=%~1, ARGV[2]=%~2" | ||||||
|     for /F "tokens=1-3* delims=.,-" %%A in ("%2") do ( |     for /F "tokens=1-3* delims=.,-" %%A in ("%2") do ( | ||||||
|         set "%~1_MAJOR=%%A" |         set "%~1_MAJOR=%%A" | ||||||
| @@ -98,7 +101,6 @@ exit /b | |||||||
|         set "%~1_BUILD=%%D" |         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 |     exit /b | ||||||
|  |  | ||||||
| :validate_version | :validate_version | ||||||
|   | |||||||
							
								
								
									
										135
									
								
								vendor/profile.ps1
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										135
									
								
								vendor/profile.ps1
									
									
									
									
										vendored
									
									
								
							| @@ -25,9 +25,9 @@ if (! $ENV:CMDER_ROOT ) { | |||||||
| # Remove trailing '\' | # Remove trailing '\' | ||||||
| $ENV:CMDER_ROOT = (($ENV:CMDER_ROOT).trimend("\")) | $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 | # -> 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. | # Add Cmder modules directory to the autoload path. | ||||||
| $CmderModulePath = Join-path $PSScriptRoot "psmodules/" | $CmderModulePath = Join-path $PSScriptRoot "psmodules/" | ||||||
| @@ -36,26 +36,21 @@ if(-not $moduleInstallerAvailable -and -not $env:PSModulePath.Contains($CmderMod | |||||||
|     $env:PSModulePath = $env:PSModulePath.Insert(0, "$CmderModulePath;") |     $env:PSModulePath = $env:PSModulePath.Insert(0, "$CmderModulePath;") | ||||||
| } | } | ||||||
|  |  | ||||||
| try { | function Configure-Git($GIT_INSTALL_ROOT){ | ||||||
|     Get-command -Name "vim" -ErrorAction Stop >$null |   $env:Path += $(";" + $GIT_INSTALL_ROOT + "\cmd") | ||||||
| } 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. |  | ||||||
|  |  | ||||||
|     new-alias -name "vim" -value $($ENV:CMDER_ROOT + "\vendor\git-for-windows\usr\bin\vim.exe") |   # Add "$GIT_INSTALL_ROOT\usr\bin" to the path if exists and not done already | ||||||
|     new-alias -name "vi" -value vim |   $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" | ||||||
|  |   } | ||||||
|    |    | ||||||
| try { |   # Add "$GIT_INSTALL_ROOT\mingw[32|64]\bin" to the path if exists and not done already | ||||||
|     # Check if git is on PATH, i.e. Git already installed on system |   if ((test-path "$GIT_INSTALL_ROOT\mingw32\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\mingw32\\bin")) { | ||||||
|     Get-command -Name "git" -ErrorAction Stop >$null |       $env:path = "$env:path;$GIT_INSTALL_ROOT\mingw32\bin" | ||||||
| } catch { |   } elseif ((test-path "$GIT_INSTALL_ROOT\mingw64\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\mingw64\\bin")) { | ||||||
|     $env:Path += $(";" + $env:CMDER_ROOT + "\vendor\git-for-windows\cmd") |       $env:path = "$env:path;$GIT_INSTALL_ROOT\mingw64\bin" | ||||||
|     # for bash.exe, which in the cmd version is found as <GIT>\usr\bin\bash.exe |   } | ||||||
|     $env:Path += $(";" + $env:CMDER_ROOT + "\vendor\git-for-windows\bin") |  | ||||||
| } | } | ||||||
|  |  | ||||||
| $gitLoaded = $false | $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") { | if (Get-Module PSReadline -ErrorAction "SilentlyContinue") { | ||||||
|     Set-PSReadlineOption -ExtraPromptLineCount 1 |     Set-PSReadlineOption -ExtraPromptLineCount 1 | ||||||
| } | } | ||||||
| @@ -91,36 +99,6 @@ if (Get-Module PSReadline -ErrorAction "SilentlyContinue") { | |||||||
| # Enhance Path | # Enhance Path | ||||||
| $env:Path = "$Env:CMDER_ROOT\bin;$Env:CMDER_ROOT\vendor\bin;$env:Path;$Env:CMDER_ROOT" | $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. |  | ||||||
| # |  | ||||||
|  |  | ||||||
| # 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" | # Drop *.ps1 files into "$ENV:CMDER_ROOT\config\profile.d" | ||||||
| # to source them at startup. | # to source them at startup. | ||||||
| if (-not (test-path "$ENV:CMDER_ROOT\config\profile.d")) { | if (-not (test-path "$ENV:CMDER_ROOT\config\profile.d")) { | ||||||
| @@ -185,11 +163,54 @@ if (! (Test-Path $CmderUserProfilePath) ) { | |||||||
|     Copy-Item "$env:CMDER_ROOT\vendor\user_profile.ps1.default" -Destination $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 | # Prompt Section | ||||||
| Set-Item -Path function:\CmderPrompt -Value $CmderPrompt -Options Constant | #   Users should modify their user_profile.ps1 as it will be safe from updates. | ||||||
| Set-Item -Path function:\PostPrompt  -Value $PostPrompt  -Options Constant | # | ||||||
|  |  | ||||||
| # Functions can be made constant only at creation time | # Only set the prompt if it is currently set to the default | ||||||
| # ReadOnly at least requires `-force` to be overwritten | # This allows users to configure the prompt in their user_profile.ps1 or config\profile.d\*.ps1 | ||||||
| Set-Item -Path function:\prompt  -Value $Prompt  -Options ReadOnly | 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 | ||||||
|  |       if (get-command git -erroraction silentlycontinue) { | ||||||
|  |           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 " " | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |   # 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 | ||||||
|  | } | ||||||
|   | |||||||
							
								
								
									
										16
									
								
								vendor/user_profile.ps1.default
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								vendor/user_profile.ps1.default
									
									
									
									
										vendored
									
									
								
							| @@ -23,3 +23,19 @@ | |||||||
|  |  | ||||||
| ## <Continue to add your own> | ## <Continue to add your own> | ||||||
|  |  | ||||||
|  | # # 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 | ||||||
|  | # } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user