mirror of
https://github.com/cmderdev/cmder.git
synced 2025-02-11 07:59:07 +08:00
Add branchonly option to cmdstatus
This commit is contained in:
parent
36f4ce0e3c
commit
c262934822
@ -194,10 +194,11 @@ You can write `*.cmd|*.bat`, `*.ps1`, and `*.sh` scripts and just drop them in t
|
|||||||
|
|
||||||
```
|
```
|
||||||
[cmder]
|
[cmder]
|
||||||
status = false # Opt out of Git status for 'ALL' Cmder supported shells.
|
status = false # Opt out of Git status for 'ALL' Cmder supported shells.
|
||||||
cmdstatus = false # Opt out of Git status for 'Cmd.exe' shells.
|
cmdstatus = false # Opt out of Git status for 'Cmd.exe' shells.
|
||||||
psstatus = false # Opt out of Git status for 'Powershell.exe and 'Pwsh.exe' shells.
|
cmdstatus = branchonly # Show branch name in 'Cmd.exe' shells, but don't color according to status (faster)
|
||||||
shstatus = false # Opt out of Git status for 'bash.exe' shells.
|
psstatus = false # Opt out of Git status for 'Powershell.exe and 'Pwsh.exe' shells.
|
||||||
|
shstatus = false # Opt out of Git status for 'bash.exe' shells.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Aliases
|
### Aliases
|
||||||
|
53
vendor/clink.lua
vendored
53
vendor/clink.lua
vendored
@ -41,6 +41,10 @@ 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()
|
||||||
|
return unknown_color or "\x1b[30;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
|
||||||
---
|
---
|
||||||
@ -361,27 +365,29 @@ end
|
|||||||
|
|
||||||
---
|
---
|
||||||
-- Get the status of working dir
|
-- Get the status of working dir
|
||||||
-- @return {bool}
|
-- @return {bool|'branchonly'}
|
||||||
---
|
---
|
||||||
local function get_git_status_setting()
|
local function get_git_status_setting()
|
||||||
local gitStatusConfig = io.popen("git --no-pager config cmder.status 2>nul")
|
local gitCmdStatusConfig = io.popen("git --no-pager config cmder.cmdstatus 2>nul")
|
||||||
|
for line in gitCmdStatusConfig:lines() do
|
||||||
|
if string.match(line, 'false') then
|
||||||
|
gitCmdStatusConfig:close()
|
||||||
|
return false
|
||||||
|
elseif string.match(line, 'branchonly') then
|
||||||
|
gitCmdStatusConfig:close()
|
||||||
|
return 'branchonly'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
gitCmdStatusConfig:close()
|
||||||
|
|
||||||
|
local gitStatusConfig = io.popen("git --no-pager config cmder.status 2>nul")
|
||||||
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")
|
|
||||||
for line in gitCmdStatusConfig:lines() do
|
|
||||||
if string.match(line, 'false') then
|
|
||||||
gitCmdStatusConfig:close()
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
gitStatusConfig:close()
|
gitStatusConfig:close()
|
||||||
gitCmdStatusConfig:close()
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -392,7 +398,8 @@ local function git_prompt_filter()
|
|||||||
local colors = {
|
local colors = {
|
||||||
clean = get_clean_color(),
|
clean = get_clean_color(),
|
||||||
dirty = get_dirty_color(),
|
dirty = get_dirty_color(),
|
||||||
conflict = get_conflict_color()
|
conflict = get_conflict_color(),
|
||||||
|
unknown = get_unknown_color()
|
||||||
}
|
}
|
||||||
|
|
||||||
local git_dir = get_git_dir()
|
local git_dir = get_git_dir()
|
||||||
@ -403,17 +410,21 @@ local function git_prompt_filter()
|
|||||||
local branch = get_git_branch(git_dir)
|
local branch = get_git_branch(git_dir)
|
||||||
local color
|
local color
|
||||||
if branch then
|
if branch then
|
||||||
-- Has branch => therefore it is a git folder, now figure out status
|
if cmderGitStatusOptIn ~= 'branchonly' then
|
||||||
local gitStatus = get_git_status()
|
-- Has branch => therefore it is a git folder, now figure out status
|
||||||
local gitConflict = get_git_conflict()
|
local gitStatus = get_git_status()
|
||||||
|
local gitConflict = get_git_conflict()
|
||||||
|
|
||||||
color = colors.dirty
|
color = colors.dirty
|
||||||
if gitStatus then
|
if gitStatus then
|
||||||
color = colors.clean
|
color = colors.clean
|
||||||
end
|
end
|
||||||
|
|
||||||
if gitConflict then
|
if gitConflict then
|
||||||
color = colors.conflict
|
color = colors.conflict
|
||||||
|
end
|
||||||
|
else
|
||||||
|
color = colors.unknown
|
||||||
end
|
end
|
||||||
|
|
||||||
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")")
|
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")")
|
||||||
|
1
vendor/cmder_prompt_config.lua.default
vendored
1
vendor/cmder_prompt_config.lua.default
vendored
@ -43,3 +43,4 @@ lamb_color = "\x1b[1;30;40m" -- Light Grey = Lambda Color
|
|||||||
clean_color = "\x1b[1;37;40m"
|
clean_color = "\x1b[1;37;40m"
|
||||||
dirty_color = "\x1b[33;3m"
|
dirty_color = "\x1b[33;3m"
|
||||||
conflict_color = "\x1b[31;1m"
|
conflict_color = "\x1b[31;1m"
|
||||||
|
unknown_color = "\x1b[30;1m"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user