Skip to content

Instantly share code, notes, and snippets.

@wapiflapi
Created February 20, 2015 21:11
Show Gist options
  • Save wapiflapi/3ed6d649c4165b64040d to your computer and use it in GitHub Desktop.
Save wapiflapi/3ed6d649c4165b64040d to your computer and use it in GitHub Desktop.
my fish prompt
# name: wapiflapi
function _git_branch_name
command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||'
end
function _git_repo_name
basename (git rev-parse --show-toplevel ^/dev/null) ^/dev/null
end
function fish_prompt
set -l last_status "$status"
set -l jobs (count (jobs))
set -l error (set_color -o red)
set -l info (set_color -o blue)
set -l usual (set_color -o green)
set -l normal (set_color normal)
if test "$last_status" != 0
set color "$error"
else if test "$jobs" != 0
set color "$info"
else
set color "$usual"
end
echo " $color➜$normal "
end
function fish_right_prompt
set -l last_status "$status"
set -l jobs (count (jobs))
set -l git_branch (_git_branch_name)
set -l git_repo (_git_repo_name)
set -l critical (set_color -o red)
set -l error (set_color red)
set -l info (set_color blue)
set -l usual (set_color green)
set -l dark (set_color -o black)
set -l light (set_color -o white)
set -l normal (set_color normal)
if [ "$git_branch" = "master" ]
set branch_str "$dark/$git_branch"
else if [ "$git_branch" != "" ]
set branch_str "$light/$git_branch"
else
set branch_str "$dark"(prompt_pwd)
end
if test "$last_status" -gt 192
set status_str "$critical"(math "$last_status"-256)" "
else if test "$last_status" -gt 128
set status_str "$critical"SIG(math "$last_status"-128)" "
else if test "$last_status" -gt 0
set status_str "$error$last_status "
end
if test "$jobs" != 0
set jobs_str "$info$jobs$dark "
end
echo "$status_str$jobs_str$dark$git_repo$branch_str$normal "
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment