|
@@ -1,31 +1,119 @@
|
|
-# name: Krisleech
|
|
|
|
-function _git_branch_name
|
|
|
|
- echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||')
|
|
|
|
|
|
+# Status Chars
|
|
|
|
+set __fish_git_prompt_char_dirtystate '!'
|
|
|
|
+set __fish_git_prompt_char_untrackedfiles '☡'
|
|
|
|
+set __fish_git_prompt_char_stashstate '↩'
|
|
|
|
+set __fish_git_prompt_char_cleanstate '✓'
|
|
|
|
+
|
|
|
|
+# Display the state of the branch when inside of a git repo
|
|
|
|
+function __simple_ass_prompt_parse_git_branch_state -d "Display the state of the branch"
|
|
|
|
+ git update-index --really-refresh -q 1> /dev/null
|
|
|
|
+
|
|
|
|
+ # Check for changes to be commited
|
|
|
|
+ if git_is_touched
|
|
|
|
+ echo -n "$__fish_git_prompt_char_dirtystate"
|
|
|
|
+ else
|
|
|
|
+ echo -n "$__fish_git_prompt_char_cleanstate"
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ # Check for untracked files
|
|
|
|
+ set -l git_untracked (command git ls-files --others --exclude-standard 2> /dev/null)
|
|
|
|
+ if [ -n "$git_untracked" ]
|
|
|
|
+ echo -n "$__fish_git_prompt_char_untrackedfiles"
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ # Check for stashed files
|
|
|
|
+ if git_is_stashed
|
|
|
|
+ echo -n "$__fish_git_prompt_char_stashstate"
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ # Check if branch is ahead, behind or diverged of remote
|
|
|
|
+ git_ahead
|
|
|
|
+end
|
|
|
|
+
|
|
|
|
+# Display current git branch
|
|
|
|
+function __simple_ass_prompt_git -d "Display the actual git branch"
|
|
|
|
+ set -l ref
|
|
|
|
+ set -l std_prompt (prompt_pwd)
|
|
|
|
+ set -l is_dot_git (string match '*/.git' $std_prompt)
|
|
|
|
+
|
|
|
|
+ if git_is_repo; and test -z $is_dot_git
|
|
|
|
+ printf 'on '
|
|
|
|
+ set_color purple
|
|
|
|
+
|
|
|
|
+ set -l git_branch (command git symbolic-ref --quiet --short HEAD 2> /dev/null; or git rev-parse --short HEAD 2> /dev/null; or echo -n '(unknown)')
|
|
|
|
+
|
|
|
|
+ printf '%s ' $git_branch
|
|
|
|
+
|
|
|
|
+ set state (__simple_ass_prompt_parse_git_branch_state)
|
|
|
|
+ set_color 0087ff
|
|
|
|
+ printf '[%s]' $state
|
|
|
|
+
|
|
|
|
+ set_color normal
|
|
|
|
+ end
|
|
|
|
+end
|
|
|
|
+
|
|
|
|
+# Print current user
|
|
|
|
+function __simple_ass_prompt_get_user -d "Print the user"
|
|
|
|
+ if test $USER = 'root'
|
|
|
|
+ set_color red
|
|
|
|
+ else
|
|
|
|
+ set_color d75f00
|
|
|
|
+ end
|
|
|
|
+ printf '%s' (whoami)
|
|
|
|
+end
|
|
|
|
+
|
|
|
|
+# Get Machines Hostname
|
|
|
|
+function __simple_ass_prompt_get_host -d "Get Hostname"
|
|
|
|
+ if test $SSH_TTY
|
|
|
|
+ tput bold
|
|
|
|
+ set_color red
|
|
|
|
+ else
|
|
|
|
+ set_color af8700
|
|
|
|
+ end
|
|
|
|
+ printf '%s' (hostname|cut -d . -f 1)
|
|
end
|
|
end
|
|
|
|
|
|
-function _is_git_dirty
|
|
|
|
- echo (command git status -s --ignore-submodules=dirty 2> /dev/null)
|
|
|
|
|
|
+# Get Project Working Directory
|
|
|
|
+function __simple_ass_prompt_pwd -d "Get PWD"
|
|
|
|
+ set_color $fish_color_cwd
|
|
|
|
+ printf '%s ' (prompt_pwd)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
+# Simple-ass-prompt
|
|
function fish_prompt
|
|
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 green (set_color -o green)
|
|
|
|
- set -l normal (set_color normal)
|
|
|
|
|
|
+ set -l code $status
|
|
|
|
+
|
|
|
|
+ # Logged in user
|
|
|
|
+ __simple_ass_prompt_get_user
|
|
|
|
+ set_color normal
|
|
|
|
+ printf ' at '
|
|
|
|
+
|
|
|
|
+ # Machine logged in to
|
|
|
|
+ __simple_ass_prompt_get_host
|
|
|
|
+ set_color normal
|
|
|
|
+ printf ' in '
|
|
|
|
+
|
|
|
|
+ # Path
|
|
|
|
+ __simple_ass_prompt_pwd
|
|
|
|
+ set_color normal
|
|
|
|
|
|
- set -l cwd $cyan(basename (prompt_pwd))
|
|
|
|
|
|
+ # Git info
|
|
|
|
+ __simple_ass_prompt_git
|
|
|
|
|
|
- if [ (_git_branch_name) ]
|
|
|
|
- set -l git_branch (_git_branch_name)
|
|
|
|
- set git_info "$green$git_branch "
|
|
|
|
|
|
+ # Line 2
|
|
|
|
+ echo
|
|
|
|
+ if test -e "Cargo.toml"
|
|
|
|
+ printf "(rust:%s) " (set_color red)(rustup show | tail -n 3 | head -n 1 | cut -d '-' -f 1)(set_color normal)
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ if test $VIRTUAL_ENV
|
|
|
|
+ printf "(python:%s) " (set_color blue)(basename $VIRTUAL_ENV)(set_color normal)
|
|
|
|
+ end
|
|
|
|
|
|
- if [ (_is_git_dirty) ]
|
|
|
|
- set -l dirty "$yellow✗"
|
|
|
|
- set git_info "$git_info$dirty"
|
|
|
|
- end
|
|
|
|
|
|
+ if test $code -eq 127
|
|
|
|
+ set_color red
|
|
end
|
|
end
|
|
|
|
|
|
- echo -n -s $cwd $red '|' $git_info $normal ⇒ ' ' $normal
|
|
|
|
|
|
+ printf '↪ '
|
|
|
|
+ set_color normal
|
|
end
|
|
end
|