Here’s a simple function I wrote for the fish shell to show the current git branch name in the titlebar, along with an asterisk if there are any local changes.
function fish_title
# Show Git branch if inside a repo
if git rev-parse --is-inside-work-tree >/dev/null 2>&1
set branch (git symbolic-ref --short HEAD 2>/dev/null | string trim)
set dirty ""
set git_status (git status --porcelain 2>/dev/null | string trim)
if test -n "$git_status"
set dirty " *"
end
echo "$branch$dirty"
end
end
Leave a comment