Add Fossil branch to fish prompt
Also prefer Git over Fossil branch instead of showing both in zsh.
This commit is contained in:
parent
bb3d7920de
commit
fd9e04a090
2 changed files with 10 additions and 11 deletions
|
@ -9,8 +9,13 @@ function fish_prompt --description 'Write out the prompt'
|
||||||
|
|
||||||
set -l branch (git symbolic-ref HEAD 2>/dev/null)
|
set -l branch (git symbolic-ref HEAD 2>/dev/null)
|
||||||
set branch (string replace -r "^refs/heads/" "" $branch)
|
set branch (string replace -r "^refs/heads/" "" $branch)
|
||||||
|
|
||||||
|
if test -z "$branch"
|
||||||
|
set branch (fossil branch current)
|
||||||
|
end
|
||||||
|
|
||||||
set -l vcs
|
set -l vcs
|
||||||
if test -n "$branch" -a "$branch" != "master"
|
if test -n "$branch"
|
||||||
set vcs (set_color $fish_color_vcs_braces)"(" \
|
set vcs (set_color $fish_color_vcs_braces)"(" \
|
||||||
(set_color $fish_color_vcs)"$branch" \
|
(set_color $fish_color_vcs)"$branch" \
|
||||||
(set_color $fish_color_vcs_braces)")"
|
(set_color $fish_color_vcs_braces)")"
|
||||||
|
|
14
zshrc
14
zshrc
|
@ -99,17 +99,11 @@ set_prompt
|
||||||
__precmd() {
|
__precmd() {
|
||||||
__update_terminal_cwd
|
__update_terminal_cwd
|
||||||
|
|
||||||
local branch=""
|
local branch=$(git symbolic-ref HEAD 2>/dev/null)
|
||||||
|
branch=${branch##refs/heads/}
|
||||||
|
|
||||||
local fossil_branch=$(fossil branch current 2>/dev/null)
|
if [ -z "$branch" ]; then
|
||||||
if [ -n "$fossil_branch" ]; then
|
branch=$(fossil branch current 2>/dev/null)
|
||||||
branch="$branch${branch:+ }f:$fossil_branch"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local git_branch=$(git symbolic-ref HEAD 2>/dev/null)
|
|
||||||
git_branch=${git_branch##refs/heads/}
|
|
||||||
if [ -n "$git_branch" ]; then
|
|
||||||
branch="$branch${branch:+ }g:$git_branch"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set_prompt $branch
|
set_prompt $branch
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue