diff --git a/fish/.config/fish/functions/fish_prompt.fish b/fish/.config/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..d45ff6b --- /dev/null +++ b/fish/.config/fish/functions/fish_prompt.fish @@ -0,0 +1,36 @@ +function __bcarlin_prompt_suffix + set -l color_suffix + set -l suffix "➜" + + switch $USER + case root toor + if set -q fish_color_cwd_root + echo root if + set color_suffix $fish_color_cwd_root + else + set color_suffix $fish_color_cwd + end + case '*' + set color_suffix $fish_color_cwd + end + + echo -n -s (set_color $color_suffix --bold) "$suffix" (set_color normal) +end + +function __bcarlin_prompt_git + set -l git_branch (git rev-parse --abbrev-ref HEAD) + if test $status -ne 0 + echo -n -s '' + return + end + + echo -n -s (set_color blue) ± (set_color normal) '(' + echo -n -s (set_color red --bold) $git_branch (set_color normal) + echo -n -s ')' +end + +function fish_prompt --description 'Write out the prompt' + set -l _pwd (set_color $fish_color_cwd) (prompt_pwd) + + echo -n -s "$USER" @ (prompt_hostname) ' ' $_pwd ' ' (__bcarlin_prompt_git) ' ' (__bcarlin_prompt_suffix) ' ' +end