Created
April 8, 2014 20:59
-
-
Save wkf/10191345 to your computer and use it in GitHub Desktop.
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
# name: wkf | |
# agnoster's Theme - https://gist.github.com/3712874 | |
# A Powerline-inspired theme for FISH | |
# | |
# # README | |
# | |
# In order for this theme to render correctly, you will need a | |
# [Powerline-patched font](https://gist.github.com/1595572). | |
## Set this options in your config.fish (if you want to :]) | |
# set -g theme_display_user yes | |
# set -g default_user your_normal_user | |
set -g current_bg NONE | |
set segment_separator \uE0B0 | |
set right_segment_separator \uE0B0 | |
# =========================== | |
# Helper methods | |
# =========================== | |
set -g __fish_git_prompt_showdirtystate 'yes' | |
set -g __fish_git_prompt_char_dirtystate '●' | |
set -g __fish_git_prompt_char_cleanstate '' | |
function parse_git_dirty | |
set -l submodule_syntax | |
set submodule_syntax "--ignore-submodules=dirty" | |
set git_dirty (command git status -s $submodule_syntax 2> /dev/null) | |
if [ -n "$git_dirty" ] | |
if [ $__fish_git_prompt_showdirtystate = "yes" ] | |
echo -n "$__fish_git_prompt_char_dirtystate" | |
end | |
else | |
if [ $__fish_git_prompt_showdirtystate = "yes" ] | |
echo -n "$__fish_git_prompt_char_cleanstate" | |
end | |
end | |
end | |
# =========================== | |
# Segments functions | |
# =========================== | |
function prompt_segment -d "Function to draw a segment" | |
set -l bg | |
set -l fg | |
if [ -n "$argv[1]" ] | |
set bg $argv[1] | |
else | |
set bg normal | |
end | |
if [ -n "$argv[2]" ] | |
set fg $argv[2] | |
else | |
set fg normal | |
end | |
set_color -b $bg | |
set_color $fg | |
if [ -n "$argv[3]" ] | |
echo -n -s $argv[3] | |
end | |
end | |
function prompt_finish -d "Close open segments" | |
set_color -b normal | |
echo -n -s | |
end | |
# =========================== | |
# Theme components | |
# =========================== | |
function prompt_dir -d "Display the actual directory" | |
set -l root_path | |
set -l root_name | |
if command git rev-parse --is-inside-work-tree >/dev/null 2>&1 | |
set root_path (command git rev-parse --show-toplevel 2> /dev/null) | |
set root_name (basename $root_path) | |
set root_path (echo $root_path | sed -e 's/\//\\\\\//g') | |
prompt_segment normal "#404040" (echo $root_name(pwd | sed -e "s/$root_path//g")) | |
else | |
prompt_segment normal "#404040" (prompt_pwd) | |
end | |
end | |
function prompt_git -d "Display the actual git branch" | |
set -l ref | |
set -l dirty | |
if command git rev-parse --is-inside-work-tree >/dev/null 2>&1 | |
prompt_segment normal "#404040" "|" | |
set ref (command git symbolic-ref HEAD 2> /dev/null) | |
if [ $status -gt 0 ] | |
set -l branch (command git show-ref --head -s --abbrev |head -n1 2> /dev/null) | |
set ref "$branch " | |
end | |
set -l branch (echo $ref | sed "s-refs/heads/--") | |
set dirty (parse_git_dirty) | |
if [ "$dirty" != "" ] | |
prompt_segment normal yellow "$branch" | |
else | |
prompt_segment normal "#404040" "$branch" | |
end | |
end | |
end | |
function prompt_status -d "Display the actual git state" | |
#echo -n $vi_mode | |
prompt_segment normal "#404040" "> " | |
#prompt_segment normal purple "λ " | |
#prompt_segment normal "#404040" ":" | |
end | |
# =========================== | |
# Apply theme | |
# =========================== | |
function fish_prompt | |
prompt_status | |
prompt_finish | |
end | |
function fish_right_prompt | |
prompt_dir | |
prompt_git | |
prompt_finish | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment