From 03d0f913ea2dad4596640313a36833a260b8a222 Mon Sep 17 00:00:00 2001 From: dgames Date: Sun, 30 May 2021 07:27:16 -0400 Subject: [PATCH 1/8] fixing branch only --- vendor/clink.lua | 14 ++++++++++++++ vendor/cmder_prompt_config.lua.default | 1 + 2 files changed, 15 insertions(+) diff --git a/vendor/clink.lua b/vendor/clink.lua index c01d6be..2c26d4c 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -350,6 +350,7 @@ local function git_prompt_filter() clean = clean_color, dirty = dirty_color, conflict = conflict_color + nostatus = unknown_color } local git_dir = get_git_dir() @@ -377,6 +378,17 @@ local function git_prompt_filter() return false end end + 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)..")") + return false + end + end + end -- No git present or not in git file @@ -394,6 +406,7 @@ local function hg_prompt_filter() local colors = { clean = clean_color, dirty = dirty_color, + nostatus = nostatus_color } local pipe = io.popen("hg branch 2>&1") @@ -428,6 +441,7 @@ local function svn_prompt_filter() local colors = { clean = clean_color, dirty = dirty_color, + nostatus = nostatus_color } if get_svn_dir() then diff --git a/vendor/cmder_prompt_config.lua.default b/vendor/cmder_prompt_config.lua.default index 5e59c14..366dc62 100644 --- a/vendor/cmder_prompt_config.lua.default +++ b/vendor/cmder_prompt_config.lua.default @@ -43,3 +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 From c9acb13d0b0f8871b2ea6ea8716a820e8eaa2d60 Mon Sep 17 00:00:00 2001 From: dgames Date: Sun, 30 May 2021 07:50:48 -0400 Subject: [PATCH 2/8] Fix cmder no status prompt --- CHANGELOG.md | 2 + vendor/clink.lua | 84 ++++++++++++++++++++------ vendor/cmder_prompt_config.lua.default | 2 +- vendor/sources.json | 4 +- 4 files changed, 70 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc61977..77d2fdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ ### Changes - Update Git for Windows to 2.31.1 +- Update to Clink 1.2.5 +- Do not rely on having a `%cmder_root%\config\cmder_prompt_config.lua` ### Adds diff --git a/vendor/clink.lua b/vendor/clink.lua index 2c26d4c..d69d4e2 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -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 diff --git a/vendor/cmder_prompt_config.lua.default b/vendor/cmder_prompt_config.lua.default index 366dc62..ab3191f 100644 --- a/vendor/cmder_prompt_config.lua.default +++ b/vendor/cmder_prompt_config.lua.default @@ -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 diff --git a/vendor/sources.json b/vendor/sources.json index b552653..f2423a4 100644 --- a/vendor/sources.json +++ b/vendor/sources.json @@ -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", From 4fab4cc6e4fba06f4a8cf13a74afcf2e112fd6e1 Mon Sep 17 00:00:00 2001 From: dgames Date: Sun, 30 May 2021 08:41:40 -0400 Subject: [PATCH 3/8] make unknown color white for all shells --- vendor/git-prompt.sh | 2 +- vendor/psmodules/Cmder.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/git-prompt.sh b/vendor/git-prompt.sh index ccda575..957dcdc 100644 --- a/vendor/git-prompt.sh +++ b/vendor/git-prompt.sh @@ -61,7 +61,7 @@ else PS1="$PS1"'\[\033[36m\]' # change color to cyan PS1="$PS1"'`__git_ps1`' # bash function else - PS1="$PS1"'\[\033[30;1m\]' # change color to gray + PS1="$PS1"'\[\033[37;1m\]' # change color to white PS1="$PS1"'`getSimpleGitBranch`' fi fi diff --git a/vendor/psmodules/Cmder.ps1 b/vendor/psmodules/Cmder.ps1 index 5ede0cf..755d4a7 100644 --- a/vendor/psmodules/Cmder.ps1 +++ b/vendor/psmodules/Cmder.ps1 @@ -43,7 +43,7 @@ function checkGit($Path) { } else { $branchName = "HEAD detached at $($headContent.Substring(0, 7))" } - Write-Host " [$branchName]" -NoNewline -ForegroundColor DarkGray + Write-Host " [$branchName]" -NoNewline -ForegroundColor White } return From 73ad62eaa2c08c9e7ae0192e9139676566523a34 Mon Sep 17 00:00:00 2001 From: dgames Date: Sun, 30 May 2021 08:46:08 -0400 Subject: [PATCH 4/8] add xxx --- xxx | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 xxx diff --git a/xxx b/xxx new file mode 100644 index 0000000..e69de29 From 413fb2f1ac9ad18785cae2b745bc4919dfe7a678 Mon Sep 17 00:00:00 2001 From: dgames Date: Sun, 30 May 2021 08:46:37 -0400 Subject: [PATCH 5/8] remove xxx --- xxx | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 xxx diff --git a/xxx b/xxx deleted file mode 100644 index e69de29..0000000 From aebe37bd282afb361dff54601a056168deab0278 Mon Sep 17 00:00:00 2001 From: dgames Date: Sun, 30 May 2021 08:56:05 -0400 Subject: [PATCH 6/8] fix default unknown color --- vendor/clink.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/clink.lua b/vendor/clink.lua index 5bf3612..89550c4 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -42,7 +42,7 @@ local function get_conflict_color() end local function get_unknown_color() - return unknown_color or "\x1b[1;37;40m" + return unknown_color or "\x1b[37;1m" end --- From 55ff6110952dde45ee561f1e30d4c2778cb019b0 Mon Sep 17 00:00:00 2001 From: dgames Date: Sun, 30 May 2021 08:56:44 -0400 Subject: [PATCH 7/8] fix default unknown color --- vendor/cmder_prompt_config.lua.default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/cmder_prompt_config.lua.default b/vendor/cmder_prompt_config.lua.default index ab3191f..a33de81 100644 --- a/vendor/cmder_prompt_config.lua.default +++ b/vendor/cmder_prompt_config.lua.default @@ -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;37;40m" -- White = No VCS Status Branch Color +unknown_color = "\x1b[37;1" -- White = No VCS Status Branch Color From 56b04fc9ce252c4c1e45023db81c17e667377aba Mon Sep 17 00:00:00 2001 From: dgames Date: Mon, 31 May 2021 10:53:18 -0400 Subject: [PATCH 8/8] fix unknown color and code dedup --- vendor/clink.lua | 50 +++++++++++--------------- vendor/cmder_prompt_config.lua.default | 2 +- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/vendor/clink.lua b/vendor/clink.lua index 89550c4..2110548 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -403,37 +403,29 @@ local function git_prompt_filter() 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) - if branch then - -- Has branch => therefore it is a git folder, now figure out status - local gitStatus = get_git_status() - local gitConflict = get_git_conflict() + if git_dir then + local branch = get_git_branch(git_dir) + if branch then + if cmderGitStatusOptIn then + -- if we're inside of git repo then try to detect current branch + -- Has branch => therefore it is a git folder, now figure out status + local gitStatus = get_git_status() + local gitConflict = get_git_conflict() - color = colors.dirty - if gitStatus then - color = colors.clean - end + color = colors.dirty + if gitStatus then + color = colors.clean + end - if gitConflict then - color = colors.conflict - end - - clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")") - return false - end - end - else - if git_dir then - local branch = get_git_branch(git_dir) - if branch then - color = colors.nostatus - clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")") - return false - end - end + if gitConflict then + color = colors.conflict + end + else + color = colors.nostatus + end + clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")") + return false + end end -- No git present or not in git file diff --git a/vendor/cmder_prompt_config.lua.default b/vendor/cmder_prompt_config.lua.default index a33de81..e5ae224 100644 --- a/vendor/cmder_prompt_config.lua.default +++ b/vendor/cmder_prompt_config.lua.default @@ -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[37;1" -- White = No VCS Status Branch Color +unknown_color = "\x1b[37;1m" -- White = No VCS Status Branch Color