restructure repo

This commit is contained in:
pika 2024-05-21 09:19:50 +02:00
parent 6348678015
commit ff921c9292
14 changed files with 281 additions and 298 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,3 @@
function __bobthefish_display_colors -d 'Print example prompts using the current color scheme'
bobthefish_display_colors
end

View file

@ -0,0 +1,99 @@
function __bobthefish_glyphs -S -d 'Define glyphs used by bobthefish'
# Powerline glyphs
set -x branch_glyph \uE0A0
set -x right_black_arrow_glyph \uE0B0
set -x right_arrow_glyph \uE0B1
set -x left_black_arrow_glyph \uE0B2
set -x left_arrow_glyph \uE0B3
# Additional glyphs
set -x detached_glyph \u27A6
set -x tag_glyph \u2302
set -x nonzero_exit_glyph '! '
set -x private_glyph \uE0A2 ' '
set -x superuser_glyph '$ '
set -x bg_job_glyph '% '
set -x hg_glyph \u263F
# Python glyphs
set -x superscript_glyph \u00B9 \u00B2 \u00B3
set -x virtualenv_glyph \u25F0
set -x pypy_glyph \u1D56
set -x ruby_glyph ''
set -x go_glyph ''
set -x nix_glyph ''
# Desk glyphs
set -x desk_glyph \u25F2
# Kubernetes glyphs
set -x k8s_glyph \u2388 # '⎈'
# Vagrant glyphs
set -x vagrant_running_glyph \u2191 # ↑ 'running'
set -x vagrant_poweroff_glyph \u2193 # ↓ 'poweroff'
set -x vagrant_aborted_glyph \u2715 # ✕ 'aborted'
set -x vagrant_saved_glyph \u21E1 # ⇡ 'saved'
set -x vagrant_stopping_glyph \u21E3 # ⇣ 'stopping'
set -x vagrant_unknown_glyph '!' # strange cases
# Git glyphs
set -x git_dirty_glyph '*'
set -x git_staged_glyph '~'
set -x git_stashed_glyph '$'
set -x git_untracked_glyph '…'
set -x git_ahead_glyph \u2191 # '↑'
set -x git_behind_glyph \u2193 # '↓'
set -x git_plus_glyph '+'
set -x git_minus_glyph '-'
set -x git_plus_minus_glyph '±'
# Disable Powerline fonts (unless we're using nerd fonts instead)
if [ "$theme_powerline_fonts" = "no" -a "$theme_nerd_fonts" != "yes" ]
set private_glyph \u29B8 ' '
set branch_glyph \u2387
set right_black_arrow_glyph ''
set right_arrow_glyph ''
set left_black_arrow_glyph ''
set left_arrow_glyph ''
end
# Use prettier Nerd Fonts glyphs
if [ "$theme_nerd_fonts" = "yes" ]
set private_glyph \uF023 ' ' # nf-fa-lock
set branch_glyph \uF418
set detached_glyph \uF417
set tag_glyph \uF412
set nix_glyph \uF313 ' ' # nf-linux-nixos
set virtualenv_glyph \uE73C ' '
set ruby_glyph \uE791 ' '
set go_glyph \uE626 ' '
set node_glyph \uE718 ' '
set vagrant_running_glyph \uF431 # ↑ 'running'
set vagrant_poweroff_glyph \uF433 # ↓ 'poweroff'
set vagrant_aborted_glyph \uF468 # ✕ 'aborted'
set vagrant_unknown_glyph \uF421 # strange cases
set git_dirty_glyph \uF448 '' # nf-oct-pencil
set git_staged_glyph \uF0C7 '' # nf-fa-save
set git_stashed_glyph \uF0C6 '' # nf-fa-paperclip
set git_untracked_glyph \uF128 '' # nf-fa-question
# set git_untracked_glyph \uF141 '' # nf-fa-ellipsis_h
set git_ahead_glyph \uF47B # nf-oct-chevron_up
set git_behind_glyph \uF47C # nf-oct-chevron_down
set git_plus_glyph \uF0DE # fa-sort-asc
set git_minus_glyph \uF0DD # fa-sort-desc
set git_plus_minus_glyph \uF0DC # fa-sort
end
# Avoid ambiguous glyphs
if [ "$theme_avoid_ambiguous_glyphs" = "yes" ]
set git_untracked_glyph '...'
end
end

View file

