Change theme again for fish #fishshell

This commit is contained in:
Colin Powell
2019-02-25 21:57:53 -05:00
parent 48d42c55a2
commit 94ed6c7705
4 changed files with 58 additions and 151 deletions

View File

@ -2,6 +2,4 @@ edc/bass
jethrokuan/fzf
2m/fish-gpg-tty
oh-my-fish/plugin-direnv
oh-my-fish/theme-scorphish
oh-my-fish/theme-default
oh-my-fish/theme-qing
oh-my-fish/theme-idan

View File

@ -9,5 +9,5 @@
#
function fish_greeting -d "what's up, fish?"
bash (dirname (status -f))/archey.sh
bash (dirname (status -f))/archey.sh
end

View File

@ -1,60 +1,54 @@
# name: cyan
set -g cyan (set_color 33FFFF)
set -g yellow (set_color CCFF00)
set -g red (set_color -o red)
set -g green (set_color -o green)
set -g white (set_color -o white)
set -g blue (set_color -o blue)
set -g magenta (set_color -o magenta)
set -g normal (set_color normal)
set -g purple (set_color -o purple)
# name: idan
# Display the following bits on the left:
# * Virtualenv name (if applicable, see https://github.com/adambrenecki/virtualfish)
# * Current directory name
# * Git branch and dirty state (if inside a git repo)
set -g FISH_GIT_PROMPT_EQUAL_REMOTE "$magenta=$normal"
set -g FISH_GIT_PROMPT_AHEAD_REMOTE "$magenta>$normal"
set -g FISH_GIT_PROMPT_BEHIND_REMOTE "$magenta<$normal"
set -g FISH_GIT_PROMPT_DIVERGED_REMOTE "$red<>$normal"
function _git_branch_name -d "Display current branch's name"
function _git_branch_name
echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||')
end
function _git_short_sha -d "Display short hash"
echo (command git rev-parse --short HEAD 2> /dev/null)
end
function _git_ahead -d "git repository is ahead or behind origin"
set -l commits (command git rev-list --left-right '@{upstream}...HEAD' 2> /dev/null)
if [ $status != 0 ]
return
end
set -l behind (count (for arg in $commits; echo $arg; end | grep '^<'))
set -l ahead (count (for arg in $commits; echo $arg; end | grep -v '^<'))
switch "$ahead $behind"
case '' # no upstream
echo ""
case '0 0' # equal to upstream
echo "$FISH_GIT_PROMPT_EQUAL_REMOTE"
case '* 0' # ahead of upstream
echo "$FISH_GIT_PROMPT_AHEAD_REMOTE"
case '0 *' # behind upstream
echo "$FISH_GIT_PROMPT_BEHIND_REMOTE"
case '*' # diverged from upstream
echo "$FISH_GIT_PROMPT_DIVERGED_REMOTE"
end
function _is_git_dirty
echo (command git status -s --ignore-submodules=dirty 2> /dev/null)
end
function fish_prompt
set -l cwd $green(basename (prompt_pwd))
if [ (command git rev-parse --git-dir 2> /dev/null) ]
set -l git_branch $yellow(_git_branch_name)
set -l git_sha $magenta(_git_short_sha)$normal
set -l git_branch_ahead (_git_ahead)
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 git_info "$green($git_branch#$normal$git_sha$green)$normal $git_branch_ahead"
set -l cwd $cyan(basename (prompt_pwd))
# output the prompt, left to right
# Add a newline before prompts
echo -e ""
# Display [venvname] if in a virtualenv
if set -q VIRTUAL_ENV
echo -n -s (set_color -b cyan black) '[' (basename "$VIRTUAL_ENV") ']' $normal ' '
end
# Display the current directory name
echo -n -s $cwd $normal
# Show git branch and dirty state
if [ (_git_branch_name) ]
set -l git_branch '(' (_git_branch_name) ')'
if [ (_is_git_dirty) ]
set git_info $red $git_branch " ★ "
else
set git_info $green $git_branch
end
echo -n -s ' · ' $git_info $normal
end
# Terminate with a nice prompt char
echo -n -s ' ⟩ ' $normal
echo -n -s $normal $cyan (whoami) '@' $normal $blue (hostname -s) $normal ' ' $cwd ' ' $git_info $yellow' ✗ '$normal
end

View File

