mirror of
				https://github.com/cmderdev/cmder.git
				synced 2025-10-31 09:22:15 +08:00 
			
		
		
		
	Improvements to Cmder prompt
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| # How to contribute | # How to contribute | ||||||
|  |  | ||||||
| Unfortunately we all can't work on cmder every day of the year, so I have decided to write some guidelines for contributing. | Unfortunately we all can't work on Cmder every day of the year, so I have decided to write some guidelines for contributing. | ||||||
|  |  | ||||||
| If you follow them your contribution will likely be pulled in quicker. | If you follow them your contribution will likely be pulled in quicker. | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ SET CMDER_ROOT=%~dp0 | |||||||
| @if "%CMDER_ROOT:~-1%" == "\" SET CMDER_ROOT=%CMDER_ROOT:~0,-1% | @if "%CMDER_ROOT:~-1%" == "\" SET CMDER_ROOT=%CMDER_ROOT:~0,-1% | ||||||
|  |  | ||||||
| if not exist "%CMDER_ROOT%\config\user_ConEmu.xml" ( | if not exist "%CMDER_ROOT%\config\user_ConEmu.xml" ( | ||||||
|   copy "%CMDER_ROOT%\vendor\ConEmu.xml.default" "%CMDER_ROOT%\config\user_ConEmu.xml" |     copy "%CMDER_ROOT%\vendor\ConEmu.xml.default" "%CMDER_ROOT%\config\user_ConEmu.xml" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| if exist "%~1" ( | if exist "%~1" ( | ||||||
|   | |||||||
| @@ -98,8 +98,8 @@ function Get-VersionStr { | |||||||
|  |  | ||||||
|     # Determine if git is available |     # Determine if git is available | ||||||
|     if (Get-Command "git.exe" -ErrorAction SilentlyContinue) { |     if (Get-Command "git.exe" -ErrorAction SilentlyContinue) { | ||||||
|         # Determine if the current diesctory is a git repository |         # Determine if the current directory is a git repository | ||||||
|         $GitPresent = Invoke-Expression "git rev-parse --is-inside-work-tree" -erroraction SilentlyContinue |         $GitPresent = Invoke-Expression "git rev-parse --is-inside-work-tree" -ErrorAction SilentlyContinue | ||||||
|  |  | ||||||
|         if ( $GitPresent -eq 'true' ) { |         if ( $GitPresent -eq 'true' ) { | ||||||
|             $string = Invoke-Expression "git describe --abbrev=0 --tags" |             $string = Invoke-Expression "git describe --abbrev=0 --tags" | ||||||
|   | |||||||
							
								
								
									
										70
									
								
								vendor/clink.lua
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										70
									
								
								vendor/clink.lua
									
									
									
									
										vendored
									
									
								
							| @@ -15,34 +15,34 @@ dofile(clink_lua_file) | |||||||
|  |  | ||||||
|  |  | ||||||
| local function get_uah_color() | local function get_uah_color() | ||||||
|   return uah_color or "\x1b[1;33;49m" -- Green = uah = [user]@[hostname] |     return uah_color or "\x1b[1;33;49m" -- Green = uah = [user]@[hostname] | ||||||
| end | end | ||||||
|  |  | ||||||
| local function get_cwd_color() | local function get_cwd_color() | ||||||
|   return cwd_color or "\x1b[1;32;49m" -- Yellow cwd = Current Working Directory |     return cwd_color or "\x1b[1;32;49m" -- Yellow cwd = Current Working Directory | ||||||
| end | end | ||||||
|  |  | ||||||
| local function get_lamb_color() | local function get_lamb_color() | ||||||
|   return lamb_color or "\x1b[1;30;49m" -- Light Grey = Lambda Color |     return lamb_color or "\x1b[1;30;49m" -- Light Grey = Lambda Color | ||||||
| end | end | ||||||
|  |  | ||||||
|  |  | ||||||
| local function get_clean_color() | local function get_clean_color() | ||||||
|   return clean_color or "\x1b[1;37;49m" |     return clean_color or "\x1b[1;37;49m" | ||||||
| end | end | ||||||
|  |  | ||||||
|  |  | ||||||
| local function get_dirty_color() | local function get_dirty_color() | ||||||
|   return dirty_color or "\x1b[33;3m" |     return dirty_color or "\x1b[33;3m" | ||||||
| end | end | ||||||
|  |  | ||||||
|  |  | ||||||
| local function get_conflict_color() | local function get_conflict_color() | ||||||
|   return conflict_color or "\x1b[31;1m" |     return conflict_color or "\x1b[31;1m" | ||||||
| end | end | ||||||
|  |  | ||||||
| local function get_unknown_color() | local function get_unknown_color() | ||||||
|   return unknown_color or "\x1b[37;1m" |     return unknown_color or "\x1b[37;1m" | ||||||
| end | end | ||||||
|  |  | ||||||
| --- | --- | ||||||
| @@ -57,9 +57,9 @@ end | |||||||
| -- Ex: Input C:\Windows\System32 returns System32 | -- Ex: Input C:\Windows\System32 returns System32 | ||||||
| --- | --- | ||||||
| local function get_folder_name(path) | local function get_folder_name(path) | ||||||
|   local reversePath = string.reverse(path) |     local reversePath = string.reverse(path) | ||||||
|   local slashIndex = string.find(reversePath, "\\") |     local slashIndex = string.find(reversePath, "\\") | ||||||
|   return string.sub(path, string.len(path) - slashIndex + 2) |     return string.sub(path, string.len(path) - slashIndex + 2) | ||||||
| end | end | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -115,32 +115,32 @@ local function set_prompt_filter() | |||||||
|     -- Much of the below was 'borrowed' from https://github.com/AmrEldib/cmder-powerline-prompt |     -- Much of the below was 'borrowed' from https://github.com/AmrEldib/cmder-powerline-prompt | ||||||
|     -- Symbol displayed for the home dir in the prompt. |     -- Symbol displayed for the home dir in the prompt. | ||||||
|     if not prompt_homeSymbol then |     if not prompt_homeSymbol then | ||||||
|       prompt_homeSymbol = "~" |         prompt_homeSymbol = "~" | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     -- Symbol displayed in the new line below the prompt. |     -- Symbol displayed in the new line below the prompt. | ||||||
|     if not prompt_lambSymbol then |     if not prompt_lambSymbol then | ||||||
|       prompt_lambSymbol = "λ" |         prompt_lambSymbol = "λ" | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     if not prompt_type then |     if not prompt_type then | ||||||
|       prompt_type = "full" |         prompt_type = "full" | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     if prompt_useHomeSymbol == nil then |     if prompt_useHomeSymbol == nil then | ||||||
|       prompt_useHomeSymbol = false |         prompt_useHomeSymbol = false | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     if prompt_useUserAtHost == nil then |     if prompt_useUserAtHost == nil then | ||||||
|       prompt_useUserAtHost = false |         prompt_useUserAtHost = false | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     if prompt_singleLine == nil then |     if prompt_singleLine == nil then | ||||||
|       prompt_singleLine = false |         prompt_singleLine = false | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     if prompt_includeVersionControl == nil then |     if prompt_includeVersionControl == nil then | ||||||
|       prompt_includeVersionControl = true |         prompt_includeVersionControl = true | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     if prompt_type == 'folder' then |     if prompt_type == 'folder' then | ||||||
| @@ -158,9 +158,11 @@ local function set_prompt_filter() | |||||||
|  |  | ||||||
|     cr = "\n" |     cr = "\n" | ||||||
|     if prompt_singleLine then |     if prompt_singleLine then | ||||||
|       cr = ' ' |         cr = ' ' | ||||||
|     end |     end | ||||||
|  |  | ||||||
|  |     cr = "\x1b[0m" .. cr | ||||||
|  |  | ||||||
|     if env ~= nil then env = "("..env..") " else env = "" end |     if env ~= nil then env = "("..env..") " else env = "" end | ||||||
|  |  | ||||||
|     if uah ~= '' then uah = get_uah_color() .. uah end |     if uah ~= '' then uah = get_uah_color() .. uah end | ||||||
| @@ -168,7 +170,7 @@ local function set_prompt_filter() | |||||||
|  |  | ||||||
|     local version_control = prompt_includeVersionControl and "{git}{hg}{svn}" or "" |     local version_control = prompt_includeVersionControl and "{git}{hg}{svn}" or "" | ||||||
|  |  | ||||||
|     prompt = "{uah}{cwd}" .. version_control .. get_lamb_color() .. cr .. "{env}{lamb} \x1b[0m" |     prompt = "{uah}{cwd}" .. version_control .. cr .. get_lamb_color() .. "{env}{lamb}\x1b[0m " | ||||||
|     prompt = string.gsub(prompt, "{uah}", uah) |     prompt = string.gsub(prompt, "{uah}", uah) | ||||||
|     prompt = string.gsub(prompt, "{cwd}", cwd) |     prompt = string.gsub(prompt, "{cwd}", cwd) | ||||||
|     prompt = string.gsub(prompt, "{env}", env) |     prompt = string.gsub(prompt, "{env}", env) | ||||||
| @@ -363,12 +365,12 @@ local function get_git_status() | |||||||
|         local code = line:sub(1, 2) |         local code = line:sub(1, 2) | ||||||
|         -- print (string.format("code: %s, line: %s", code, line)) |         -- print (string.format("code: %s, line: %s", code, line)) | ||||||
|         if code == "DD" or code == "AU" or code == "UD" or code == "UA" or code == "DU" or code == "AA" or code == "UU" then |         if code == "DD" or code == "AU" or code == "UD" or code == "UA" or code == "DU" or code == "AA" or code == "UU" then | ||||||
|           is_status = false |             is_status = false | ||||||
|           conflict_found = true |             conflict_found = true | ||||||
|           break |             break | ||||||
|         -- unversioned files are ignored, comment out 'code ~= "!!"' to unignore them |         -- unversioned files are ignored, comment out 'code ~= "!!"' to unignore them | ||||||
|         elseif code ~= "!!" and code ~= "??" then |         elseif code ~= "!!" and code ~= "??" then | ||||||
|           is_status = false |             is_status = false | ||||||
|         end |         end | ||||||
|     end |     end | ||||||
|     file:close() |     file:close() | ||||||
| @@ -440,16 +442,16 @@ local function get_git_status_setting() | |||||||
|  |  | ||||||
|     for line in gitStatusConfig:lines() do |     for line in gitStatusConfig:lines() do | ||||||
|         if string.match(line, 'false') then |         if string.match(line, 'false') then | ||||||
|           gitStatusConfig:close() |             gitStatusConfig:close() | ||||||
|           return false |             return false | ||||||
|         end |         end | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     local gitCmdStatusConfig = io.popen("git --no-pager config cmder.cmdstatus 2>nul") |     local gitCmdStatusConfig = io.popen("git --no-pager config cmder.cmdstatus 2>nul") | ||||||
|     for line in gitCmdStatusConfig:lines() do |     for line in gitCmdStatusConfig:lines() do | ||||||
|         if string.match(line, 'false') then |         if string.match(line, 'false') then | ||||||
|           gitCmdStatusConfig:close() |             gitCmdStatusConfig:close() | ||||||
|           return false |             return false | ||||||
|         end |         end | ||||||
|     end |     end | ||||||
|     gitStatusConfig:close() |     gitStatusConfig:close() | ||||||
| @@ -640,11 +642,11 @@ for _,lua_module in ipairs(clink.find_files(completions_dir..'*.lua')) do | |||||||
| end | end | ||||||
|  |  | ||||||
| if clink.get_env('CMDER_USER_CONFIG') then | if clink.get_env('CMDER_USER_CONFIG') then | ||||||
|   local cmder_config_dir = clink.get_env('CMDER_ROOT')..'/config/' |     local cmder_config_dir = clink.get_env('CMDER_ROOT')..'/config/' | ||||||
|   for _,lua_module in ipairs(clink.find_files(cmder_config_dir..'*.lua')) do |     for _,lua_module in ipairs(clink.find_files(cmder_config_dir..'*.lua')) do | ||||||
|     local filename = cmder_config_dir..lua_module |         local filename = cmder_config_dir..lua_module | ||||||
|     -- use dofile instead of require because require caches loaded modules |         -- use dofile instead of require because require caches loaded modules | ||||||
|     -- so config reloading using Alt-Q won't reload updated modules. |         -- so config reloading using Alt-Q won't reload updated modules. | ||||||
|     dofile(filename) |         dofile(filename) | ||||||
|   end |     end | ||||||
| end | end | ||||||
|   | |||||||
							
								
								
									
										9
									
								
								vendor/clink_settings.default
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								vendor/clink_settings.default
									
									
									
									
										vendored
									
									
								
							| @@ -17,3 +17,12 @@ history.max_lines = 10000 | |||||||
| # name: Share history between instances | # name: Share history between instances | ||||||
| # type: boolean | # type: boolean | ||||||
| history.shared = True | history.shared = True | ||||||
|  |  | ||||||
|  | # name: Auto-answer terminate prompt | ||||||
|  | # type: enum | ||||||
|  | # options: off,answer_yes,answer_no | ||||||
|  | cmd.auto_answer = answer_yes | ||||||
|  |  | ||||||
|  | # name: Doskey completions | ||||||
|  | # type: color | ||||||
|  | color.doskey = yellow | ||||||
|   | |||||||
							
								
								
									
										78
									
								
								vendor/init.bat
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										78
									
								
								vendor/init.bat
									
									
									
									
										vendored
									
									
								
							| @@ -129,10 +129,15 @@ goto var_loop | |||||||
| %print_debug% init.bat "Env Var - CMDER_ROOT=%CMDER_ROOT%" | %print_debug% init.bat "Env Var - CMDER_ROOT=%CMDER_ROOT%" | ||||||
| %print_debug% init.bat "Env Var - debug_output=%debug_output%" | %print_debug% init.bat "Env Var - debug_output=%debug_output%" | ||||||
|  |  | ||||||
|  | :: Sets Cmder directory paths | ||||||
|  | SET CMDER_CONFIG_DIR=%CMDER_ROOT%\config | ||||||
|  |  | ||||||
|  | :: Check if wre're using Cmder individual user profile | ||||||
| if defined CMDER_USER_CONFIG ( | if defined CMDER_USER_CONFIG ( | ||||||
|     %print_debug% init.bat "CMDER IS ALSO USING INDIVIDUAL USER CONFIG FROM '%CMDER_USER_CONFIG%'!" |     %print_debug% init.bat "CMDER IS ALSO USING INDIVIDUAL USER CONFIG FROM '%CMDER_USER_CONFIG%'!" | ||||||
|  |  | ||||||
|     if not exist "%CMDER_USER_CONFIG%\..\opt" md "%CMDER_USER_CONFIG%\..\opt" |     if not exist "%CMDER_USER_CONFIG%\..\opt" md "%CMDER_USER_CONFIG%\..\opt" | ||||||
|  |     set CMDER_CONFIG_DIR=%CMDER_USER_CONFIG% | ||||||
| ) | ) | ||||||
|  |  | ||||||
| :: Pick right version of Clink | :: Pick right version of Clink | ||||||
| @@ -153,54 +158,29 @@ if "%CMDER_CLINK%" == "1" ( | |||||||
|     ) |     ) | ||||||
|  |  | ||||||
|     :: Run Clink |     :: Run Clink | ||||||
|     if defined CMDER_USER_CONFIG ( |     if not exist "%CMDER_CONFIG_DIR%\settings" if not exist "%CMDER_CONFIG_DIR%\clink_settings" ( | ||||||
|         if not exist "%CMDER_USER_CONFIG%\settings" if not exist "%CMDER_USER_CONFIG%\clink_settings" ( |         echo Generating Clink initial settings in "%CMDER_CONFIG_DIR%\clink_settings" | ||||||
|             echo Generating clink initial settings in "%CMDER_USER_CONFIG%\clink_settings" |         copy "%CMDER_ROOT%\vendor\clink_settings.default" "%CMDER_CONFIG_DIR%\clink_settings" | ||||||
|             copy "%CMDER_ROOT%\vendor\clink_settings.default" "%CMDER_USER_CONFIG%\clink_settings" |         echo Additional *.lua files in "%CMDER_CONFIG_DIR%" are loaded on startup. | ||||||
|             echo Additional *.lua files in "%CMDER_USER_CONFIG%" are loaded on startup. |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         if not exist "%CMDER_USER_CONFIG%\cmder_prompt_config.lua" ( |  | ||||||
|             echo Creating Cmder prompt config file: "%CMDER_USER_CONFIG%\cmder_prompt_config.lua" |  | ||||||
|             copy "%CMDER_ROOT%\vendor\cmder_prompt_config.lua.default" "%CMDER_USER_CONFIG%\cmder_prompt_config.lua" |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         REM Cleanup lagacy Clink Settings file |  | ||||||
|         if exist "%CMDER_USER_CONFIG%\settings" if exist "%CMDER_USER_CONFIG%\clink_settings" ( |  | ||||||
|             del "%CMDER_USER_CONFIG%\settings" |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         REM Cleanup legacy Clink history file |  | ||||||
|         if exist "%CMDER_USER_CONFIG%\.history" if exist "%CMDER_USER_CONFIG%\clink_history" ( |  | ||||||
|             del "%CMDER_USER_CONFIG%\.history" |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_USER_CONFIG%" --scripts "%CMDER_ROOT%\vendor" |  | ||||||
|     ) else ( |  | ||||||
|         if not exist "%CMDER_ROOT%\config\settings" if not exist "%CMDER_ROOT%\config\clink_settings" ( |  | ||||||
|             echo Generating Clink initial settings in "%CMDER_ROOT%\config\clink_settings" |  | ||||||
|             copy "%CMDER_ROOT%\vendor\clink_settings.default" "%CMDER_ROOT%\config\clink_settings" |  | ||||||
|             echo Additional *.lua files in "%CMDER_ROOT%\config" are loaded on startup. |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         if not exist "%CMDER_ROOT%\config\cmder_prompt_config.lua" ( |  | ||||||
|             echo Creating Cmder prompt config file: "%CMDER_ROOT%\config\cmder_prompt_config.lua" |  | ||||||
|             copy "%CMDER_ROOT%\vendor\cmder_prompt_config.lua.default" "%CMDER_ROOT%\config\cmder_prompt_config.lua" |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         REM Cleanup lagacy Clink Settings file |  | ||||||
|             if exist "%CMDER_ROOT%\config\settings" if exist "%CMDER_ROOT%\config\clink_settings" ( |  | ||||||
|             del "%CMDER_ROOT%\config\settings" |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         REM Cleanup legacy Clink history file |  | ||||||
|             if exist "%CMDER_ROOT%\config\.history" if exist "%CMDER_ROOT%\config\clink_history" ( |  | ||||||
|             del "%CMDER_ROOT%\config\.history" |  | ||||||
|         ) |  | ||||||
|  |  | ||||||
|         "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config" --scripts "%CMDER_ROOT%\vendor" |  | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
|  |     if not exist "%CMDER_CONFIG_DIR%\cmder_prompt_config.lua" ( | ||||||
|  |         echo Creating Cmder prompt config file: "%CMDER_CONFIG_DIR%\cmder_prompt_config.lua" | ||||||
|  |         copy "%CMDER_ROOT%\vendor\cmder_prompt_config.lua.default" "%CMDER_CONFIG_DIR%\cmder_prompt_config.lua" | ||||||
|  |     ) | ||||||
|  |  | ||||||
|  |     :: Cleanup lagacy Clink Settings file | ||||||
|  |     if exist "%CMDER_CONFIG_DIR%\settings" if exist "%CMDER_CONFIG_DIR%\clink_settings" ( | ||||||
|  |         del "%CMDER_CONFIG_DIR%\settings" | ||||||
|  |     ) | ||||||
|  |  | ||||||
|  |     :: Cleanup legacy Clink history file | ||||||
|  |     if exist "%CMDER_CONFIG_DIR%\.history" if exist "%CMDER_CONFIG_DIR%\clink_history" ( | ||||||
|  |         del "%CMDER_CONFIG_DIR%\.history" | ||||||
|  |     ) | ||||||
|  |  | ||||||
|  |     "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_CONFIG_DIR%" --scripts "%CMDER_ROOT%\vendor" | ||||||
|  |  | ||||||
|     if errorlevel 1 ( |     if errorlevel 1 ( | ||||||
|         %print_error% "Failed to initialize Clink with error code: %errorlevel%" |         %print_error% "Failed to initialize Clink with error code: %errorlevel%" | ||||||
|     ) |     ) | ||||||
| @@ -361,11 +341,7 @@ if defined CMDER_USER_CONFIG ( | |||||||
| :: must also be self executing, see '.\user_aliases.cmd.default', | :: must also be self executing, see '.\user_aliases.cmd.default', | ||||||
| :: and be in profile.d folder. | :: and be in profile.d folder. | ||||||
| if not defined user_aliases ( | if not defined user_aliases ( | ||||||
|     if defined CMDER_USER_CONFIG ( |     set "user_aliases=%CMDER_CONFIG_DIR%\user_aliases.cmd" | ||||||
|         set "user_aliases=%CMDER_USER_CONFIG%\user_aliases.cmd" |  | ||||||
|     ) else ( |  | ||||||
|         set "user_aliases=%CMDER_ROOT%\config\user_aliases.cmd" |  | ||||||
|     ) |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| if "%CMDER_ALIASES%" == "1" ( | if "%CMDER_ALIASES%" == "1" ( | ||||||
|   | |||||||
							
								
								
									
										35
									
								
								vendor/profile.ps1
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										35
									
								
								vendor/profile.ps1
									
									
									
									
										vendored
									
									
								
							| @@ -1,5 +1,6 @@ | |||||||
| # Init Script for PowerShell | # Init Script for PowerShell | ||||||
| # Created as part of cmder project | # Created as part of Cmder project | ||||||
|  | # This file must be saved using UTF-8 with BOM encoding for prompt to work correctly. | ||||||
|  |  | ||||||
| # !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED | # !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED | ||||||
| # !!! Use "%CMDER_ROOT%\config\user_profile.ps1" to add your own startup commands | # !!! Use "%CMDER_ROOT%\config\user_profile.ps1" to add your own startup commands | ||||||
| @@ -16,8 +17,8 @@ if ($ENV:CMDER_USER_CONFIG) { | |||||||
| } | } | ||||||
|  |  | ||||||
| # We do this for Powershell as Admin Sessions because CMDER_ROOT is not being set. | # We do this for Powershell as Admin Sessions because CMDER_ROOT is not being set. | ||||||
| if ($null -eq $ENV:CMDER_ROOT) { | if (!$ENV:CMDER_ROOT) { | ||||||
|     if (-Not($null -eq $ENV:ConEmuDir)) { |     if ($ENV:ConEmuDir) { | ||||||
|         $ENV:CMDER_ROOT = Resolve-Path($ENV:ConEmuDir + "\..\..") |         $ENV:CMDER_ROOT = Resolve-Path($ENV:ConEmuDir + "\..\..") | ||||||
|     } else { |     } else { | ||||||
|         $ENV:CMDER_ROOT = Resolve-Path($PSScriptRoot + "\..") |         $ENV:CMDER_ROOT = Resolve-Path($PSScriptRoot + "\..") | ||||||
| @@ -25,7 +26,7 @@ if ($null -eq $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 | ||||||
| @@ -85,7 +86,7 @@ if (-Not ($null -eq $ENV:GIT_INSTALL_ROOT)) { | |||||||
|     $env:Path = Configure-Git -gitRoot "$ENV:GIT_INSTALL_ROOT" -gitType $ENV:GIT_INSTALL_TYPE -gitPathUser $gitPathUser |     $env:Path = Configure-Git -gitRoot "$ENV:GIT_INSTALL_ROOT" -gitType $ENV:GIT_INSTALL_TYPE -gitPathUser $gitPathUser | ||||||
| } | } | ||||||
|  |  | ||||||
| if (Get-Command -Name "vim" -ErrorAction silentlycontinue) { | if (Get-Command -Name "vim" -ErrorAction SilentlyContinue) { | ||||||
|     New-Alias -name "vi" -value vim |     New-Alias -name "vi" -value vim | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -98,10 +99,15 @@ $env:gitLoaded = $false | |||||||
| [ScriptBlock]$PrePrompt = {} | [ScriptBlock]$PrePrompt = {} | ||||||
| [ScriptBlock]$PostPrompt = {} | [ScriptBlock]$PostPrompt = {} | ||||||
| [ScriptBlock]$CmderPrompt = { | [ScriptBlock]$CmderPrompt = { | ||||||
|  |     $identity = [Security.Principal.WindowsIdentity]::GetCurrent() | ||||||
|  |     $principal = [Security.Principal.WindowsPrincipal] $identity | ||||||
|  |     $adminRole = [Security.Principal.WindowsBuiltInRole]::Administrator | ||||||
|  |     $color = "White" | ||||||
|  |     if ($principal.IsInRole($adminRole)) { $color = "Red" } | ||||||
|     $Host.UI.RawUI.ForegroundColor = "White" |     $Host.UI.RawUI.ForegroundColor = "White" | ||||||
|     Write-Host -NoNewline "PS " |     Microsoft.PowerShell.Utility\Write-Host -NoNewline "PS " -ForegroundColor $color | ||||||
|     Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green |     Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green | ||||||
|     if (Get-Command git -erroraction silentlycontinue) { |     if (Get-Command git -ErrorAction SilentlyContinue) { | ||||||
|         checkGit($pwd.ProviderPath) |         checkGit($pwd.ProviderPath) | ||||||
|     } |     } | ||||||
|     Microsoft.PowerShell.Utility\Write-Host "`nλ" -NoNewLine -ForegroundColor "DarkGray" |     Microsoft.PowerShell.Utility\Write-Host "`nλ" -NoNewLine -ForegroundColor "DarkGray" | ||||||
| @@ -170,7 +176,7 @@ if ($ENV:CMDER_USER_CONFIG) { | |||||||
| } | } | ||||||
|  |  | ||||||
| if (-Not (Test-Path $CmderUserProfilePath)) { | if (-Not (Test-Path $CmderUserProfilePath)) { | ||||||
|     Write-Host -BackgroundColor Darkgreen -ForegroundColor White "First Run: Creating user startup file: $CmderUserProfilePath" |     Write-Host -BackgroundColor DarkGreen -ForegroundColor White "First Run: Creating user startup file: $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 | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -190,8 +196,13 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS | |||||||
|     Custom prompt functions are loaded in as constants to get the same behaviour |     Custom prompt functions are loaded in as constants to get the same behaviour | ||||||
|     #> |     #> | ||||||
|     [ScriptBlock]$Prompt = { |     [ScriptBlock]$Prompt = { | ||||||
|  |         $lastSUCCESS = $? | ||||||
|         $realLASTEXITCODE = $LASTEXITCODE |         $realLASTEXITCODE = $LASTEXITCODE | ||||||
|         $host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf |         $host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf | ||||||
|  |         Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x200B)`r$([char]0x1B)[K" | ||||||
|  |         if ($lastSUCCESS -Or ($LASTEXITCODE -ne 0)) { | ||||||
|  |             Microsoft.PowerShell.Utility\Write-Host | ||||||
|  |         } | ||||||
|         PrePrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline |         PrePrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline | ||||||
|         CmderPrompt |         CmderPrompt | ||||||
|         PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline |         PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline | ||||||
| @@ -201,9 +212,9 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS | |||||||
|  |  | ||||||
|  |  | ||||||
|     # Once Created these code blocks cannot be overwritten |     # 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 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 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} |     # 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:\PrePrompt   -Value $PrePrompt   -Options Constant | ||||||
|     Set-Item -Path function:\CmderPrompt -Value $CmderPrompt -Options Constant |     Set-Item -Path function:\CmderPrompt -Value $CmderPrompt -Options Constant | ||||||
| @@ -216,4 +227,4 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS | |||||||
| } | } | ||||||
|  |  | ||||||
| $CMDER_INIT_END = $(Get-Date -UFormat %s) | $CMDER_INIT_END = $(Get-Date -UFormat %s) | ||||||
| # Write-Host "Elapsed Time: $(get-Date) `($($CMDER_INIT_END - $CMDER_INIT_START) total`)" | Write-Verbose "Elapsed Time: $(get-Date) `($($CMDER_INIT_END - $CMDER_INIT_START) total`)" | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								vendor/user_aliases.cmd.default
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/user_aliases.cmd.default
									
									
									
									
										vendored
									
									
								
							| @@ -6,6 +6,7 @@ | |||||||
| ;= Add aliases below here | ;= Add aliases below here | ||||||
| e.=explorer . | e.=explorer . | ||||||
| gl=git log --oneline --all --graph --decorate  $* | gl=git log --oneline --all --graph --decorate  $* | ||||||
|  | l=ls --show-control-chars -CFGNhp --color --ignore={"NTUSER.DAT*","ntuser.dat*"} $* | ||||||
| ls=ls --show-control-chars -F --color $* | ls=ls --show-control-chars -F --color $* | ||||||
| pwd=cd | pwd=cd | ||||||
| clear=cls | clear=cls | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user