Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
dotfiles/fish/.config/fish/functions/fish_prompt.fish
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
62 lines (53 sloc)
1.49 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fish_prompt | |
# simple root prompt | |
if [ $USER = root ] | |
printf '%s[root] %s%s %s➜ ' \ | |
(set_color -o red)\ | |
(set_color -o blue) (pwd)\ | |
(set_color -o red) | |
return | |
end | |
if not set -q -g __prompt_helpers_defined | |
set -g __prompt_helpers_defined | |
function _git_branch_name | |
echo (git rev-parse --symbolic-full-name --abbrev-ref HEAD ^/dev/null) | |
end | |
function _is_git_dirty | |
echo (git status -s --ignore-submodules=dirty ^/dev/null) | |
end | |
end | |
set -l cyan (set_color -o cyan) | |
set -l yellow (set_color -o yellow) | |
set -l red (set_color -o red) | |
set -l blue (set_color -o blue) | |
set -l green (set_color -o green) | |
set -l normal (set_color normal) | |
set -l grey (set_color dddddd) | |
if [ (_git_branch_name) ] | |
set -l branch_color $normal | |
if [ (_is_git_dirty) ] | |
set branch_color $red | |
end | |
set -l git_branch $branch_color(_git_branch_name) | |
set git_info "$blue (git:$branch_color$git_branch$blue)" | |
end | |
if set -q -g VIRTUAL_ENV | |
set -l ve_tag (basename "$VIRTUAL_ENV") | |
set vex_info "$blue (venv:$normal$ve_tag$blue)" | |
end | |
if test -e "Cargo.toml"; | |
set -l c (set_color -o blue) | |
set -l toolchain (rustup_prompt_helper) | |
set multirust " $c(rust:$normal$toolchain$c)" | |
end | |
set -l arrow " $red➜$normal " | |
set -l cwd $blue(basename (prompt_pwd)) | |
set -l time $grey(date +"%H:%M") | |
printf '%s %s%s%s%s%s' \ | |
$time \ | |
$cwd \ | |
$multirust \ | |
$vex_info \ | |
$git_info \ | |
$arrow | |
end |