@ -0,0 +1,170 @@
function bobthefish_display_colors -a color_scheme -d 'Print example prompt color schemes'
set -l color_schemes default light \
solarized solarized-light \
base16 base16-light \
gruvbox gruvbox-light zenburn \
dracula nord \
catppuccin-latte catppuccin-frappe \
catppuccin-macchiato catppuccin-mocha \
jellybeans \
terminal terminal-dark-white \
terminal-light terminal-light-black \
terminal2 terminal2-dark-white \
terminal2-light terminal2-light-black
switch "$color_scheme"
case '--all'
for scheme in $color_schemes
echo
echo "$scheme:"
bobthefish_display_colors $scheme
end
return
case $color_schemes
__bobthefish_colors $color_scheme
case ''
if type -q bobthefish_colors
if [ -n "$theme_color_scheme" ]
echo "$theme_color_scheme (with bobthefish_colors overrides):"
else
echo 'custom (via bobthefish_colors):'
end
else if [ -n "$theme_color_scheme" ]
echo "$theme_color_scheme:"
end
__bobthefish_colors $theme_color_scheme
type -q bobthefish_colors
and bobthefish_colors
case '*'
echo 'usage: bobthefish_display_colors [--all] [color_scheme]'
return
end
__bobthefish_glyphs
echo
set_color normal
__bobthefish_start_segment $color_initial_segment_exit
echo -n exit $nonzero_exit_glyph
set_color -b $color_initial_segment_private
echo -n private $private_glyph
set_color -b $color_initial_segment_su
echo -n su $superuser_glyph
set_color -b $color_initial_segment_jobs
echo -n jobs $bg_job_glyph
__bobthefish_finish_segments
set_color normal
echo -n "(<- initial_segment)"
echo
__bobthefish_start_segment $color_path
echo -n /color/path/
set_color -b $color_path_basename
echo -ns basename ' '
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_path_nowrite
echo -n /color/path/nowrite/
set_color -b $color_path_nowrite_basename
echo -ns basename ' '
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_path
echo -n /color/path/
set_color -b $color_path_basename
echo -ns basename ' '
__bobthefish_start_segment $color_repo
echo -n "$branch_glyph repo $git_stashed_glyph "
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_path
echo -n /color/path/
set_color -b $color_path_basename
echo -ns basename ' '
__bobthefish_start_segment $color_repo_dirty
echo -n "$tag_glyph repo_dirty $git_dirty_glyph "
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_path
echo -n /color/path/
set_color -b $color_path_basename
echo -ns basename ' '
__bobthefish_start_segment $color_repo_staged
echo -n "$detached_glyph repo_staged $git_staged_glyph "
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_vi_mode_default
echo -ns vi_mode_default ' '
__bobthefish_finish_segments
__bobthefish_start_segment $color_vi_mode_insert
echo -ns vi_mode_insert ' '
__bobthefish_finish_segments
__bobthefish_start_segment $color_vi_mode_visual
echo -ns vi_mode_visual ' '
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_vagrant
echo -ns $vagrant_running_glyph ' ' vagrant ' '
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_username
echo -n username
set_color normal
set_color -b $color_hostname[1] $color_hostname[2..-1]
echo -ns @hostname ' '
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_screen
echo -ns 'screen '
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_rvm
echo -ns $ruby_glyph rvm ' '
__bobthefish_finish_segments
__bobthefish_start_segment $color_nvm
echo -ns $ruby_glyph nvm ' '
__bobthefish_finish_segments
__bobthefish_start_segment $color_virtualfish
echo -ns $virtualenv_glyph virtualfish ' '
__bobthefish_finish_segments
__bobthefish_start_segment $color_virtualgo
echo -ns $go_glyph virtualgo ' '
__bobthefish_finish_segments
__bobthefish_start_segment $color_desk
echo -ns $desk_glyph desk ' '
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_aws_vault
echo -ns aws-vault ' (' active ') '
__bobthefish_finish_segments
__bobthefish_start_segment $color_aws_vault_expired
echo -ns aws-vault ' (' expired ') '
__bobthefish_finish_segments
__bobthefish_start_segment $color_k8s
echo -ns $k8s_glyph ' k8s-context'
__bobthefish_finish_segments
echo -e "\n"
end

View file

