mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 05:37:36 +08:00
feat: add support for fossil-scm in prompt (#9500)
* feat: add support for fossil-scm in prompt * fix: change directory testing and string matching
This commit is contained in:
parent
d239e26f6b
commit
cf67709931
53
share/functions/fish_fossil_prompt.fish
Normal file
53
share/functions/fish_fossil_prompt.fish
Normal file
|
@ -0,0 +1,53 @@
|
|||
function fish_fossil_prompt --description 'Write out the fossil prompt'
|
||||
# Bail if fossil is not available
|
||||
if not command -sq fossil
|
||||
return 1
|
||||
end
|
||||
|
||||
# Bail if not a fossil checkout
|
||||
if not fossil ls &> /dev/null
|
||||
return 127
|
||||
end
|
||||
|
||||
# Parse fossil info
|
||||
set -l fossil_info (fossil info)
|
||||
string match --regex --quiet \
|
||||
'^project-name:\s*(?<fossil_project_name>.*)$' $fossil_info
|
||||
string match --regex --quiet \
|
||||
'^tags:\s*(?<fossil_tags>.*)$' $fossil_info
|
||||
|
||||
echo -n ' ['
|
||||
set_color --bold magenta
|
||||
echo -n $fossil_project_name
|
||||
set_color normal
|
||||
echo -n ':'
|
||||
set_color --bold yellow
|
||||
echo -n $fossil_tags
|
||||
set_color normal
|
||||
|
||||
# Parse fossil status
|
||||
set -l fossil_status (fossil status)
|
||||
if string match --quiet 'ADDED*' $fossil_status
|
||||
set_color --bold green
|
||||
echo -n '+'
|
||||
end
|
||||
if string match --quiet 'DELETED*' $fossil_status
|
||||
set_color --bold red
|
||||
echo -n '-'
|
||||
end
|
||||
if string match --quiet 'MISSING*' $fossil_status
|
||||
set_color --bold red
|
||||
echo -n '!'
|
||||
end
|
||||
if string match --quiet 'RENAMED*' $fossil_status
|
||||
set_color --bold yellow
|
||||
echo -n '→'
|
||||
end
|
||||
if string match --quiet 'CONFLICT*' $fossil_status
|
||||
set_color --bold green
|
||||
echo -n '×'
|
||||
end
|
||||
|
||||
set_color normal
|
||||
echo -n ']'
|
||||
end
|
|
@ -3,6 +3,7 @@ function fish_vcs_prompt --description "Print all vcs prompts"
|
|||
# This is so we don't try svn if git already worked.
|
||||
fish_git_prompt $argv
|
||||
or fish_hg_prompt $argv
|
||||
or fish_fossil_prompt $argv
|
||||
# The svn prompt is disabled by default because it's quite slow on common svn repositories.
|
||||
# To enable it uncomment it.
|
||||
# You can also only use it in specific directories by checking $PWD.
|
||||
|
|
Loading…
Reference in New Issue
Block a user