mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-03-15 17:16:20 +08:00
New theme: budspencer
This commit is contained in:
parent
599f29f47c
commit
d200937d06
41
themes/budspencer/README.md
Normal file
41
themes/budspencer/README.md
Normal file
@ -0,0 +1,41 @@
|
||||
# budspencer theme
|
||||
|
||||
Translation of zsh's prezto [budspencer theme][budspencer]
|
||||
|
||||
## Left prompt segments
|
||||
|
||||
- Vi mode indicator
|
||||
- Git repository information
|
||||
- Status symbols
|
||||
* V: vi is parent process
|
||||
* R: [ranger][ranger] is parent process
|
||||
* ⚙: there are background jobs
|
||||
* : no write permissions in present working directory
|
||||
* ✔: last command succeeded
|
||||
* ✘: last command failed
|
||||
* ⚡: superuser indicator
|
||||
|
||||
## Right prompt segments
|
||||
- Git status symbols
|
||||
* ↑: git repository is ahead origin
|
||||
* ↓: git repository is behind origin
|
||||
* +: new files added
|
||||
* –: files deleted
|
||||
* ✱: files have changed
|
||||
* ●: uncommited changes
|
||||
* ✭: commits stashed
|
||||
- Present working directory
|
||||
* style can be toggled in NORMAL mode with space bar
|
||||
* styles implemented:
|
||||
- `short` (show truncated path)
|
||||
- `long` (show full path)
|
||||
- `none` (show nothing)
|
||||
* configurable by global array `$PWDSTYLE` (defaults to `short long none`)
|
||||
|
||||
### TODO:
|
||||
- elapsed time indicator
|
||||
- host/username indicator for ssh connections
|
||||
- vi REPLACE mode
|
||||
|
||||
[budspencer]: https://github.com/tannhuber/prezto
|
||||
[ranger]: http://ranger.nongnu.org/
|
165
themes/budspencer/fish_prompt.fish
Normal file
165
themes/budspencer/fish_prompt.fish
Normal file
@ -0,0 +1,165 @@
|
||||
# TODO: color definitions
|
||||
# name: budspencer
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Utils
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
set -g __budspencer_display_rprompt 1
|
||||
|
||||
function __budspencer_git_branch_name -d "Return the current branch name"
|
||||
echo (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
|
||||
end
|
||||
|
||||
function fish_vi_prompt_cm --description "Displays the current mode"
|
||||
switch $fish_bind_mode
|
||||
case default
|
||||
set_color -b blue 000
|
||||
echo -n " NORMAL "
|
||||
set_color -b 000 blue
|
||||
case insert
|
||||
set_color -b yellow 000
|
||||
echo -n " INSERT "
|
||||
set_color -b 000 yellow
|
||||
case visual
|
||||
set_color -b magenta 000
|
||||
echo -n " VISUAL "
|
||||
set_color -b 000 magenta
|
||||
end
|
||||
end
|
||||
|
||||
function fish_prompt_symbols --description "Display symbols"
|
||||
set_color -o -b 073642
|
||||
echo -n ""
|
||||
# indicator for vim parent process
|
||||
if set -q -x VIM
|
||||
set_color 6c71c4
|
||||
echo -n " V"
|
||||
end
|
||||
# indicator for ranger parent process
|
||||
if set -q -x RANGER_LEVEL
|
||||
set_color 6c71c4
|
||||
echo -n " R"
|
||||
end
|
||||
# background job indicator
|
||||
if [ (jobs | wc -l) -gt 0 ]
|
||||
set_color 6c71c4
|
||||
echo -n " ⚙"
|
||||
end
|
||||
# write protection indicator
|
||||
if [ ! -w . ]
|
||||
set_color cb4b16
|
||||
echo -n " "
|
||||
end
|
||||
# status indicator
|
||||
if [ $last_status -eq 0 ]
|
||||
set_color green
|
||||
echo -n " ✔"
|
||||
else
|
||||
set_color red
|
||||
echo -n " ✘"
|
||||
end
|
||||
# superuser indicator
|
||||
if [ $USER = "root" ]
|
||||
set_color cb4b16
|
||||
echo -n " ⚡"
|
||||
end
|
||||
echo -n " "
|
||||
set_color -b normal 073642
|
||||
end
|
||||
# ----------------------------------------------------------------------------
|
||||
# Prompts
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
function fish_prompt -d "Write out the left prompt of the budspencer theme"
|
||||
set -g last_status $status
|
||||
set -l basedir_name (basename (prompt_pwd))
|
||||
|
||||
# Init colors
|
||||
|
||||
set -l fcol_black (set_color 000000)
|
||||
set -l fcol_base03 (set_color 002b36)
|
||||
set -l fcol_base02 (set_color 073642)
|
||||
set -l fcol_base01 (set_color 586e75)
|
||||
set -l fcol_base00 (set_color 657b83)
|
||||
set -l fcol_base0 (set_color 839496)
|
||||
set -l fcol_base1 (set_color 93a1a1)
|
||||
set -l fcol_base2 (set_color eee8d5)
|
||||
set -l fcol_base3 (set_color fdf6e3)
|
||||
set -l fcol_yellow (set_color b58900)
|
||||
set -l fcol_orange (set_color cb4b16)
|
||||
set -l fcol_red (set_color red)
|
||||
set -l fcol_magenta (set_color d33682)
|
||||
set -l fcol_violet (set_color 6c71c4)
|
||||
set -l fcol_blue (set_color 268bd2)
|
||||
set -l fcol_cyan (set_color 2aa198)
|
||||
set -l fcol_green (set_color 859900)
|
||||
set -l bcol_base03 (set_color -b 002b36)
|
||||
set -l bcol_base02 (set_color -b 073642)
|
||||
set -l bcol_base01 (set_color -b 586e75)
|
||||
set -l bcol_base00 (set_color -b 657b83)
|
||||
set -l bcol_base0 (set_color -b 839496)
|
||||
set -l bcol_base1 (set_color -b 93a1a1)
|
||||
set -l bcol_base2 (set_color -b eee8d5)
|
||||
set -l bcol_base3 (set_color -b fdf6e3)
|
||||
set -l bcol_yellow (set_color -b b58900)
|
||||
set -l bcol_orange (set_color -b cb4b16)
|
||||
set -l bcol_red (set_color -b red)
|
||||
set -l bcol_magenta (set_color -b d33682)
|
||||
set -l bcol_violet (set_color -b 6c71c4)
|
||||
set -l bcol_blue (set_color -b 268bd2)
|
||||
set -l bcol_cyan (set_color -b 2aa198)
|
||||
set -l bcol_green (set_color -b 859900)
|
||||
|
||||
# Segments
|
||||
|
||||
# vi mode
|
||||
# If vi_mode plugin or native vi mode is activated then print the vi mode
|
||||
# in the prompt.
|
||||
set -l ps_vi ""
|
||||
# if test -n "$vi_mode"
|
||||
# set ps_vi $colnormal"["$vi_mode$colnormal"]"
|
||||
# end
|
||||
if test "$fish_key_bindings" = "fish_vi_key_bindings" -o "$fish_key_bindings" = "my_fish_key_bindings"
|
||||
set ps_vi (fish_vi_prompt_cm)
|
||||
end
|
||||
|
||||
# git
|
||||
# If inside a git repo then the pwd segment is replaced by the git
|
||||
# segment.
|
||||
# The git segment format is X:YI@Z:P(N) where:
|
||||
# X is git
|
||||
# Y is the current branch
|
||||
# I is the information about the current repo state
|
||||
# Z is the name of the repo
|
||||
# P is the current working path basename (name of the current directory)
|
||||
# C is the depth of the path starting from base directory of the repo
|
||||
# The displayed information is:
|
||||
# Dirtiness is indicated by a little dot after the branch name.
|
||||
# Unpushed commits are indicated with up arrows
|
||||
# The number of unpushed commits is indicated right after the up arrows
|
||||
# If P = Z then P(C) is not displayed
|
||||
set -l ps_git ""
|
||||
set -l git_branch_name (__budspencer_git_branch_name)
|
||||
if test -n "$git_branch_name"
|
||||
# set -l git_repo_name (__budspencer_git_repo_name)
|
||||
# if test -n (__budspencer_is_git_dirty)
|
||||
# set git_info $git_info$colbred"·"
|
||||
# end
|
||||
set ps_git $bcol_base01 "" $fcol_black " "$git_branch_name" " $fcol_base01 #"@"$colbred$git_repo_name
|
||||
# if test "$basedir_name" != "$git_repo_name"
|
||||
# set -l basedir_depth (echo (__budspencer_git_repo_base) | sed "s/\// /g" | wc -w)
|
||||
# set -l depth (echo (pwd) | sed "s/\// /g" | wc -w)
|
||||
# set depth (math $depth - $basedir_depth)
|
||||
# set ps_git $ps_git$colbwhite":"$colbgreen$basedir_name$colnormal"("$depth")"
|
||||
# end
|
||||
end
|
||||
|
||||
set -l ps_symbols (fish_prompt_symbols)
|
||||
|
||||
# Left Prompt
|
||||
|
||||
echo -n -s $ps_vi $ps_git $ps_symbols '' ' '
|
||||
end
|
||||
|
||||
|
159
themes/budspencer/fish_right_prompt.fish
Normal file
159
themes/budspencer/fish_right_prompt.fish
Normal file
@ -0,0 +1,159 @@
|
||||
# TODO: color definitions
|
||||
# TODO: elapsed time segment
|
||||
# TODO: configurable pwd_style
|
||||
|
||||
function __budspencer_is_git_ahead -d "Check if there are unpushed commits"
|
||||
echo (command git status -s -b ^/dev/null | grep ahead)
|
||||
end
|
||||
|
||||
function __budspencer_is_git_behind -d "Check if there are unpushed commits"
|
||||
echo (command git status -s -b ^/dev/null | grep behind)
|
||||
end
|
||||
|
||||
function __budspencer_is_git_added -d "Check if there are added files"
|
||||
echo (command git status -s -b ^/dev/null | grep "^A")
|
||||
end
|
||||
|
||||
function __budspencer_is_git_deleted -d "Check if there are deleted files"
|
||||
echo (command git status -s -b ^/dev/null | grep "^.D")
|
||||
end
|
||||
|
||||
function __budspencer_is_git_changed -d "Check if there are changed files"
|
||||
echo (command git status -s -b ^/dev/null | grep "^.M")
|
||||
end
|
||||
|
||||
function __budspencer_is_git_uncomitted -d "Check if there are uncommited changes"
|
||||
echo (command git status -s -b ^/dev/null | grep "^??")
|
||||
end
|
||||
|
||||
function __budspencer_is_git_stashed -d "Check if there are stashed commits"
|
||||
echo (command git stash list ^/dev/null)
|
||||
end
|
||||
|
||||
if set -q -x $PWDSTYLE
|
||||
set -x PWDSTYLE short long none
|
||||
end
|
||||
set pwd_style $PWDSTYLE[1]
|
||||
function fish_pwd_toggle_cm --description "Toggles style of pwd segment, press space bar in NORMAL mode"
|
||||
for i in (seq 1 (count $PWDSTYLE))
|
||||
if test $PWDSTYLE[$i] = $pwd_style
|
||||
set pwd_style $PWDSTYLE[(math $i%(count $PWDSTYLE)+1)]
|
||||
commandline -f repaint
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
bind -M default ' ' fish_pwd_toggle_cm
|
||||
|
||||
function fish_pwd_prompt_cm --description "Displays the present working directory"
|
||||
switch $fish_bind_mode
|
||||
case default
|
||||
set_color blue
|
||||
echo -n ""
|
||||
set_color normal
|
||||
set_color --background blue 000
|
||||
case insert
|
||||
set_color yellow
|
||||
echo -n ""
|
||||
set_color normal
|
||||
set_color --background yellow 000
|
||||
case visual
|
||||
set_color magenta
|
||||
echo -n ""
|
||||
set_color normal
|
||||
set_color --background magenta 000
|
||||
end
|
||||
switch $pwd_style
|
||||
case none
|
||||
echo -n ' '
|
||||
case short
|
||||
echo -n ' '(prompt_pwd)' '
|
||||
case long
|
||||
echo -n ' '$PWD' ' # | sed "s|$HOME|~|"
|
||||
end
|
||||
set_color normal
|
||||
end
|
||||
|
||||
function fish_right_prompt -d "Write out the right prompt of the budspencer theme"
|
||||
# Init colors
|
||||
|
||||
set -l fcol_black (set_color 000000)
|
||||
set -l fcol_base03 (set_color -o 002b36)
|
||||
set -l fcol_base02 (set_color -o 073642)
|
||||
set -l fcol_base01 (set_color -o 586e75)
|
||||
set -l fcol_base00 (set_color -o 657b83)
|
||||
set -l fcol_base0 (set_color -o 839496)
|
||||
set -l fcol_base1 (set_color -o 93a1a1)
|
||||
set -l fcol_base2 (set_color -o eee8d5)
|
||||
set -l fcol_base3 (set_color -o fdf6e3)
|
||||
set -l fcol_yellow (set_color -o b58900)
|
||||
set -l fcol_orange (set_color -o cb4b16)
|
||||
set -l fcol_red (set_color -o red)
|
||||
set -l fcol_magenta (set_color -o d33682)
|
||||
set -l fcol_violet (set_color -o 6c71c4)
|
||||
set -l fcol_blue (set_color -o 268bd2)
|
||||
set -l fcol_blue (set_color -o 268bd2)
|
||||
set -l fcol_cyan (set_color -o 2aa198)
|
||||
set -l fcol_green (set_color -o 859900)
|
||||
set -l bcol_base03 (set_color -b 002b36)
|
||||
set -l bcol_base02 (set_color -b 073642)
|
||||
set -l bcol_base01 (set_color -b 586e75)
|
||||
set -l bcol_base00 (set_color -b 657b83)
|
||||
set -l bcol_base0 (set_color -b 839496)
|
||||
set -l bcol_base1 (set_color -b 93a1a1)
|
||||
set -l bcol_base2 (set_color -b eee8d5)
|
||||
set -l bcol_base3 (set_color -b fdf6e3)
|
||||
set -l bcol_yellow (set_color -b b58900)
|
||||
set -l bcol_orange (set_color -b cb4b16)
|
||||
set -l bcol_red (set_color -b dc322f)
|
||||
set -l bcol_magenta (set_color -b d33682)
|
||||
set -l bcol_violet (set_color -b 6c71c4)
|
||||
set -l bcol_blue (set_color -b 268bd2)
|
||||
set -l bcol_cyan (set_color -b 2aa198)
|
||||
set -l bcol_green (set_color -b 859900)
|
||||
|
||||
# Segments
|
||||
|
||||
# git
|
||||
set -l ps_git ""
|
||||
if test -n (__budspencer_is_git_ahead)
|
||||
set ps_git $fcol_yellow" ↑"
|
||||
end
|
||||
|
||||
if test -n (__budspencer_is_git_behind)
|
||||
set ps_git $ps_git$fcol_yellow" ↓"
|
||||
end
|
||||
|
||||
if test -n (__budspencer_is_git_added)
|
||||
set ps_git $ps_git$fcol_green" +"
|
||||
end
|
||||
|
||||
if test -n (__budspencer_is_git_deleted)
|
||||
set ps_git $ps_git$fcol_red" –"
|
||||
end
|
||||
|
||||
if test -n (__budspencer_is_git_changed)
|
||||
set ps_git $ps_git$fcol_blue" ✱"
|
||||
end
|
||||
|
||||
if test -n (__budspencer_is_git_uncomitted)
|
||||
set ps_git $ps_git$fcol_base3" ●"
|
||||
end
|
||||
|
||||
if test -n (__budspencer_is_git_stashed)
|
||||
set ps_git $ps_git$fcol_cyan" ✭"
|
||||
end
|
||||
|
||||
if test -n "$ps_git"
|
||||
set ps_git $fcol_base02""$bcol_base02""$ps_git
|
||||
end
|
||||
|
||||
# pwd
|
||||
set -l ps_pwd ""
|
||||
if test "$fish_key_bindings" = "fish_vi_key_bindings" -o "$fish_key_bindings" = "my_fish_key_bindings"
|
||||
set ps_pwd (fish_pwd_prompt_cm)
|
||||
end
|
||||
|
||||
echo -n $ps_git $ps_pwd
|
||||
set_color normal
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user