mirror of
https://github.com/ViViDboarder/shoestrap.git
synced 2024-11-22 04:56:30 +00:00
Update fish prompt
Adding lots of good stuff for colors and host names
This commit is contained in:
parent
618a2b1b83
commit
a58a9a3496
@ -1,13 +1,24 @@
|
|||||||
# name: RobbyRussel
|
# name: ifij (forked from RobbyRussel)
|
||||||
#
|
#
|
||||||
# You can override some default options in your config.fish:
|
# You can override some default options in your config.fish:
|
||||||
# set -g theme_display_git_untracked no
|
# set -g theme_display_git_untracked no
|
||||||
|
|
||||||
|
function _status_color
|
||||||
|
# Returns a color for successful or failed previous command
|
||||||
|
if test $last_status -eq 0
|
||||||
|
echo (set_color -o green)
|
||||||
|
else
|
||||||
|
echo (set_color -o red)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function _git_branch_name
|
function _git_branch_name
|
||||||
|
# Returns the name of the current git branch
|
||||||
echo (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
|
echo (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
|
||||||
end
|
end
|
||||||
|
|
||||||
function _is_git_dirty
|
function _is_git_dirty
|
||||||
|
# Returns whether or not there is anything uncommitted
|
||||||
set -l show_untracked (git config --bool bash.showUntrackedFiles)
|
set -l show_untracked (git config --bool bash.showUntrackedFiles)
|
||||||
set untracked ''
|
set untracked ''
|
||||||
if [ "$theme_display_git_untracked" = 'no' -o "$show_untracked" = 'false' ]
|
if [ "$theme_display_git_untracked" = 'no' -o "$show_untracked" = 'false' ]
|
||||||
@ -16,16 +27,43 @@ function _is_git_dirty
|
|||||||
echo (command git status -s --ignore-submodules=dirty $untracked ^/dev/null)
|
echo (command git status -s --ignore-submodules=dirty $untracked ^/dev/null)
|
||||||
end
|
end
|
||||||
|
|
||||||
function _prompt_char
|
function _git_info
|
||||||
if [ (whoami) = 'root' ]
|
# Returns what is to be displayed for the git info
|
||||||
echo '#'
|
if [ (_git_branch_name) ]
|
||||||
|
if [ (_is_git_dirty) ]
|
||||||
|
set branch_color (set_color -o red)
|
||||||
else
|
else
|
||||||
echo '$'
|
set branch_color (set_color -o yellow)
|
||||||
|
end
|
||||||
|
set -l git_branch (_git_branch_name)
|
||||||
|
echo " $branch_color($git_branch)"(set_color normal)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function _hostname
|
||||||
|
# Returns the hostname if not using tmux since tmux will display
|
||||||
|
if [ -z $TMUX ]
|
||||||
|
echo (hostname)" "
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _prompt_char
|
||||||
|
# Gives a colored prompt char for user or root
|
||||||
|
echo -n (_status_color)
|
||||||
|
if [ (whoami) = 'root' ]
|
||||||
|
echo -n '#'
|
||||||
|
else
|
||||||
|
echo -n '$'
|
||||||
|
end
|
||||||
|
echo -n (set_color normal)
|
||||||
|
end
|
||||||
|
|
||||||
function fish_prompt
|
function fish_prompt
|
||||||
set -l last_status $status
|
# Build full left side prompt
|
||||||
|
|
||||||
|
# NOTE: this becomes a global variable
|
||||||
|
set -g last_status $status
|
||||||
|
|
||||||
set -l cyan (set_color -o cyan)
|
set -l cyan (set_color -o cyan)
|
||||||
set -l yellow (set_color -o yellow)
|
set -l yellow (set_color -o yellow)
|
||||||
set -l red (set_color -o red)
|
set -l red (set_color -o red)
|
||||||
@ -33,23 +71,9 @@ function fish_prompt
|
|||||||
set -l green (set_color -o green)
|
set -l green (set_color -o green)
|
||||||
set -l normal (set_color normal)
|
set -l normal (set_color normal)
|
||||||
|
|
||||||
if test $last_status = 0
|
set -l arrow (_status_color) "➜ $normal"
|
||||||
set arrow "$green➜ "
|
set -l cwd (basename (prompt_pwd))
|
||||||
else
|
|
||||||
set arrow "$red➜ "
|
|
||||||
end
|
|
||||||
set -l cwd $normal(basename (prompt_pwd))
|
|
||||||
|
|
||||||
if [ (_git_branch_name) ]
|
echo -n -s $arrow (_hostname) $cwd (_git_info) (_prompt_char) ' '
|
||||||
if [ (_is_git_dirty) ]
|
|
||||||
set branch_color "$red"
|
|
||||||
else
|
|
||||||
set branch_color "$yellow"
|
|
||||||
end
|
|
||||||
set -l git_branch (_git_branch_name)
|
|
||||||
set git_info " $branch_color($git_branch)"
|
|
||||||
end
|
|
||||||
|
|
||||||
echo -n -s $arrow $cwd $git_info $normal (_prompt_char) ' '
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user