Merge pull request #2538 from daxgames/fix_configurable_prompt

Fix configurable prompt
This commit is contained in:
Dax T Games 2021-05-02 22:47:11 -04:00 committed by GitHub
commit 36f4ce0e3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 10 deletions

View File

@ -5,6 +5,8 @@
### Changes ### Changes
- Update Git for Windows to 2.31.1 - 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 ### Adds

60
vendor/clink.lua vendored
View File

@ -13,6 +13,34 @@ dofile(clink_lua_file)
-- now add our own things... -- 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
--- ---
-- Makes a string safe to use as the replacement in string.gsub -- Makes a string safe to use as the replacement in string.gsub
--- ---
@ -65,6 +93,22 @@ local function set_prompt_filter()
prompt_lambSymbol = "λ" prompt_lambSymbol = "λ"
end 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 if prompt_type == 'folder' then
cwd = get_folder_name(cwd) cwd = get_folder_name(cwd)
end end
@ -85,7 +129,7 @@ local function set_prompt_filter()
if env ~= nil then env = "("..env..") " else env = "" end if env ~= nil then env = "("..env..") " else env = "" end
prompt = uah_color .. "{uah}" .. cwd_color .. "{cwd}{git}{hg}{svn}" .. lamb_color .. cr .. "{env}{lamb} \x1b[0m" 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, "{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)
@ -346,9 +390,9 @@ local function git_prompt_filter()
-- Colors for git status -- Colors for git status
local colors = { local colors = {
clean = clean_color, clean = get_clean_color(),
dirty = dirty_color, dirty = get_dirty_color(),
conflict = conflict_color conflict = get_conflict_color()
} }
local git_dir = get_git_dir() local git_dir = get_git_dir()
@ -391,8 +435,8 @@ local function hg_prompt_filter()
if hg_dir then if hg_dir then
-- Colors for mercurial status -- Colors for mercurial status
local colors = { local colors = {
clean = clean_color, clean = get_clean_color(),
dirty = dirty_color, dirty = get_dirty_color(),
} }
local pipe = io.popen("hg branch 2>&1") local pipe = io.popen("hg branch 2>&1")
@ -425,8 +469,8 @@ end
local function svn_prompt_filter() local function svn_prompt_filter()
-- Colors for svn status -- Colors for svn status
local colors = { local colors = {
clean = clean_color, clean = get_clean_color(),
dirty = dirty_color, dirty = get_dirty_color(),
} }
if get_svn_dir() then if get_svn_dir() then

4
vendor/sources.json vendored
View File

@ -6,8 +6,8 @@
}, },
{ {
"name": "clink", "name": "clink",
"version": "1.1.45", "version": "1.2.5",
"url": "https://github.com/chrisant996/clink/releases/download/v1.1.45/clink.1.1.45.1c3985.zip" "url": "https://github.com/chrisant996/clink/releases/download/v1.2.5/clink.1.2.5.5dd017.zip"
}, },
{ {
"name": "conemu-maximus5", "name": "conemu-maximus5",