diff --git a/share/functions/__terlar_git_prompt.fish b/share/functions/__terlar_git_prompt.fish new file mode 100644 index 000000000..93df408f1 --- /dev/null +++ b/share/functions/__terlar_git_prompt.fish @@ -0,0 +1,76 @@ +set -gx fish_color_git_clean green +set -gx fish_color_git_dirty red +set -gx fish_color_git_ahead red +set -gx fish_color_git_staged yellow + +set -gx fish_color_git_added green +set -gx fish_color_git_modified blue +set -gx fish_color_git_renamed magenta +set -gx fish_color_git_deleted red +set -gx fish_color_git_unmerged yellow +set -gx fish_color_git_untracked cyan + +set -gx fish_prompt_git_status_added '✚' +set -gx fish_prompt_git_status_modified '*' +set -gx fish_prompt_git_status_renamed '➜' +set -gx fish_prompt_git_status_deleted '✖' +set -gx fish_prompt_git_status_unmerged '═' +set -gx fish_prompt_git_status_untracked '.' + +function __terlar_git_prompt --description 'Write out the git prompt' + set -l branch (git symbolic-ref --quiet --short HEAD 2>/dev/null) + if test -z $branch + return + end + + echo -n '|' + + set -l index (git status --porcelain 2>/dev/null) + if test -z "$index" + set_color $fish_color_git_clean + printf $branch'✓' + set_color normal + return + end + + git diff-index --quiet --cached HEAD 2>/dev/null + set -l staged $status + if test $staged = 1 + set_color $fish_color_git_staged + else + set_color $fish_color_git_dirty + end + + printf $branch'⚡' + + set -l info + for i in $index + switch $i + case 'A *' + set i added + case 'M *' ' M *' + set i modified + case 'R *' + set i renamed + case 'D *' ' D *' + set i deleted + case 'U *' + set i unmerged + case '?? *' + set i untracked + end + + if not contains $i $info + set info $info $i + end + end + + for i in added modified renamed deleted unmerged untracked + if contains $i $info + eval 'set_color $fish_color_git_'$i + eval 'printf $fish_prompt_git_status_'$i + end + end + + set_color normal +end diff --git a/share/tools/web_config/sample_prompts/robbyrussell.fish b/share/tools/web_config/sample_prompts/robbyrussell.fish new file mode 100644 index 000000000..2493f7662 --- /dev/null +++ b/share/tools/web_config/sample_prompts/robbyrussell.fish @@ -0,0 +1,33 @@ +# name: Robbyrussell +# author: Bruno Ferreira Pinto + +function _git_branch_name + echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||') +end + +function _is_git_dirty + echo (git status -s --ignore-submodules=dirty ^/dev/null) +end + +function fish_prompt + 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 normal (set_color normal) + + set -l arrow "$red➜ " + set -l cwd $cyan(basename (prompt_pwd)) + + if [ (_git_branch_name) ] + set -l git_branch $red(_git_branch_name) + set git_info "$blue git:($git_branch$blue)" + + if [ (_is_git_dirty) ] + set -l dirty "$yellow ✗" + set git_info "$git_info$dirty" + end + end + + echo -n -s $arrow $cwd $git_info $normal '>' +end diff --git a/share/tools/web_config/sample_prompts/terlar.fish b/share/tools/web_config/sample_prompts/terlar.fish new file mode 100644 index 000000000..e2697b964 --- /dev/null +++ b/share/tools/web_config/sample_prompts/terlar.fish @@ -0,0 +1,39 @@ +# name: Terlar +# author: terlar - https://github.com/terlar + +set -xg fish_color_user magenta +set -xg fish_color_host yellow + +function fish_prompt --description 'Write out the prompt' + set -l last_status $status + + # User + set_color $fish_color_user + printf (whoami) + set_color normal + + echo -n '@' + + # Host + set_color $fish_color_host + printf (hostname -s) + set_color normal + + echo -n ':' + + # PWD + set_color $fish_color_cwd + printf (prompt_pwd) + set_color normal + + __terlar_git_prompt + # I prefer to have a new-line here but messes with the prompt when resizing + echo + + if not test $last_status -eq 0 + set_color $fish_color_error + end + + echo -n '➤ ' + set_color normal +end diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index 02d8e3633..965832ce0 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -224,6 +224,7 @@ def ansi_to_html(val): if result[idx] == '' and result[idx-1].startswith('