@ -1,102 +1,17 @@
# Colors vary depending on time lapsed.
set -g FISH_GIT_TIME_SINCE_COMMIT_SHORT (set_color -o green)
set -g FISH_GIT_TIME_SHORT_COMMIT_MEDIUM (set_color -o yellow)
set -g FISH_GIT_TIME_SINCE_COMMIT_LONG (set_color CC0000)
set -g FISH_GIT_TIME_SINCE_COMMIT_NEUTRAL (set_color -o cyan)
set -g normal (set_color normal)
set -g cyan (set_color 33FFFF)
set -g yellow (set_color -o yellow)
set -g red (set_color CC0000)
set -g green (set_color -o green)
set -g white (set_color -o white)
set -g blue (set_color -o blue)
set -g magenta (set_color -o magenta)
set -g normal (set_color normal)
set -g purple (set_color -o purple)
set -g FISH_GIT_PROMPT_ADDED "$green$normal"
set -g FISH_GIT_PROMPT_MODIFIED "$blue""M""$normal"
set -g FISH_GIT_PROMPT_DELETED "$red$normal"
set -g FISH_GIT_PROMPT_RENAMED "$magenta$normal"
set -g FISH_GIT_PROMPT_UNMERGED "$yellow$normal"
set -g FISH_GIT_PROMPT_UNTRACKED "$cyan$normal"
set -g FISH_GIT_PROMPT_CLEAN "$green$normal"
function _git_status -d "git repo status about Untracked, new file and so on."
if [ (command git rev-parse --git-dir 2> /dev/null) ]
if [ (command git status | grep -c "working directory clean") -eq 1 ]
echo "$FISH_GIT_PROMPT_CLEAN"
else
if [ (command git status | grep -c "Untracked files:") -ne 0 ]
set output $FISH_GIT_PROMPT_UNTRACKED
end
if [ (command git status | grep -c "new file:") -ne 0 ]
set output "$output $FISH_GIT_PROMPT_ADDED"
end
if [ (command git status | grep -c "renamed:") -ne 0 ]
set output "$output $FISH_GIT_PROMPT_RENAMED"
end
if [ (command git status | grep -c "modified:") -ne 0 ]
set output "$output $FISH_GIT_PROMPT_MODIFIED"
end
if [ (command git status | grep -c "deleted:") -ne 0 ]
set output "$output $FISH_GIT_PROMPT_DELETED"
end
echo $output
end
end
end
function _git_time_since_commit -d "Display the time since last commit"
if [ (command git rev-parse --git-dir 2> /dev/null) ]
# Only proceed if there is actually a commit.
if [ (command git log 2>&1 > /dev/null | grep -c "^fatal:") -eq 0 ]
# Get the last commit.
set last_commit (command git log --pretty=format:'%at' -1 2> /dev/null)
set now (command date +%s)
set seconds_since_last_commit (math "$now-$last_commit")
# Totals
set MINUTES (math "$seconds_since_last_commit / 60")
set HOURS (math "$seconds_since_last_commit/3600")
# Sub-hours and sub-minutes
set DAYS (math "$seconds_since_last_commit / 86400")
set SUB_HOURS (math "$HOURS % 24")
set SUB_MINUTES (math "$MINUTES % 60")
if git status -s > /dev/null
if [ "$MINUTES" -gt 30 ]
set COLOR $FISH_GIT_TIME_SINCE_COMMIT_LONG
else if [ "$MINUTES" -gt 10 ]
set COLOR $FISH_GIT_TIME_SHORT_COMMIT_MEDIUM
else
set COLOR $FISH_GIT_TIME_SINCE_COMMIT_SHORT
end
else
set COLOR $ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
end
if [ "$HOURS" -gt 24 ]
echo "[$COLOR$DAYS""d""$SUB_HOURS""h""$SUB_MINUTES""m""$normal]"
else if [ "$MINUTES" -gt 60 ]
echo "[$COLOR$HOURS""h""$SUB_MINUTES""m""$normal]"
else
echo "[$COLOR$MINUTES""m""$normal]"
end
else
set COLOR $FISH_GIT_TIME_SINCE_COMMIT_NEUTRAL
echo "[$COLOR~$normal]"
end
end
end
# Display the compressed current working path on the right
# If the previous command returned any kind of error code, display that too
function fish_right_prompt
set -l git_info (_git_time_since_commit)
set -l git_status (_git_status)
set -l last_status $status
set -l cyan (set_color -o cyan)
set -l red (set_color -o red)
set -l normal (set_color normal)
set git_info "$git_info$git_status"
echo -n -s $git_info
echo -n -s $cyan (prompt_pwd)
if test $last_status -ne 0
set_color red
printf ' %d' $last_status
set_color normal
end
end