@ -0,0 +1,42 @@
# Display the current binding mode... if it's vi or vi-like.
#
# To always show the binding mode (regardless of current bindings):
# set -g theme_display_vi yes
#
# To never show:
# set -g theme_display_vi no
function fish_mode_prompt -d 'bobthefish-optimized fish mode indicator'
[ "$theme_display_vi" != 'no' ]
or return
[ "$fish_key_bindings" = 'fish_vi_key_bindings' \
-o "$fish_key_bindings" = 'hybrid_bindings' \
-o "$fish_key_bindings" = 'fish_hybrid_key_bindings' \
-o "$theme_display_vi" = 'yes' ]
or return
__bobthefish_colors $theme_color_scheme
type -q bobthefish_colors
and bobthefish_colors
set_color normal # clear out anything bold or underline...
switch $fish_bind_mode
case default
set_color -b $color_vi_mode_default
echo -n ' N '
case insert
set_color -b $color_vi_mode_insert
echo -n ' I '
case replace_one replace-one
set_color -b $color_vi_mode_insert
echo -n ' R '
case visual
set_color -b $color_vi_mode_visual
echo -n ' V '
end
set_color normal
end

1263
functions/fish_prompt.fish Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,80 @@
# See "Right prompt options" in README.md for configuration options
function __bobthefish_cmd_duration -S -d 'Show command duration'
[ "$theme_display_cmd_duration" = "no" ]
and return
[ -z "$CMD_DURATION" -o "$CMD_DURATION" -lt 100 ]
and return
if [ "$CMD_DURATION" -lt 5000 ]
echo -ns $CMD_DURATION 'ms'
else if [ "$CMD_DURATION" -lt 60000 ]
__bobthefish_pretty_ms $CMD_DURATION s
else if [ "$CMD_DURATION" -lt 3600000 ]
set_color $fish_color_error
__bobthefish_pretty_ms $CMD_DURATION m
else
set_color $fish_color_error
__bobthefish_pretty_ms $CMD_DURATION h
end
set_color $fish_color_normal
set_color $fish_color_autosuggestion
[ "$theme_display_date" = "no" ]
or echo -ns ' ' $__bobthefish_left_arrow_glyph
end
function __bobthefish_pretty_ms -S -a ms -a interval -d 'Millisecond formatting for humans'
set -l interval_ms
set -l scale 1
switch $interval
case s
set interval_ms 1000
case m
set interval_ms 60000
case h
set interval_ms 3600000
set scale 2
end
switch $FISH_VERSION
case 2.0.\* 2.1.\* 2.2.\* 2.3.\*
# Fish 2.3 and lower doesn't know about the -s argument to math.
math "scale=$scale;$ms/$interval_ms" | string replace -r '\\.?0*$' $interval
case 2.\*
# Fish 2.x always returned a float when given the -s argument.
math -s$scale "$ms/$interval_ms" | string replace -r '\\.?0*$' $interval
case \*
math -s$scale "$ms/$interval_ms"
echo -ns $interval
end
end
function __bobthefish_timestamp -S -d 'Show the current timestamp'
[ "$theme_display_date" = "no" ]
and return
set -q theme_date_format
or set -l theme_date_format "+%T"
echo -n ' '
set -q theme_date_timezone
and env TZ="$theme_date_timezone" date $theme_date_format
or date $theme_date_format
end
function fish_right_prompt -d 'bobthefish is all about the right prompt'
set -l __bobthefish_left_arrow_glyph \uE0B3
if [ "$theme_powerline_fonts" = "no" -a "$theme_nerd_fonts" != "yes" ]
set __bobthefish_left_arrow_glyph '<'
end
set_color $fish_color_autosuggestion
__bobthefish_cmd_duration
__bobthefish_timestamp
set_color normal
end

30
functions/fish_title.fish Normal file
View file

@ -0,0 +1,30 @@
# See "Title options" in README.md for configuration options
function __bobthefish_title_user -S -d 'Display actual user if different from $default_user'
if [ "$theme_title_display_user" = 'yes' ]
if [ "$USER" != "$default_user" -o -n "$SSH_CLIENT" ]
set -l IFS .
uname -n | read -l host __
echo -ns (whoami) '@' $host ' '
end
end
end
function fish_title
__bobthefish_title_user
if [ "$theme_title_display_process" = 'yes' ]
status current-command
[ "$theme_title_display_path" != 'no' ]
and echo ' '
end
if [ "$theme_title_display_path" != 'no' ]
if [ "$theme_title_use_abbreviated_path" = 'no' ]
echo $PWD
else
prompt_pwd
end
end
end

4
functions/tools.fish Normal file
View file

@ -0,0 +1,4 @@
function tools
echo $TOOLBOX
end