mirror of
				https://github.com/cmderdev/cmder.git
				synced 2025-10-31 09:22:15 +08:00 
			
		
		
		
	Fix cmder no status prompt
This commit is contained in:
		
							
								
								
									
										84
									
								
								vendor/clink.lua
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										84
									
								
								vendor/clink.lua
									
									
									
									
										vendored
									
									
								
							| @@ -13,6 +13,38 @@ dofile(clink_lua_file) | ||||
|  | ||||
| -- now add our own things... | ||||
|  | ||||
|  | ||||
| local function get_uah_color() | ||||
|   return uah_color or "\x1b[1;33;40m" -- Green = uah = [user]@[hostname] | ||||
| end | ||||
|  | ||||
| local function get_cwd_color() | ||||
|   return cwd_color or "\x1b[1;32;40m" -- Yellow cwd = Current Working Directory | ||||
| end | ||||
|  | ||||
| local function get_lamb_color() | ||||
|   return lamb_color or "\x1b[1;30;40m" -- Light Grey = Lambda Color | ||||
| end | ||||
|  | ||||
|  | ||||
| local function get_clean_color() | ||||
|   return clean_color or "\x1b[1;37;40m" | ||||
| end | ||||
|  | ||||
|  | ||||
| local function get_dirty_color() | ||||
|   return dirty_color or "\x1b[33;3m" | ||||
| end | ||||
|  | ||||
|  | ||||
| local function get_conflict_color() | ||||
|   return conflict_color or "\x1b[31;1m" | ||||
| end | ||||
|  | ||||
| local function get_unknown_color() | ||||
|   return unknown_color or "\x1b[1;37;40m" | ||||
| end | ||||
|  | ||||
| --- | ||||
| -- Makes a string safe to use as the replacement in string.gsub | ||||
| --- | ||||
| @@ -65,6 +97,22 @@ local function set_prompt_filter() | ||||
|       prompt_lambSymbol = "λ" | ||||
|     end | ||||
|  | ||||
|     if not prompt_type then | ||||
|       prompt_type = "full" | ||||
|     end | ||||
|  | ||||
|     if prompt_useHomeSymbol == nil then | ||||
|       prompt_useHomeSymbol = false | ||||
|     end | ||||
|  | ||||
|     if prompt_useUserAtHost == nil then | ||||
|       prompt_useUserAtHost = false | ||||
|     end | ||||
|  | ||||
|     if prompt_singleLine == nil then | ||||
|       prompt_singleLine = false | ||||
|     end | ||||
|  | ||||
|     if prompt_type == 'folder' then | ||||
|         cwd = get_folder_name(cwd) | ||||
|     end | ||||
| @@ -83,14 +131,13 @@ local function set_prompt_filter() | ||||
|       cr = ' ' | ||||
|     end | ||||
|  | ||||
|     if env ~= nil then | ||||
|         prompt_lambSymbol = "("..env..") "..prompt_lambSymbol | ||||
|     end | ||||
|     if env ~= nil then env = "("..env..") " else env = "" end | ||||
|  | ||||
|     prompt = uah_color .. "{uah}" .. cwd_color .. "{cwd}{git}{hg}{svn}" .. lamb_color .. cr .. "{lamb} \x1b[0m" | ||||
|     uah_value = string.gsub(prompt, "{uah}", uah) | ||||
|     new_value = string.gsub(uah_value, "{cwd}", cwd) | ||||
|     clink.prompt.value = string.gsub(new_value, "{lamb}", prompt_lambSymbol) | ||||
|     prompt = get_uah_color() .. "{uah}" .. get_cwd_color() .. "{cwd}{git}{hg}{svn}" .. get_lamb_color() .. cr .. "{lamb} \x1b[0m" | ||||
|     prompt = string.gsub(prompt, "{uah}", uah) | ||||
|     prompt = string.gsub(prompt, "{cwd}", cwd) | ||||
|     prompt = string.gsub(prompt, "{env}", env) | ||||
|     clink.prompt.value = string.gsub(prompt, "{lamb}", prompt_lambSymbol) | ||||
| end | ||||
|  | ||||
| local function percent_prompt_filter() | ||||
| @@ -347,19 +394,19 @@ local function git_prompt_filter() | ||||
|  | ||||
|     -- Colors for git status | ||||
|     local colors = { | ||||
|         clean = clean_color, | ||||
|         dirty = dirty_color, | ||||
|         conflict = conflict_color | ||||
|         nostatus = unknown_color | ||||
|         clean = get_clean_color(), | ||||
|         dirty = get_dirty_color(), | ||||
|         conflict = get_conflict_color(), | ||||
|         nostatus = get_unknown_color() | ||||
|     } | ||||
|  | ||||
|     local git_dir = get_git_dir() | ||||
|     local color | ||||
|     cmderGitStatusOptIn = get_git_status_setting() | ||||
|     if cmderGitStatusOptIn then | ||||
|       if git_dir then | ||||
|           -- if we're inside of git repo then try to detect current branch | ||||
|           local branch = get_git_branch(git_dir) | ||||
|           local color | ||||
|           if branch then | ||||
|               -- Has branch => therefore it is a git folder, now figure out status | ||||
|               local gitStatus = get_git_status() | ||||
| @@ -381,7 +428,6 @@ local function git_prompt_filter() | ||||
|     else | ||||
|       if git_dir then | ||||
|           local branch = get_git_branch(git_dir) | ||||
|           local color | ||||
|           if branch then | ||||
|               color = colors.nostatus | ||||
|               clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")") | ||||
| @@ -404,9 +450,9 @@ local function hg_prompt_filter() | ||||
|     if hg_dir then | ||||
|         -- Colors for mercurial status | ||||
|         local colors = { | ||||
|             clean = clean_color, | ||||
|             dirty = dirty_color, | ||||
|             nostatus = nostatus_color | ||||
|             clean = get_clean_color(), | ||||
|             dirty = get_dirty_color(), | ||||
|             nostatus = get_unknown_color() | ||||
|         } | ||||
|  | ||||
|         local pipe = io.popen("hg branch 2>&1") | ||||
| @@ -439,9 +485,9 @@ end | ||||
| local function svn_prompt_filter() | ||||
|     -- Colors for svn status | ||||
|     local colors = { | ||||
|         clean = clean_color, | ||||
|         dirty = dirty_color, | ||||
|         nostatus = nostatus_color | ||||
|         clean = get_clean_color(), | ||||
|         dirty = get_dirty_color(), | ||||
|         nostatus = get_unknown_color() | ||||
|     } | ||||
|  | ||||
|     if get_svn_dir() then | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/cmder_prompt_config.lua.default
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/cmder_prompt_config.lua.default
									
									
									
									
										vendored
									
									
								
							| @@ -43,4 +43,4 @@ lamb_color = "\x1b[1;30;40m" -- Light Grey = Lambda Color | ||||
| clean_color = "\x1b[1;37;40m" | ||||
| dirty_color = "\x1b[33;3m" | ||||
| conflict_color = "\x1b[31;1m" | ||||
| unknown_color = "\x1b[1;30;40m" -- Light Grey = No VCS Status Branch Color | ||||
| unknown_color = "\x1b[1;37;40m" -- White = No VCS Status Branch Color | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/sources.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/sources.json
									
									
									
									
										vendored
									
									
								
							| @@ -6,8 +6,8 @@ | ||||
|     }, | ||||
|     { | ||||
|         "name": "clink", | ||||
|         "version": "1.1.45", | ||||
|         "url": "https://github.com/chrisant996/clink/releases/download/v1.1.45/clink.1.1.45.1c3985.zip" | ||||
|         "version": "1.2.5", | ||||
|         "url": "https://github.com/chrisant996/clink/releases/download/v1.2.5/clink.1.2.5.5dd017.zip" | ||||
|     }, | ||||
|     { | ||||
|         "name": "conemu-maximus5", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user