From 1da4a614e0e274303d1721bcad188ff868ab8d26 Mon Sep 17 00:00:00 2001 From: pika Date: Sun, 12 May 2024 21:11:56 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=AB=A5=20initial=20commit=20-=20fish-conf?= =?UTF-8?q?ig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dotfiles/.config/fish/config.fish | 275 ++++ dotfiles/.config/fish/fish_variables | 76 + .../fish/functions/__bobthefish_colors.fish | 1102 ++++++++++++++ .../__bobthefish_display_colors.fish | 3 + .../fish/functions/__bobthefish_glyphs.fish | 99 ++ .../functions/bobthefish_display_colors.fish | 170 +++ .../fish/functions/fish_mode_prompt.fish | 42 + .../.config/fish/functions/fish_prompt.fish | 1263 +++++++++++++++++ .../fish/functions/fish_right_prompt.fish | 80 ++ .../.config/fish/functions/fish_title.fish | 30 + 10 files changed, 3140 insertions(+) create mode 100644 dotfiles/.config/fish/config.fish create mode 100644 dotfiles/.config/fish/fish_variables create mode 100644 dotfiles/.config/fish/functions/__bobthefish_colors.fish create mode 100644 dotfiles/.config/fish/functions/__bobthefish_display_colors.fish create mode 100644 dotfiles/.config/fish/functions/__bobthefish_glyphs.fish create mode 100644 dotfiles/.config/fish/functions/bobthefish_display_colors.fish create mode 100644 dotfiles/.config/fish/functions/fish_mode_prompt.fish create mode 100644 dotfiles/.config/fish/functions/fish_prompt.fish create mode 100644 dotfiles/.config/fish/functions/fish_right_prompt.fish create mode 100644 dotfiles/.config/fish/functions/fish_title.fish diff --git a/dotfiles/.config/fish/config.fish b/dotfiles/.config/fish/config.fish new file mode 100644 index 0000000..98d01d3 --- /dev/null +++ b/dotfiles/.config/fish/config.fish @@ -0,0 +1,275 @@ +if status is-interactive + # Commands to run in interactive sessions can go here +end + +# __ _ __ _ _ +# / _(_) / _(_) | | +# ___ ___ _ __ | |_ _ __ _ | |_ _ ___| |__ +# / __/ _ \| '_ \| _| |/ _` | | _| / __| '_ \ +# | (_| (_) | | | | | | | (_| |_| | | \__ \ | | | +# \___\___/|_| |_|_| |_|\__, (_)_| |_|___/_| |_| +# __/ | +# |___/ +# _ ___ _ _ +# | | / _ \| | | +# | |__ _ _ / /_\ \ | | ___ _____ ____ __ +# | '_ \| | | | | _ | | |/ _ \/ _ \ \/ /\ \/ / +# | |_) | |_| | | | | | | | __/ __/> < > < +# |_.__/ \__, | \_| |_/_|_|\___|\___/_/\_\/_/\_\ +# __/ | +# |___/ + + +# +# Environment-Variables +set fish_greeting +set toolbox "The following tools are active: + +" +set warnings "The following packages are NOT active: + +" + +set -p EDITOR (which nvim) + +## Set Distro-Packagemanager-Aliases + +# DNF - Fedora +if command -v dnf + alias install='sudo dnf install' + alias update='sudo dnf update && sudo dnf upgrade' + alias search='sudo dnf search' + alias remove='sudo dnf remove' + set -a ALIASSES "-- You're using DNF aliases!! --" +end + +# APT/NALA - Debian +if command -v nala + alias install='sudo nala update && sudo nala install' + alias update='sudo nala update && sudo nala upgrade' + alias search='nala search' + alias remove='sudo nala remove' + set ALIASSES "-- You're using NALA aliases!! --" + else +if command -v apt + alias install='sudo apt update && sudo apt install' + alias update='sudo apt update && sudo apt upgrade' + alias search='apt search' + alias remove='sudo apt remove' + set ALIASSES "-- You're using APT aliases!! --" +end +end + +# Pacman - Arch +if command -v yay + alias install='yay -S' + alias update='yay -Syu' + alias search='yay -Ss' + alias remove='yay -R' + set ALIASSES "-- You're using Arch!! - installed helper: yay --" +else +if command -v paru + alias install='paru -S' + alias update='paru -Syu' + alias search='paru -Ss' + alias remove='paru -R' + set ALIASSES "-- You're using Arch!! - installed helper: paru --" +else + if command -v pacman + alias install='sudo pacman -S' + alias update='sudo pacman -Syu' + alias remove='sudo pacman -R' + set ALIASSES "-- by the PACMAN - You're using Arch!! --" +end +end +end + +# Zypper - OpenSuse +if command -v zypper + alias install='sudo zypper in' + alias update='sudo zypper dup' + alias search='sudo zypper se' + alias lock='sudo zypper al' + alias remove='sudo zypper rm' + set ALIASSES "-- I see.. you're using OpenSUSE. i like <3 -- + ZYPPER " +end + +# APK - Alpine +if command -v apk + alias install='sudo apk add' + alias update='sudo apk update' + alias search='sudo apk search' + set ALIASSES "-- Alpine.. right, this fast os is evolving.. --" +end + +## END Distro-Packagemanager-Aliases + +# OMF - Oh-My-Fish +#if test -d "$HOME/.config/omf/" +# omf update +# alias rl='omf reload' +# set -a fish_greed "Oh-my-FiSh installed and activated" +#end + +#colorized ls +if command -v lsd + alias ls='lsd -l' + alias ll='pwd && lsd -lA && pwd' + alias tree='lsd --tree' + set -a toolbox "  using $(which lsd) for ls + " +else +if command -v exa + alias ls='exa --icons -l' + alias ll='exa --icons -laa' + alias tree='exa --icons -l -tree' + set -a toolbox "  using $(which exa) for ls + " +else +if command -v eza + alias ls='eza --icons -l' + alias ll='eza --icons -laa' + alias tree='eza --icons -l -tree' + set -a toolbox "  using $(which eza) for ls + " +else + alias ls='ls --color=always -lph' + alias ll='ls --color=always -lAph' + set -a toolbox "  using plain old ls, but with colors!! + " + set -a warnings " no ls helper is installed [lsd, eza, exa..] +" +end +end +end + +#colored everything +alias ip="ip -c" +alias grep="grep --color=always" + +#weather +alias www='curl wttr.in/Ulm' + +#bat alias +if command -v batcat + alias cat='batcat -p --paging=never' + set -a toolbox " cat is using $(which batcat) + " +else +if command -v bat + alias cat='bat -p' + set -a toolbox " cat is using $(which bat) + " + else + set -a warnings " bat +" +end +end + +if command -v tmux + alias ts="tmux source $HOME/.tmux.conf" + alias t="tmux" + set -a toolbox " t is using $(which tmux) + " +else + set -a warnings " tmux +" +end + + +if command -v docker + alias up='docker compose up' + alias down='docker compose down' + alias pull='docker compose pull' + alias d='docker' + alias dr='docker run --rm -it' + alias ds='docker ps -a' + alias dc='docker compose' + alias appudpate='docker pull && docker compose up -d --force-recreate' + set -a toolbox " d is using $(which docker) [docker] + " +else + set -a warnings " docker +" +end + +# z stands for Zoxide + +if command -v zoxide + zoxide init fish | source + set -a toolbox " z is using $(which zoxide) [cd] + " +else + set -a warnings " zoxide +" + end + +# g stands for git +if command -v git + alias g='git' + alias gc='git clone' + alias gs='git status' + alias ga='git add' + alias gcm='git commit' + alias gp='git pull' + set -a toolbox " g is using $(which git) + " +else + set -a warnings " git +" +end + + + +#the *fetch's +if command -v pfetch + alias clearl='command clear & pfetch && ls' + alias p='pfetch' + set -a toolbox " p is using $(which pfetch) + " +else + set -a warnings " pfetch + --> run 'git clone https://github.com/dylanaraps/pfetch.git && sudo cp pfetch/pfetch /bin/ && sudo rm -r pfetch/' to fix this + " +end + +if command -v neofetch + alias nf='neofetch' + alias clearnf='command clear & neofetch' + set -a toolbox " nf is using $(which neofetch) + " +end + +#set nmap-alias +if command -v nmap + alias scanvuln='sudo nmap --script vuln -vvv' + alias sv='scanvuln' + alias portscan='sudo nmap -sT' + alias ps='portscan' + set -a toolbox " nmap is using $(which nmap) [needs sudo] + sv | 'nmap --script vuln' | vulnerabilityscan + ps | 'nmap -sT' | portscanner + " +end +#set colorscheme for bobthefish +if test -d $HOME/.config/fish/functions/ + set -g theme_nerd_fonts yes + set -g defaults_user ($USER) + # available options: dark, light, solarized(-dark/-light), base16(-dark/-light), zenburn, gruvbox(-light), dracula, nord, catppuccin-(latte/frappe/macchiato/mocha) + set -g theme_color_scheme catppuccin-mocha +end + +set -a fish_greed " +$toolbox" + + alias code='codium' + clear & pfetch + alias clear='clear & pfetch && echo $toolbox' + +echo "-------------------------------------------------------------" +echo $fish_greed +echo "-------------------------------------------------------------" +echo $ALIASSES +echo "-------------------------------------------------------------" +echo $warnings diff --git a/dotfiles/.config/fish/fish_variables b/dotfiles/.config/fish/fish_variables new file mode 100644 index 0000000..62bbc05 --- /dev/null +++ b/dotfiles/.config/fish/fish_variables @@ -0,0 +1,76 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR __fish_initialized:3400 +SETUVAR fish_color_autosuggestion:555\x1ebrblack +SETUVAR fish_color_cancel:\x2dr +SETUVAR fish_color_command:005fd7 +SETUVAR fish_color_comment:990000 +SETUVAR fish_color_cwd:green +SETUVAR fish_color_cwd_root:red +SETUVAR fish_color_end:009900 +SETUVAR fish_color_error:ff0000 +SETUVAR fish_color_escape:00a6b2 +SETUVAR fish_color_history_current:\x2d\x2dbold +SETUVAR fish_color_host:normal +SETUVAR fish_color_host_remote:yellow +SETUVAR fish_color_normal:normal +SETUVAR fish_color_operator:00a6b2 +SETUVAR fish_color_param:00afff +SETUVAR fish_color_quote:999900 +SETUVAR fish_color_redirection:00afff +SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_status:red +SETUVAR fish_color_user:brgreen +SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_key_bindings:fish_default_key_bindings +SETUVAR fish_pager_color_completion:\x1d +SETUVAR fish_pager_color_description:B3A06D\x1eyellow +SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan +SETUVAR fish_pager_color_selected_background:\x2dr +SETUVAR pure_begin_prompt_with_current_directory:true +SETUVAR pure_check_for_new_release:false +SETUVAR pure_color_at_sign:pure_color_mute +SETUVAR pure_color_command_duration:pure_color_warning +SETUVAR pure_color_current_directory:pure_color_primary +SETUVAR pure_color_danger:red +SETUVAR pure_color_dark:black +SETUVAR pure_color_git_branch:pure_color_mute +SETUVAR pure_color_git_dirty:pure_color_mute +SETUVAR pure_color_git_stash:pure_color_info +SETUVAR pure_color_git_unpulled_commits:pure_color_info +SETUVAR pure_color_git_unpushed_commits:pure_color_info +SETUVAR pure_color_hostname:pure_color_mute +SETUVAR pure_color_info:cyan +SETUVAR pure_color_jobs:pure_color_normal +SETUVAR pure_color_light:white +SETUVAR pure_color_mute:brblack +SETUVAR pure_color_normal:normal +SETUVAR pure_color_prefix_root_prompt:pure_color_danger +SETUVAR pure_color_primary:blue +SETUVAR pure_color_prompt_on_error:pure_color_danger +SETUVAR pure_color_prompt_on_success:pure_color_success +SETUVAR pure_color_success:magenta +SETUVAR pure_color_system_time:pure_color_mute +SETUVAR pure_color_username_normal:pure_color_mute +SETUVAR pure_color_username_root:pure_color_light +SETUVAR pure_color_virtualenv:pure_color_mute +SETUVAR pure_color_warning:yellow +SETUVAR pure_enable_git:true +SETUVAR pure_enable_single_line_prompt:false +SETUVAR pure_reverse_prompt_symbol_in_vimode:true +SETUVAR pure_separate_prompt_on_error:false +SETUVAR pure_show_jobs:false +SETUVAR pure_show_prefix_root_prompt:false +SETUVAR pure_show_subsecond_command_duration:false +SETUVAR pure_show_system_time:false +SETUVAR pure_symbol_git_dirty:\x2a +SETUVAR pure_symbol_git_stash:\u2261 +SETUVAR pure_symbol_git_unpulled_commits:\u21e3 +SETUVAR pure_symbol_git_unpushed_commits:\u21e1 +SETUVAR pure_symbol_prefix_root_prompt:\x23 +SETUVAR pure_symbol_prompt:\u276f +SETUVAR pure_symbol_reverse_prompt:\u276e +SETUVAR pure_symbol_title_bar_separator:\x2d +SETUVAR pure_threshold_command_duration:5 diff --git a/dotfiles/.config/fish/functions/__bobthefish_colors.fish b/dotfiles/.config/fish/functions/__bobthefish_colors.fish new file mode 100644 index 0000000..34a5d16 --- /dev/null +++ b/dotfiles/.config/fish/functions/__bobthefish_colors.fish @@ -0,0 +1,1102 @@ +function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthefish' + switch "$color_scheme" + case 'user' + __bobthefish_user_color_scheme_deprecated + return + + case 'terminal' 'terminal-dark*' + set -l colorfg black + [ "$color_scheme" = 'terminal-dark-white' ]; and set colorfg white + set -x color_initial_segment_exit white red --bold + set -x color_initial_segment_private white black + set -x color_initial_segment_su white green --bold + set -x color_initial_segment_jobs white blue --bold + + set -x color_path black white + set -x color_path_basename black white --bold + set -x color_path_nowrite magenta $colorfg + set -x color_path_nowrite_basename magenta $colorfg --bold + + set -x color_repo green $colorfg + set -x color_repo_work_tree black $colorfg --bold + set -x color_repo_dirty brred $colorfg + set -x color_repo_staged yellow $colorfg + + set -x color_vi_mode_default brblue $colorfg --bold + set -x color_vi_mode_insert brgreen $colorfg --bold + set -x color_vi_mode_visual bryellow $colorfg --bold + + set -x color_vagrant brcyan $colorfg + set -x color_k8s magenta white --bold + set -x color_aws_vault blue $colorfg --bold + set -x color_aws_vault_expired blue red --bold + set -x color_username white black --bold + set -x color_hostname white black + set -x color_screen brgreen $colorfg --bold + set -x color_rvm brmagenta $colorfg --bold + set -x color_node brgreen $colorfg --bold + set -x color_virtualfish brblue $colorfg --bold + set -x color_virtualgo brblue $colorfg --bold + set -x color_desk brblue $colorfg --bold + set -x color_nix brblue $colorfg --bold + + case 'terminal-light*' + set -l colorfg white + [ "$color_scheme" = 'terminal-light-black' ]; and set colorfg black + set -x color_initial_segment_exit black red --bold + set -x color_initial_segment_private black white + set -x color_initial_segment_su black green --bold + set -x color_initial_segment_jobs black blue --bold + + set -x color_path white black + set -x color_path_basename white black --bold + set -x color_path_nowrite magenta $colorfg + set -x color_path_nowrite_basename magenta $colorfg --bold + + set -x color_repo green $colorfg + set -x color_repo_work_tree white $colorfg --bold + set -x color_repo_dirty brred $colorfg + set -x color_repo_staged yellow $colorfg + + set -x color_vi_mode_default brblue $colorfg --bold + set -x color_vi_mode_insert brgreen $colorfg --bold + set -x color_vi_mode_visual bryellow $colorfg --bold + + set -x color_vagrant brcyan $colorfg + set -x color_k8s magenta white --bold + set -x color_aws_vault blue $colorfg --bold + set -x color_aws_vault_expired blue red --bold + set -x color_username black white --bold + set -x color_hostname black white + set -x color_screen brgreen $colorfg --bold + set -x color_rvm brmagenta $colorfg --bold + set -x color_node brgreen $colorfg --bold + set -x color_virtualfish brblue $colorfg --bold + set -x color_virtualgo brblue $colorfg --bold + set -x color_desk brblue $colorfg --bold + set -x color_nix brblue $colorfg --bold + + case 'terminal2' 'terminal2-dark*' + set -l colorfg black + [ "$color_scheme" = 'terminal2-dark-white' ]; and set colorfg white + set -x color_initial_segment_exit grey red --bold + set -x color_initial_segment_private grey black + set -x color_initial_segment_su grey green --bold + set -x color_initial_segment_jobs grey blue --bold + + set -x color_path brgrey white + set -x color_path_basename brgrey white --bold + set -x color_path_nowrite magenta $colorfg + set -x color_path_nowrite_basename magenta $colorfg --bold + + set -x color_repo green $colorfg + set -x color_repo_work_tree brgrey $colorfg --bold + set -x color_repo_dirty brred $colorfg + set -x color_repo_staged yellow $colorfg + + set -x color_vi_mode_default brblue $colorfg --bold + set -x color_vi_mode_insert brgreen $colorfg --bold + set -x color_vi_mode_visual bryellow $colorfg --bold + + set -x color_vagrant brcyan $colorfg + set -x color_k8s magenta white --bold + set -x color_aws_vault blue $colorfg --bold + set -x color_aws_vault_expired blue red --bold + set -x color_username brgrey white --bold + set -x color_hostname brgrey white + set -x color_screen brgreen $colorfg --bold + set -x color_rvm brmagenta $colorfg --bold + set -x color_node brgreen $colorfg --bold + set -x color_virtualfish brblue $colorfg --bold + set -x color_virtualgo brblue $colorfg --bold + set -x color_desk brblue $colorfg --bold + set -x color_nix brblue $colorfg --bold + + case 'terminal2-light*' + set -l colorfg white + [ "$color_scheme" = 'terminal2-light-black' ]; and set colorfg black + set -x color_initial_segment_exit brgrey red --bold + set -x color_initial_segment_private brgrey black + set -x color_initial_segment_su brgrey green --bold + set -x color_initial_segment_jobs brgrey blue --bold + + set -x color_path grey black + set -x color_path_basename grey black --bold + set -x color_path_nowrite magenta $colorfg + set -x color_path_nowrite_basename magenta $colorfg --bold + + set -x color_repo green $colorfg + set -x color_repo_work_tree grey $colorfg --bold + set -x color_repo_dirty brred $colorfg + set -x color_repo_staged yellow $colorfg + + set -x color_vi_mode_default brblue $colorfg --bold + set -x color_vi_mode_insert brgreen $colorfg --bold + set -x color_vi_mode_visual bryellow $colorfg --bold + + set -x color_vagrant brcyan $colorfg + set -x color_k8s magenta white --bold + set -x color_aws_vault blue $colorfg --bold + set -x color_aws_vault_expired blue red --bold + set -x color_username grey black --bold + set -x color_hostname grey black + set -x color_screen brgreen $colorfg --bold + set -x color_rvm brmagenta $colorfg --bold + set -x color_node brgreen $colorfg --bold + set -x color_virtualfish brblue $colorfg --bold + set -x color_virtualgo brblue $colorfg --bold + set -x color_desk brblue $colorfg --bold + set -x color_nix brblue $colorfg --bold + + case 'zenburn' + set -l grey 333333 # a bit darker than normal zenburn grey + set -l red CC9393 + set -l green 7F9F7F + set -l yellow E3CEAB + set -l orange DFAF8F + set -l blue 8CD0D3 + set -l white DCDCCC + + set -x color_initial_segment_exit $white $red --bold + set -x color_initial_segment_private $white $grey + set -x color_initial_segment_su $white $green --bold + set -x color_initial_segment_jobs $white $blue --bold + + set -x color_path $grey $white + set -x color_path_basename $grey $white --bold + set -x color_path_nowrite $grey $red + set -x color_path_nowrite_basename $grey $red --bold + + set -x color_repo $green $grey + set -x color_repo_work_tree $grey $grey --bold + set -x color_repo_dirty $red $grey + set -x color_repo_staged $yellow $grey + + set -x color_vi_mode_default $grey $yellow --bold + set -x color_vi_mode_insert $green $white --bold + set -x color_vi_mode_visual $yellow $grey --bold + + set -x color_vagrant $blue $green --bold + set -x color_k8s $green $white --bold + set -x color_aws_vault $blue $grey --bold + set -x color_aws_vault_expired $blue $red --bold + set -x color_username $grey $blue --bold + set -x color_hostname $grey $blue + set -x color_screen $green $grey --bold + set -x color_rvm $red $grey --bold + set -x color_node $green $white --bold + set -x color_virtualfish $blue $grey --bold + set -x color_virtualgo $blue $grey --bold + set -x color_desk $blue $grey --bold + set -x color_nix $blue $grey --bold + + case 'base16-light' + set -l base00 181818 + set -l base01 282828 + set -l base02 383838 + set -l base03 585858 + set -l base04 b8b8b8 + set -l base05 d8d8d8 + set -l base06 e8e8e8 + set -l base07 f8f8f8 + set -l base08 ab4642 # red + set -l base09 dc9656 # orange + set -l base0A f7ca88 # yellow + set -l base0B a1b56c # green + set -l base0C 86c1b9 # cyan + set -l base0D 7cafc2 # blue + set -l base0E ba8baf # violet + set -l base0F a16946 # brown + + set -l colorfg $base00 + + set -x color_initial_segment_exit $base02 $base08 --bold + set -x color_initial_segment_private $base02 $base06 + set -x color_initial_segment_su $base02 $base0B --bold + set -x color_initial_segment_jobs $base02 $base0D --bold + + set -x color_path $base06 $base02 + set -x color_path_basename $base06 $base01 --bold + set -x color_path_nowrite $base06 $base08 + set -x color_path_nowrite_basename $base06 $base08 --bold + + set -x color_repo $base0B $colorfg + set -x color_repo_work_tree $base06 $colorfg --bold + set -x color_repo_dirty $base08 $colorfg + set -x color_repo_staged $base09 $colorfg + + set -x color_vi_mode_default $base04 $colorfg --bold + set -x color_vi_mode_insert $base0B $colorfg --bold + set -x color_vi_mode_visual $base09 $colorfg --bold + + set -x color_vagrant $base0C $colorfg --bold + set -x color_k8s $base06 $colorfg --bold + set -x color_aws_vault $base0D $colorfg --bold + set -x color_aws_vault_expired $base0D $base08 --bold + set -x color_username $base02 $base0D --bold + set -x color_hostname $base02 $base0D + set -x color_screen $base06 $colorfg --bold + set -x color_rvm $base08 $colorfg --bold + set -x color_node $base0B $colorfg --bold + set -x color_virtualfish $base0D $colorfg --bold + set -x color_virtualgo $base0D $colorfg --bold + set -x color_desk $base0D $colorfg --bold + set -x color_nix $base0D $colorfg --bold + + case 'base16' 'base16-dark' + set -l base00 181818 + set -l base01 282828 + set -l base02 383838 + set -l base03 585858 + set -l base04 b8b8b8 + set -l base05 d8d8d8 + set -l base06 e8e8e8 + set -l base07 f8f8f8 + set -l base08 ab4642 # red + set -l base09 dc9656 # orange + set -l base0A f7ca88 # yellow + set -l base0B a1b56c # green + set -l base0C 86c1b9 # cyan + set -l base0D 7cafc2 # blue + set -l base0E ba8baf # violet + set -l base0F a16946 # brown + + set -l colorfg $base07 + + set -x color_initial_segment_exit $base05 $base08 --bold + set -x color_initial_segment_private $base05 $base02 + set -x color_initial_segment_su $base05 $base0B --bold + set -x color_initial_segment_jobs $base05 $base0D --bold + + set -x color_path $base02 $base05 + set -x color_path_basename $base02 $base06 --bold + set -x color_path_nowrite $base02 $base08 + set -x color_path_nowrite_basename $base02 $base08 --bold + + set -x color_repo $base0B $colorfg + set -x color_repo_work_tree $base02 $colorfg --bold + set -x color_repo_dirty $base08 $colorfg + set -x color_repo_staged $base09 $colorfg + + set -x color_vi_mode_default $base03 $colorfg --bold + set -x color_vi_mode_insert $base0B $colorfg --bold + set -x color_vi_mode_visual $base09 $colorfg --bold + + set -x color_vagrant $base0C $colorfg --bold + set -x color_k8s $base0B $colorfg --bold + set -x color_aws_vault $base0D $base0A --bold + set -x color_aws_vault_expired $base0D $base08 --bold + set -x color_username $base02 $base0D --bold + set -x color_hostname $base02 $base0D + set -x color_screen $base0B $colorfg --bold + set -x color_rvm $base08 $colorfg --bold + set -x color_node $base0B $colorfg --bold + set -x color_virtualfish $base0D $colorfg --bold + set -x color_virtualgo $base0D $colorfg --bold + set -x color_desk $base0D $colorfg --bold + set -x color_nix $base0D $colorfg --bold + + case 'solarized-light' + set -l base03 002b36 + set -l base02 073642 + set -l base01 586e75 + set -l base00 657b83 + set -l base0 839496 + set -l base1 93a1a1 + set -l base2 eee8d5 + set -l base3 fdf6e3 + set -l yellow b58900 + set -l orange cb4b16 + set -l red dc322f + set -l magenta d33682 + set -l violet 6c71c4 + set -l blue 268bd2 + set -l cyan 2aa198 + set -l green 859900 + + set colorfg $base03 + + set -x color_initial_segment_exit $base02 $red --bold + set -x color_initial_segment_private $base02 $base2 + set -x color_initial_segment_su $base02 $green --bold + set -x color_initial_segment_jobs $base02 $blue --bold + + set -x color_path $base2 $base00 + set -x color_path_basename $base2 $base01 --bold + set -x color_path_nowrite $base2 $orange + set -x color_path_nowrite_basename $base2 $orange --bold + + set -x color_repo $green $colorfg + set -x color_repo_work_tree $base2 $colorfg --bold + set -x color_repo_dirty $red $colorfg + set -x color_repo_staged $yellow $colorfg + + set -x color_vi_mode_default $blue $colorfg --bold + set -x color_vi_mode_insert $green $colorfg --bold + set -x color_vi_mode_visual $yellow $colorfg --bold + + set -x color_vagrant $violet $colorfg --bold + set -x color_k8s $green $colorfg --bold + set -x color_aws_vault $violet $base3 --bold + set -x color_aws_vault_expired $violet $orange --bold + set -x color_username $base2 $blue --bold + set -x color_hostname $base2 $blue + set -x color_screen $green $colorfg --bold + set -x color_rvm $red $colorfg --bold + set -x color_node $green $colorfg --bold + set -x color_virtualfish $cyan $colorfg --bold + set -x color_virtualgo $cyan $colorfg --bold + set -x color_desk $cyan $colorfg --bold + set -x color_nix $cyan $colorfg --bold + + case 'solarized' 'solarized-dark' + set -l base03 002b36 + set -l base02 073642 + set -l base01 586e75 + set -l base00 657b83 + set -l base0 839496 + set -l base1 93a1a1 + set -l base2 eee8d5 + set -l base3 fdf6e3 + set -l yellow b58900 + set -l orange cb4b16 + set -l red dc322f + set -l magenta d33682 + set -l violet 6c71c4 + set -l blue 268bd2 + set -l cyan 2aa198 + set -l green 859900 + + set colorfg $base3 + + set -x color_initial_segment_exit $base2 $red --bold + set -x color_initial_segment_private $base2 $base02 + set -x color_initial_segment_su $base2 $green --bold + set -x color_initial_segment_jobs $base2 $blue --bold + + set -x color_path $base02 $base0 + set -x color_path_basename $base02 $base1 --bold + set -x color_path_nowrite $base02 $orange + set -x color_path_nowrite_basename $base02 $orange --bold + + set -x color_repo $green $colorfg + set -x color_repo_work_tree $base02 $colorfg --bold + set -x color_repo_dirty $red $colorfg + set -x color_repo_staged $yellow $colorfg + + set -x color_vi_mode_default $blue $colorfg --bold + set -x color_vi_mode_insert $green $colorfg --bold + set -x color_vi_mode_visual $yellow $colorfg --bold + + set -x color_vagrant $violet $colorfg --bold + set -x color_k8s $green $colorfg --bold + set -x color_aws_vault $violet $base3 --bold + set -x color_aws_vault_expired $violet $orange --bold + set -x color_username $base02 $blue --bold + set -x color_hostname $base02 $blue + set -x color_screen $green $colorfg --bold + set -x color_rvm $red $colorfg --bold + set -x color_node $green $colorfg --bold + set -x color_virtualfish $cyan $colorfg --bold + set -x color_virtualgo $cyan $colorfg --bold + set -x color_desk $cyan $colorfg --bold + set -x color_nix $cyan $colorfg --bold + + case 'light' + # light medium dark + # ------ ------ ------ + set -l red cc9999 ce000f 660000 + set -l green addc10 189303 0c4801 + set -l blue 48b4fb 005faf 255e87 + set -l orange f6b117 unused 3a2a03 + set -l brown bf5e00 803f00 4d2600 + set -l grey cccccc 999999 333333 + set -l white ffffff + set -l black 000000 + set -l ruby_red af0000 + + set -x color_initial_segment_exit $grey[3] $red[2] --bold + set -x color_initial_segment_private $grey[3] $grey[1] + set -x color_initial_segment_su $grey[3] $green[2] --bold + set -x color_initial_segment_jobs $grey[3] $blue[3] --bold + + set -x color_path $grey[1] $grey[2] + set -x color_path_basename $grey[1] $grey[3] --bold + set -x color_path_nowrite $red[1] $red[3] + set -x color_path_nowrite_basename $red[1] $red[3] --bold + + set -x color_repo $green[1] $green[3] + set -x color_repo_work_tree $grey[1] $white --bold + set -x color_repo_dirty $red[2] $white + set -x color_repo_staged $orange[1] $orange[3] + + set -x color_vi_mode_default $grey[2] $grey[3] --bold + set -x color_vi_mode_insert $green[2] $grey[3] --bold + set -x color_vi_mode_visual $orange[1] $orange[3] --bold + + set -x color_vagrant $blue[1] $white --bold + set -x color_k8s $green[1] $colorfg --bold + set -x color_aws_vault $blue[3] $orange[1] --bold + set -x color_aws_vault_expired $blue[3] $red[3] --bold + set -x color_username $grey[1] $blue[3] --bold + set -x color_hostname $grey[1] $blue[3] + set -x color_screen $green[1] $colorfg --bold + set -x color_rvm $ruby_red $grey[1] --bold + set -x color_node $green $grey[1] --bold + set -x color_virtualfish $blue[2] $grey[1] --bold + set -x color_virtualgo $blue[2] $grey[1] --bold + set -x color_desk $blue[2] $grey[1] --bold + set -x color_nix $blue[2] $grey[1] --bold + + case 'gruvbox' + # light medium dark darkest + # ------ ------ ------ ------- + set -l red fb4934 cc241d + set -l green b8bb26 98971a + set -l yellow fabd2f d79921 + set -l aqua 8ec07c 689d6a + set -l blue 83a598 458588 + set -l grey cccccc 999999 333333 + set -l fg fbf1c7 ebdbb2 d5c4a1 a89984 + set -l bg 504945 282828 + + set -x color_initial_segment_exit $fg[1] $red[2] --bold + set -x color_initial_segment_private $fg[1] $bg[1] + set -x color_initial_segment_su $fg[1] $green[2] --bold + set -x color_initial_segment_jobs $fg[1] $aqua[2] --bold + + set -x color_path $bg[1] $fg[2] + set -x color_path_basename $bg[1] $fg[2] --bold + set -x color_path_nowrite $red[1] $fg[2] + set -x color_path_nowrite_basename $red[1] $fg[2] --bold + + set -x color_repo $green[2] $bg[1] + set -x color_repo_work_tree $bg[1] $fg[2] --bold + set -x color_repo_dirty $red[2] $fg[2] + set -x color_repo_staged $yellow[1] $bg[1] + + set -x color_vi_mode_default $fg[4] $bg[2] --bold + set -x color_vi_mode_insert $blue[1] $bg[2] --bold + set -x color_vi_mode_visual $yellow[1] $bg[2] --bold + + set -x color_vagrant $blue[2] $fg[2] --bold + set -x color_k8s $green[2] $fg[2] --bold + set -x color_aws_vault $blue[2] $yellow[1] --bold + set -x color_aws_vault_expired $blue[2] $red[1] --bold + set -x color_username $fg[3] $blue[2] --bold + set -x color_hostname $fg[3] $blue[2] + set -x color_screen $green[1] $fg[2] --bold + set -x color_rvm $red[2] $fg[2] --bold + set -x color_node $green[1] $fg[2] --bold + set -x color_virtualfish $blue[2] $fg[2] --bold + set -x color_virtualgo $blue[2] $fg[2] --bold + set -x color_desk $blue[2] $fg[2] --bold + set -x color_nix $blue[2] $fg[2] --bold + + case 'gruvbox-light' + # light medium dark darkest + # ------ ------ ------ ------- + set -l red 9d0006 cc241d + set -l green 79740e 98971a + set -l yellow b57614 d79921 + set -l aqua 427b58 689d6a + set -l blue 076678 458588 + set -l grey a89984 928374 + set -l orange af3a03 d65d0e + set -l fg 282828 3c3836 504945 7c6f64 + set -l bg d5c4a1 fbf1c7 + + set -x color_initial_segment_exit $red[1] $bg[2] --bold + set -x color_initial_segment_su $fg[1] $green[2] --bold + set -x color_initial_segment_jobs $fg[1] $aqua[2] --bold + + set -x color_path $bg[1] $fg[2] + set -x color_path_basename $bg[1] $fg[2] --bold + set -x color_path_nowrite $red[1] $bg[2] + set -x color_path_nowrite_basename $red[1] $bg[2] --bold + + set -x color_repo $green[2] $fg[1] + set -x color_repo_work_tree $bg[1] $fg[2] --bold + set -x color_repo_dirty $orange[2] $bg[2] + set -x color_repo_staged $yellow[1] $bg[1] + + set -x color_vi_mode_default $fg[4] $bg[2] --bold + set -x color_vi_mode_insert $blue[1] $bg[2] --bold + set -x color_vi_mode_visual $yellow[1] $bg[2] --bold + + set -x color_vagrant $blue[2] $fg[2] --bold + set -x color_k8s $green[2] $fg[2] --bold + set -x color_username $fg[3] $blue[2] --bold + set -x color_hostname $fg[3] $blue[2] + set -x color_screen $green[2] $fg[2] --bold + set -x color_rvm $red[2] $bg[2] --bold + set -x color_nvm $green[1] $fg[2] --bold + set -x color_virtualfish $blue[2] $fg[2] --bold + set -x color_virtualgo $blue[2] $fg[2] --bold + set -x color_desk $blue[2] $fg[2] --bold + set -x color_nix $blue[2] $fg[2] --bold + + case 'dracula' # https://draculatheme.com + set -l bg 282a36 + set -l current_line 44475a + set -l selection 44475a + set -l fg f8f8f2 + set -l comment 6272a4 + set -l cyan 8be9fd + set -l green 50fa7b + set -l orange ffb86c + set -l pink ff79c6 + set -l purple bd93f9 + set -l red ff5555 + set -l yellow f1fa8c + + set -x color_initial_segment_exit $fg $red --bold + set -x color_initial_segment_private $fg $selection + set -x color_initial_segment_su $fg $purple --bold + set -x color_initial_segment_jobs $fg $comment --bold + + set -x color_path $selection $fg + set -x color_path_basename $selection $fg --bold + set -x color_path_nowrite $selection $red + set -x color_path_nowrite_basename $selection $red --bold + + set -x color_repo $green $bg + set -x color_repo_work_tree $selection $fg --bold + set -x color_repo_dirty $red $bg + set -x color_repo_staged $yellow $bg + + set -x color_vi_mode_default $bg $yellow --bold + set -x color_vi_mode_insert $green $bg --bold + set -x color_vi_mode_visual $orange $bg --bold + + set -x color_vagrant $pink $bg --bold + set -x color_k8s $purple $bg --bold + set -x color_aws_vault $comment $yellow --bold + set -x color_aws_vault_expired $comment $red --bold + set -x color_username $selection $cyan --bold + set -x color_hostname $selection $cyan + set -x color_screen $green $bg --bold + set -x color_rvm $red $bg --bold + set -x color_node $green $bg --bold + set -x color_virtualfish $comment $bg --bold + set -x color_virtualgo $cyan $bg --bold + set -x color_desk $comment $bg --bold + set -x color_nix $cyan $bg --bold + + case 'nord' + set -l base00 2E3440 + set -l base01 3B4252 + set -l base02 434C5E + set -l base03 4C566A + set -l base04 D8DEE9 + set -l base05 E5E9F0 + set -l base06 ECEFF4 + set -l base07 8FBCBB + set -l base08 88C0D0 + set -l base09 81A1C1 + set -l base0A 5E81AC + set -l base0B BF616A + set -l base0C D08770 + set -l base0D EBCB8B + set -l base0E A3BE8C + set -l base0F B48EAD + + set -l colorfg $base00 + + set -x color_initial_segment_exit $base05 $base0B --bold + set -x color_initial_segment_private $base05 $base02 + set -x color_initial_segment_su $base05 $base0E --bold + set -x color_initial_segment_jobs $base05 $base0C --bold + + set -x color_path $base02 $base05 + set -x color_path_basename $base02 $base06 --bold + set -x color_path_nowrite $base02 $base08 + set -x color_path_nowrite_basename $base02 $base08 --bold + + set -x color_repo $base0E $colorfg + set -x color_repo_work_tree $base02 $colorfg --bold + set -x color_repo_dirty $base0B $colorfg + set -x color_repo_staged $base0D $colorfg + + set -x color_vi_mode_default $base08 $colorfg --bold + set -x color_vi_mode_insert $base06 $colorfg --bold + set -x color_vi_mode_visual $base07 $colorfg --bold + + set -x color_vagrant $base02 $colorfg --bold + set -x color_k8s $base02 $colorfg --bold + set -x color_aws_vault $base0A $base0D --bold + set -x color_aws_vault_expired $base0A $base0B --bold + set -x color_username $base02 $base0D --bold + set -x color_hostname $base02 $base0D + set -x color_screen $base02 $colorfg --bold + set -x color_rvm $base09 $colorfg --bold + set -x color_node $base09 $colorfg --bold + set -x color_virtualfish $base09 $colorfg --bold + set -x color_virtualgo $base09 $colorfg --bold + set -x color_desk $base09 $colorfg --bold + + case 'catppuccin-latte' + set -l rosewater dc8a78 + set -l flamingo dd7878 + set -l pink ea76cb + set -l mauve 8839ef + set -l red d20f39 + set -l maroon e64553 + set -l peach fe640b + set -l yellow df8e1d + set -l green 40a02b + set -l teal 179299 + set -l sky 04a5e5 + set -l sapphire 209fb5 + set -l blue 1e66f5 + set -l lavender 7287fd + set -l text 4c4f69 + set -l subtext1 5c5f77 + set -l subtext0 6c6f85 + set -l overlay2 7c7f93 + set -l overlay1 8c8fa1 + set -l overlay0 9ca0b0 + set -l surface2 acb0be + set -l surface1 bcc0cc + set -l surface0 ccd0da + set -l base eff1f5 + set -l mantle e6e9ef + set -l crust dce0e8 + + set -x color_initial_segment_exit $surface2 $red --bold + set -x color_initial_segment_private $surface2 $flamingo + set -x color_initial_segment_su $surface2 $green --bold + set -x color_initial_segment_jobs $surface2 $peach --bold + + set -x color_path $surface0 $text + set -x color_path_basename $surface0 $text --bold + set -x color_path_nowrite $surface0 $mauve + set -x color_path_nowrite_basename $surface0 $mauve --bold + + set -x color_repo $green $mantle + set -x color_repo_work_tree $surface2 $mantle --bold + set -x color_repo_dirty $red $mantle + set -x color_repo_staged $yellow $mantle + + set -x color_vi_mode_default $sky $mantle --bold + set -x color_vi_mode_insert $green $mantle --bold + set -x color_vi_mode_visual $mauve $mantle --bold + + set -x color_vagrant $surface2 $text --bold + set -x color_k8s $surface2 $text --bold + set -x color_aws_vault $yellow $mantle --bold + set -x color_aws_vault_expired $red $mantle --bold + set -x color_username $surface2 $yellow --bold + set -x color_hostname $surface2 $yellow + set -x color_screen $green $mantle --bold + set -x color_rvm $red $mantle --bold + set -x color_node $green $mantle --bold + set -x color_virtualfish $peach $mantle --bold + set -x color_virtualgo $sky $mantle --bold + set -x color_desk $peach $mantle --bold + set -x color_nix $sky $mantle --bold + + case 'catppuccin-frappe' + set -l rosewater f2d5cf + set -l flamingo eebebe + set -l pink f4b8e4 + set -l mauve ca9ee6 + set -l red e78284 + set -l maroon ea999c + set -l peach ef9f76 + set -l yellow e5c890 + set -l green a6d189 + set -l teal 81c8be + set -l sky 99d1db + set -l sapphire 85c1dc + set -l blue 8caaee + set -l lavender babbf1 + set -l text c6d0f5 + set -l subtext1 b5bfe2 + set -l subtext0 a5adce + set -l overlay2 949cbb + set -l overlay1 838ba7 + set -l overlay0 737994 + set -l surface2 626880 + set -l surface1 51576d + set -l surface0 414559 + set -l base 303446 + set -l mantle 292c3c + set -l crust 232634 + + set -x color_initial_segment_exit $surface2 $red --bold + set -x color_initial_segment_private $surface2 $flamingo + set -x color_initial_segment_su $surface2 $green --bold + set -x color_initial_segment_jobs $surface2 $peach --bold + + set -x color_path $surface0 $text + set -x color_path_basename $surface0 $text --bold + set -x color_path_nowrite $surface0 $mauve + set -x color_path_nowrite_basename $surface0 $mauve --bold + + set -x color_repo $green $mantle + set -x color_repo_work_tree $surface2 $mantle --bold + set -x color_repo_dirty $red $mantle + set -x color_repo_staged $yellow $mantle + + set -x color_vi_mode_default $sky $mantle --bold + set -x color_vi_mode_insert $green $mantle --bold + set -x color_vi_mode_visual $mauve $mantle --bold + + set -x color_vagrant $surface2 $text --bold + set -x color_k8s $surface2 $text --bold + set -x color_aws_vault $yellow $mantle --bold + set -x color_aws_vault_expired $red $mantle --bold + set -x color_username $surface2 $yellow --bold + set -x color_hostname $surface2 $yellow + set -x color_screen $green $mantle --bold + set -x color_rvm $red $mantle --bold + set -x color_node $green $mantle --bold + set -x color_virtualfish $peach $mantle --bold + set -x color_virtualgo $sky $mantle --bold + set -x color_desk $peach $mantle --bold + set -x color_nix $sky $mantle --bold + + case 'catppuccin-macchiato' + set -l rosewater f4dbd6 + set -l flamingo f0c6c6 + set -l pink f5bde6 + set -l mauve c6a0f6 + set -l red ed8796 + set -l maroon ee99a0 + set -l peach f5a97f + set -l yellow eed49f + set -l green a6da95 + set -l teal 8bd5ca + set -l sky 91d7e3 + set -l sapphire 7dc4e4 + set -l blue 8aadf4 + set -l lavender b7bdf8 + set -l text cad3f5 + set -l subtext1 b8c0e0 + set -l subtext0 a5adcb + set -l overlay2 939ab7 + set -l overlay1 8087a2 + set -l overlay0 6e738d + set -l surface2 5b6078 + set -l surface1 494d64 + set -l surface0 363a4f + set -l base 24273a + set -l mantle 1e2030 + set -l crust 181926 + + set -x color_initial_segment_exit $surface2 $red --bold + set -x color_initial_segment_private $surface2 $flamingo + set -x color_initial_segment_su $surface2 $green --bold + set -x color_initial_segment_jobs $surface2 $peach --bold + + set -x color_path $surface0 $text + set -x color_path_basename $surface0 $text --bold + set -x color_path_nowrite $surface0 $mauve + set -x color_path_nowrite_basename $surface0 $mauve --bold + + set -x color_repo $green $mantle + set -x color_repo_work_tree $surface2 $mantle --bold + set -x color_repo_dirty $red $mantle + set -x color_repo_staged $yellow $mantle + + set -x color_vi_mode_default $sky $mantle --bold + set -x color_vi_mode_insert $green $mantle --bold + set -x color_vi_mode_visual $mauve $mantle --bold + + set -x color_vagrant $surface2 $text --bold + set -x color_k8s $surface2 $text --bold + set -x color_aws_vault $yellow $mantle --bold + set -x color_aws_vault_expired $red $mantle --bold + set -x color_username $surface2 $yellow --bold + set -x color_hostname $surface2 $yellow + set -x color_screen $green $mantle --bold + set -x color_rvm $red $mantle --bold + set -x color_node $green $mantle --bold + set -x color_virtualfish $peach $mantle --bold + set -x color_virtualgo $sky $mantle --bold + set -x color_desk $peach $mantle --bold + set -x color_nix $sky $mantle --bold + + case 'catppuccin-mocha' + set -l rosewater f5e0dc + set -l flamingo f2cdcd + set -l pink f5c2e7 + set -l mauve cba6f7 + set -l red f38ba8 + set -l maroon eba0ac + set -l peach fab387 + set -l yellow f9e2af + set -l green a6e3a1 + set -l teal 94e2d5 + set -l sky 89dceb + set -l sapphire 74c7ec + set -l blue 89b4fa + set -l lavender b4befe + set -l text cdd6f4 + set -l subtext1 bac2de + set -l subtext0 a6adc8 + set -l overlay2 9399b2 + set -l overlay1 7f849c + set -l overlay0 6c7086 + set -l surface2 585b70 + set -l surface1 45475a + set -l surface0 313244 + set -l base 1e1e2e + set -l mantle 181825 + set -l crust 11111b + + set -x color_initial_segment_exit $surface2 $red --bold + set -x color_initial_segment_private $surface2 $flamingo + set -x color_initial_segment_su $surface2 $green --bold + set -x color_initial_segment_jobs $surface2 $peach --bold + + set -x color_path $surface0 $text + set -x color_path_basename $surface0 $text --bold + set -x color_path_nowrite $surface0 $mauve + set -x color_path_nowrite_basename $surface0 $mauve --bold + + set -x color_repo $green $mantle + set -x color_repo_work_tree $surface2 $mantle --bold + set -x color_repo_dirty $red $mantle + set -x color_repo_staged $yellow $mantle + + set -x color_vi_mode_default $sky $mantle --bold + set -x color_vi_mode_insert $green $mantle --bold + set -x color_vi_mode_visual $mauve $mantle --bold + + set -x color_vagrant $surface2 $text --bold + set -x color_k8s $surface2 $text --bold + set -x color_aws_vault $yellow $mantle --bold + set -x color_aws_vault_expired $red $mantle --bold + set -x color_username $surface2 $yellow --bold + set -x color_hostname $surface2 $yellow + set -x color_screen $green $mantle --bold + set -x color_rvm $red $mantle --bold + set -x color_node $green $mantle --bold + set -x color_virtualfish $peach $mantle --bold + set -x color_virtualgo $sky $mantle --bold + set -x color_desk $peach $mantle --bold + set -x color_nix $sky $mantle --bold + + case 'jellybeans' # https://github.com/nanotech/jellybeans.vim + set -l bg 151515 + set -l darker_grey 1c1c1c + set -l dark_grey 262626 + set -l grey 888888 + set -l blue_grey a0a8b0 + set -l light_grey d8dee9 + set -l white ffffff + set -l dark_red 902020 + set -l red cf6a4c + set -l red_orange ffb964 + set -l bright_orange fad07a + set -l pale_gold dad085 + set -l pink f0a0c0 + set -l lilac c6b6ee + set -l dark_blue 2b5b77 + set -l deep_blue 0d61ac + set -l blue 8197bf + set -l bright_blue 7697d6 + set -l cyan 8fbfdc + set -l blue_green 668799 + set -l green 799d6a + set -l bright_green 70b950 + set -l brighter_green 65c254 + set -l light_green 99ad6a + set -l dark_green 556633 + + set -x color_initial_segment_exit $dark_red $white --bold + set -x color_initial_segment_private $light_grey $dark_grey --bold + set -x color_initial_segment_su $red_orange $darker_grey --bold + set -x color_initial_segment_jobs $lilac $darker_grey --bold + + set -x color_path $dark_grey $light_grey + set -x color_path_basename $dark_grey $light_grey --bold + set -x color_path_nowrite $dark_grey $red_orange + set -x color_path_nowrite_basename $dark_grey $red_orange --bold + + set -x color_repo $light_green $darker_grey + set -x color_repo_work_tree $dark_grey $light_grey --bold + set -x color_repo_dirty $red $darker_grey + set -x color_repo_staged $pale_gold $darker_grey + + set -x color_vi_mode_default $bright_blue $darker_grey --bold + set -x color_vi_mode_insert $lilac $darker_grey --bold + set -x color_vi_mode_visual $cyan $darker_grey --bold + + set -x color_username $dark_grey $blue_grey --bold + set -x color_hostname $dark_grey $blue_grey + set -x color_screen $bright_green $darker_grey --bold + + set -x color_vagrant $lilac $darker_grey --bold + set -x color_k8s $pale_gold $darker_grey --bold + set -x color_aws_vault $deep_blue $pale_gold --bold + set -x color_aws_vault_expired $deep_blue $red --bold + set -x color_rvm $pink $darker_grey --bold + set -x color_nvm $bright_green $darker_grey --bold + set -x color_virtualfish $cyan $darker_grey --bold + set -x color_virtualgo $light_green $darker_grey --bold + set -x color_desk $light_grey $darker_grey --bold + set -x color_nix $bright_blue $darker_grey --bold + + case 'darcula' + # light medium dark darkest + # ------ ------ ------ ------ + set -l grey 808080 616161 595959 424242 + set -l red FF4050 F0524F B82421 772E2C + set -l green 4FC414 5C962C 458500 39511F + set -l yellow E5BF00 A68A0D A87B00 5C4F17 + set -l blue 1FB0FF 3993D4 1778BD 245980 + set -l white F9F9F4 B7C3D0 + + set -x color_initial_segment_exit $white[2] $red[3] --bold + set -x color_initial_segment_private $white[2] $grey[4] + set -x color_initial_segment_su $white[2] $green[3] --bold + set -x color_initial_segment_jobs $white[2] $blue[3] --bold + + set -x color_path $grey[4] $white[2] + set -x color_path_basename $grey[4] $white[1] --bold + set -x color_path_nowrite $grey[4] $red[2] + set -x color_path_nowrite_basename $grey[4] $red[1] --bold + + set -x color_repo $green[3] $white[4] + set -x color_repo_work_tree $grey[4] $grey[4] --bold + set -x color_repo_dirty $red[3] $grey[4] + set -x color_repo_staged $yellow[3] $grey[4] + + set -x color_vi_mode_default $grey[4] $yellow[2] --bold + set -x color_vi_mode_insert $green[2] $grey[4] --bold + set -x color_vi_mode_visual $yellow[2] $grey[4] --bold + + set -x color_vagrant $blue[2] $green[1] --bold + set -x color_k8s $green[2] $grey[4] --bold + set -x color_aws_vault $blue[2] $grey[4] --bold + set -x color_aws_vault_expired $blue[2] $red[1] --bold + set -x color_username $grey[4] $blue[2] --bold + set -x color_hostname $grey[4] $blue[1] + set -x color_screen $green[3] $white[2] --bold + set -x color_rvm $red[2] $grey[4] --bold + set -x color_node $green[3] $white[2] --bold + set -x color_virtualfish $blue[2] $grey[4] --bold + set -x color_virtualgo $blue[2] $grey[4] --bold + set -x color_desk $blue[2] $grey[4] --bold + set -x color_nix $blue[2] $grey[4] --bold + + case '*' # default dark theme + # light medium dark + # ------ ------ ------ + set -l red cc9999 ce000f 660000 + set -l green addc10 189303 0c4801 + set -l blue 48b4fb 005faf 255e87 + set -l orange f6b117 unused 3a2a03 + set -l brown bf5e00 803f00 4d2600 + set -l grey cccccc 999999 333333 + set -l white ffffff + set -l black 000000 + set -l ruby_red af0000 + set -l go_blue 00d7d7 + + set -x color_initial_segment_exit $white $red[2] --bold + set -x color_initial_segment_private $white $grey[3] + set -x color_initial_segment_su $white $green[2] --bold + set -x color_initial_segment_jobs $white $blue[3] --bold + + set -x color_path $grey[3] $grey[2] + set -x color_path_basename $grey[3] $white --bold + set -x color_path_nowrite $red[3] $red[1] + set -x color_path_nowrite_basename $red[3] $red[1] --bold + + set -x color_repo $green[1] $green[3] + set -x color_repo_work_tree $grey[3] $white --bold + set -x color_repo_dirty $red[2] $white + set -x color_repo_staged $orange[1] $orange[3] + + set -x color_vi_mode_default $grey[2] $grey[3] --bold + set -x color_vi_mode_insert $green[2] $grey[3] --bold + set -x color_vi_mode_visual $orange[1] $orange[3] --bold + + set -x color_vagrant $blue[1] $white --bold + set -x color_k8s $green[2] $white --bold + set -x color_aws_vault $blue[3] $orange[1] --bold + set -x color_aws_vault_expired $blue[3] $red[3] --bold + set -x color_username $grey[1] $blue[3] --bold + set -x color_hostname $grey[1] $blue[3] + set -x color_screen $green[1] $white --bold + set -x color_rvm $ruby_red $grey[1] --bold + set -x color_node $green[1] $white --bold + set -x color_virtualfish $blue[2] $grey[1] --bold + set -x color_virtualgo $go_blue $black --bold + set -x color_desk $blue[2] $grey[1] --bold + set -x color_nix $blue[2] $grey[1] --bold + end +end + +function __bobthefish_user_color_scheme_deprecated + set -q __color_initial_segment_exit; or set -l __color_initial_segment_exit ffffff ce000f --bold + set -q __color_initial_segment_private; or set -l __color_initial_segment_private ffffff 255e87 + set -q __color_initial_segment_su; or set -l __color_initial_segment_su ffffff 189303 --bold + set -q __color_initial_segment_jobs; or set -l __color_initial_segment_jobs ffffff 255e87 --bold + set -q __color_path; or set -l __color_path 333333 999999 + set -q __color_path_basename; or set -l __color_path_basename 333333 ffffff --bold + set -q __color_path_nowrite; or set -l __color_path_nowrite 660000 cc9999 + set -q __color_path_nowrite_basename; or set -l __color_path_nowrite_basename 660000 cc9999 --bold + set -q __color_repo; or set -l __color_repo addc10 0c4801 + set -q __color_repo_work_tree; or set -l __color_repo_work_tree 333333 ffffff --bold + set -q __color_repo_dirty; or set -l __color_repo_dirty ce000f ffffff + set -q __color_repo_staged; or set -l __color_repo_staged f6b117 3a2a03 + set -q __color_vi_mode_default; or set -l __color_vi_mode_default 999999 333333 --bold + set -q __color_vi_mode_insert; or set -l __color_vi_mode_insert 189303 333333 --bold + set -q __color_vi_mode_visual; or set -l __color_vi_mode_visual f6b117 3a2a03 --bold + set -q __color_vagrant; or set -l __color_vagrant 48b4fb ffffff --bold + set -q __color_username; or set -l __color_username cccccc 255e87 --bold + set -q __color_hostname; or set -l __color_hostname cccccc 255e87 + set -q __color_rvm; or set -l __color_rvm af0000 cccccc --bold + set -q __color_virtualfish; or set -l __color_virtualfish 005faf cccccc --bold + set -q __color_virtualgo; or set -l __color_virtualgo 005faf cccccc --bold + set -q __color_desk; or set -l __color_desk 005faf cccccc --bold + set -q __color_nix; or set -l __color_nix 005faf cccccc --bold + + set_color black -b red --bold + echo "The 'user' color scheme is deprecated." + set_color normal + set_color black -b red + echo "To define a custom color scheme, create a 'bobthefish_colors' function:" + set_color normal + echo + + echo "function bobthefish_colors -S -d 'Define a custom bobthefish color scheme' + + # optionally include a base color scheme... + ___bobthefish_colors default + + # then override everything you want! note that these must be defined with `set -x` + set -x color_initial_segment_exit $__color_initial_segment_exit + set -x color_initial_segment_private $__color_initial_segment_private + set -x color_initial_segment_su $__color_initial_segment_su + set -x color_initial_segment_jobs $__color_initial_segment_jobs + set -x color_path $__color_path + set -x color_path_basename $__color_path_basename + set -x color_path_nowrite $__color_path_nowrite + set -x color_path_nowrite_basename $__color_path_nowrite_basename + set -x color_repo $__color_repo + set -x color_repo_work_tree $__color_repo_work_tree + set -x color_repo_dirty $__color_repo_dirty + set -x color_repo_staged $__color_repo_staged + set -x color_vi_mode_default $__color_vi_mode_default + set -x color_vi_mode_insert $__color_vi_mode_insert + set -x color_vi_mode_visual $__color_vi_mode_visual + set -x color_vagrant $__color_vagrant + set -x color_aws_vault $__color_aws_vault + set -x color_aws_vault_expired $__color_aws_vault_expired + set -x color_username $__color_username + set -x color_hostname $__color_hostname + set -x color_rvm $__color_rvm + set -x color_virtualfish $__color_virtualfish + set -x color_virtualgo $__color_virtualgo + set -x color_desk $__color_desk + set -x color_nix $__color_nix +end" + + echo +end diff --git a/dotfiles/.config/fish/functions/__bobthefish_display_colors.fish b/dotfiles/.config/fish/functions/__bobthefish_display_colors.fish new file mode 100644 index 0000000..210a803 --- /dev/null +++ b/dotfiles/.config/fish/functions/__bobthefish_display_colors.fish @@ -0,0 +1,3 @@ +function __bobthefish_display_colors -d 'Print example prompts using the current color scheme' + bobthefish_display_colors +end diff --git a/dotfiles/.config/fish/functions/__bobthefish_glyphs.fish b/dotfiles/.config/fish/functions/__bobthefish_glyphs.fish new file mode 100644 index 0000000..c0f13e2 --- /dev/null +++ b/dotfiles/.config/fish/functions/__bobthefish_glyphs.fish @@ -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 diff --git a/dotfiles/.config/fish/functions/bobthefish_display_colors.fish b/dotfiles/.config/fish/functions/bobthefish_display_colors.fish new file mode 100644 index 0000000..39c025f --- /dev/null +++ b/dotfiles/.config/fish/functions/bobthefish_display_colors.fish @@ -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 diff --git a/dotfiles/.config/fish/functions/fish_mode_prompt.fish b/dotfiles/.config/fish/functions/fish_mode_prompt.fish new file mode 100644 index 0000000..efb3c62 --- /dev/null +++ b/dotfiles/.config/fish/functions/fish_mode_prompt.fish @@ -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 diff --git a/dotfiles/.config/fish/functions/fish_prompt.fish b/dotfiles/.config/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..e9ae47b --- /dev/null +++ b/dotfiles/.config/fish/functions/fish_prompt.fish @@ -0,0 +1,1263 @@ +# name: bobthefish +# +# bobthefish is a Powerline-style, Git-aware fish theme optimized for awesome. +# +# You will need a Powerline-patched font for this to work: +# +# https://powerline.readthedocs.org/en/master/installation.html#patched-fonts +# +# I recommend picking one of these: +# +# https://github.com/Lokaltog/powerline-fonts +# +# For more advanced awesome, install a nerd fonts patched font (and be sure to +# enable nerd fonts support with `set -g theme_nerd_fonts yes`): +# +# https://github.com/ryanoasis/nerd-fonts +# +# See README.md for setup and configuration options. +# +# ============================== +# Helper methods +# ============================== + +function __bobthefish_basename -d 'basically basename, but faster' + string replace -r '^.*/' '' -- $argv +end + +function __bobthefish_dirname -d 'basically dirname, but faster' + string replace -r '/[^/]+/?$' '' -- $argv +end + +function __bobthefish_pwd -d 'Get a normalized $PWD' + # The pwd builtin accepts `-P` on at least Fish 3.x, but fall back to $PWD if that doesn't work + builtin pwd -P 2>/dev/null + or echo $PWD +end + +# Note that for fish < 3.0 this falls back to unescaped, rather than trying to do something clever /shrug +# After we drop support for older fishies, we can inline this without the fallback. +function __bobthefish_escape_regex -a str -d 'A backwards-compatible `string escape --style=regex` implementation' + string escape --style=regex "$str" 2>/dev/null + or echo "$str" +end + +function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish)' + set -l tag (command git describe --tags --exact-match 2>/dev/null) + and echo "$tag_glyph $tag " + + set -l branch (command git symbolic-ref HEAD 2>/dev/null | string replace -r '^refs/heads/' '') + and begin + [ -n "$theme_git_default_branches" ] + or set -l theme_git_default_branches master main (git config init.defaultBranch) + + [ "$theme_display_git_master_branch" != 'yes' -a "$theme_display_git_default_branch" != 'yes' ] + and contains $branch $theme_git_default_branches + and echo $branch_glyph + and return + + # truncate the middle of the branch name, but only if it's 25+ characters + set -l truncname $branch + [ "$theme_use_abbreviated_branch_name" = 'yes' ] + and set truncname (string replace -r '^(.{17}).{3,}(.{5})$' "\$1…\$2" $branch) + + echo $branch_glyph $truncname + and return + end + + # If we've already shown a tag we don't need to show a detached branch + if [ -z "$tag" ] + set -l branch (command git show-ref --head -s --abbrev | head -n1 2>/dev/null) + echo "$detached_glyph $branch" + end +end + +function __bobthefish_hg_branch -S -d 'Get the current hg branch' + set -l branch (command hg branch 2>/dev/null) + set -l book (command hg book | command grep \* | cut -d\ -f3) + echo "$branch_glyph $branch @ $book" +end + +function __bobthefish_pretty_parent -S -a child_dir -d 'Print a parent directory, shortened to fit the prompt' + set -q fish_prompt_pwd_dir_length + or set -l fish_prompt_pwd_dir_length 1 + + # Replace $HOME with ~ + set -l real_home ~ + set -l parent_dir (string replace -r '^'(__bobthefish_escape_regex "$real_home")'($|/)' '~$1' (__bobthefish_dirname $child_dir)) + + # Must check whether `$parent_dir = /` if using native dirname + if [ -z "$parent_dir" ] + echo -n / + return + end + + if [ $fish_prompt_pwd_dir_length -eq 0 ] + echo -n "$parent_dir/" + return + end + + string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' "$parent_dir/" +end + +function __bobthefish_ignore_vcs_dir -a real_pwd -d 'Check whether the current directory should be ignored as a VCS segment' + for p in $theme_vcs_ignore_paths + set ignore_path (realpath $p 2>/dev/null) + switch $real_pwd/ + case $ignore_path/\* + echo 1 + return + end + end +end + +function __bobthefish_git_project_dir -S -a real_pwd -d 'Print the current git project base directory' + [ "$theme_display_git" = 'no' ] + and return + + set -q theme_vcs_ignore_paths + and [ (__bobthefish_ignore_vcs_dir $real_pwd) ] + and return + + if [ "$theme_git_worktree_support" != 'yes' ] + set -l git_toplevel (command git rev-parse --show-toplevel 2>/dev/null) + + [ -z "$git_toplevel" ] + and return + + # Support Git under WSL (see #336) + command -q wslpath + and set git_toplevel (command wslpath $git_toplevel) + + # If there are no symlinks, just use git toplevel + switch $real_pwd/ + case $git_toplevel/\* + echo $git_toplevel + return + end + + # Otherwise, we need to find the equivalent directory in the $PWD + set -l d $real_pwd + while not [ -z "$d" ] + if [ (realpath "$d") = "$git_toplevel" ] + echo $d + return + end + + [ "$d" = '/' ] + and return + + set d (__bobthefish_dirname $d) + end + return + end + + set -l git_dir (command git rev-parse --git-dir 2>/dev/null) + or return + + pushd $git_dir + set git_dir (__bobthefish_pwd) + popd + + switch $real_pwd/ + case $git_dir/\* + # Nothing works quite right if we're inside the git dir + # TODO: fix the underlying issues then re-enable the stuff below + + # # if we're inside the git dir, sweet. just return that. + # set -l toplevel (command git rev-parse --show-toplevel 2>/dev/null) + # if [ "$toplevel" ] + # switch $git_dir/ + # case $toplevel/\* + # echo $git_dir + # end + # end + return + end + + set -l project_dir (__bobthefish_dirname $git_dir) + + switch $real_pwd/ + case $project_dir/\* + echo $project_dir + return + end + + set project_dir (command git rev-parse --show-toplevel 2>/dev/null) + switch $real_pwd/ + case $project_dir/\* + echo $project_dir + end +end + +function __bobthefish_hg_project_dir -S -a real_pwd -d 'Print the current hg project base directory' + [ "$theme_display_hg" = 'yes' ] + or return + + set -q theme_vcs_ignore_paths + and [ (__bobthefish_ignore_vcs_dir $real_pwd) ] + and return + + set -l d $real_pwd + while not [ -z "$d" ] + if [ -e $d/.hg ] + command hg root --cwd "$d" 2>/dev/null + return + end + + [ "$d" = '/' ] + and return + + set d (__bobthefish_dirname $d) + end +end + +function __bobthefish_project_pwd -S -a project_root_dir -a real_pwd -d 'Print the working directory relative to project root' + set -q theme_project_dir_length + or set -l theme_project_dir_length 0 + + set -l project_dir (string replace -r '^'(__bobthefish_escape_regex "$project_root_dir")'($|/)' '' $real_pwd) + + if [ $theme_project_dir_length -eq 0 ] + echo -n $project_dir + return + end + + string replace -ar '(\.?[^/]{'"$theme_project_dir_length"'})[^/]*/' '$1/' $project_dir +end + +function __bobthefish_git_ahead -S -d 'Print the ahead/behind state for the current branch' + if [ "$theme_display_git_ahead_verbose" = 'yes' ] + __bobthefish_git_ahead_verbose + return + end + + set -l ahead 0 + set -l behind 0 + for line in (command git rev-list --left-right '@{upstream}...HEAD' 2>/dev/null) + switch "$line" + case '>*' + if [ $behind -eq 1 ] + echo '±' + return + end + set ahead 1 + case '<*' + if [ $ahead -eq 1 ] + echo "$git_plus_minus_glyph" + return + end + set behind 1 + end + end + + if [ $ahead -eq 1 ] + echo "$git_plus_glyph" + else if [ $behind -eq 1 ] + echo "$git_minus_glyph" + end +end + +function __bobthefish_git_ahead_verbose -S -d 'Print a more verbose ahead/behind state for the current branch' + set -l commits (command git rev-list --left-right '@{upstream}...HEAD' 2>/dev/null) + or return + + set -l behind (count (for arg in $commits; echo $arg; end | command grep '^<')) + set -l ahead (count (for arg in $commits; echo $arg; end | command grep -v '^<')) + + switch "$ahead $behind" + case '' # no upstream + case '0 0' # equal to upstream + return + case '* 0' # ahead of upstream + echo "$git_ahead_glyph$ahead" + case '0 *' # behind upstream + echo "$git_behind_glyph$behind" + case '*' # diverged from upstream + echo "$git_ahead_glyph$ahead$git_behind_glyph$behind" + end +end + +function __bobthefish_git_dirty_verbose -S -d 'Print a more verbose dirty state for the current working tree' + set -l changes (command git diff --numstat | awk '{ added += $1; removed += $2 } END { print "+" added "/-" removed }') + or return + + echo "$changes " | string replace -r '(\+0/(-0)?|/-0)' '' +end + +function __bobthefish_git_stashed -S -d 'Print the stashed state for the current branch' + if [ "$theme_display_git_stashed_verbose" = 'yes' ] + set -l stashed (command git rev-list --walk-reflogs --count refs/stash 2>/dev/null) + or return + + echo -n "$git_stashed_glyph$stashed" + else + command git rev-parse --verify --quiet refs/stash >/dev/null + and echo -n "$git_stashed_glyph" + end +end + + +# ============================== +# Segment functions +# ============================== + +function __bobthefish_start_segment -S -d 'Start a prompt segment' + set -l bg $argv[1] + set -e argv[1] + set -l fg $argv[1] + set -e argv[1] + + set_color normal # clear out anything bold or underline... + set_color -b $bg $fg $argv + + switch "$__bobthefish_current_bg" + case '' + # If there's no background, just start one + echo -n ' ' + case "$bg" + # If the background is already the same color, draw a separator + echo -ns $right_arrow_glyph ' ' + case '*' + # otherwise, draw the end of the previous segment and the start of the next + set_color $__bobthefish_current_bg + echo -ns $right_black_arrow_glyph ' ' + set_color $fg $argv + end + + set __bobthefish_current_bg $bg +end + +function __bobthefish_path_segment -S -a segment_dir -a path_type -d 'Display a shortened form of a directory' + set -l segment_color $color_path + set -l segment_basename_color $color_path_basename + + if not [ -w "$segment_dir" ] + set segment_color $color_path_nowrite + set segment_basename_color $color_path_nowrite_basename + end + + __bobthefish_start_segment $segment_color + + set -l directory + set -l parent + + switch "$segment_dir" + case / + set directory '/' + case "$HOME" + set directory '~' + case '*' + set parent (__bobthefish_pretty_parent "$segment_dir") + set directory (__bobthefish_basename "$segment_dir") + end + + [ "$theme_show_project_parent" != "no" -o "$path_type" != "project" ] + and echo -n $parent + + set_color -b $segment_basename_color + echo -ns $directory ' ' +end + +function __bobthefish_finish_segments -S -d 'Close open prompt segments' + if [ -n "$__bobthefish_current_bg" ] + set_color normal + set_color $__bobthefish_current_bg + echo -ns $right_black_arrow_glyph ' ' + end + + if [ "$theme_newline_cursor" = 'yes' ] + echo -ens "\n" + set_color $fish_color_autosuggestion + + if set -q theme_newline_prompt + echo -ens "$theme_newline_prompt" + else if [ "$theme_powerline_fonts" = 'no' -a "$theme_nerd_fonts" != 'yes' ] + echo -ns '> ' + else + echo -ns "$right_arrow_glyph " + end + else if [ "$theme_newline_cursor" = 'clean' ] + echo -ens "\n" + end + + set_color normal + set __bobthefish_current_bg +end + + +# ============================== +# Status segment +# ============================== + +function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a non-zero exit status, private mode, root user, and background jobs' + set -l nonzero + set -l superuser + set -l bg_jobs + + # Last exit was nonzero + [ $last_status -ne 0 ] + and set nonzero 1 + + # If superuser (uid == 0) + # + # Note that iff the current user is root and '/' is not writeable by root this + # will be wrong. But I can't think of a single reason that would happen, and + # it is literally 99.5% faster to check it this way, so that's a tradeoff I'm + # willing to make. + [ -w / -o -w /private/ ] + and [ (id -u) -eq 0 ] + and set superuser 1 + + # Jobs display + if set -q AUTOJUMP_SOURCED + # Autojump special case: check if there are jobs besides the `autojump` + # job, since that one is (briefly) backgrounded every time we `cd` + set bg_jobs (jobs -c | string match -v --regex '(Command|autojump)' | wc -l) + [ "$bg_jobs" -eq 0 ] + and set bg_jobs # clear it out so it doesn't show when `0` + else + if [ "$theme_display_jobs_verbose" = 'yes' ] + set bg_jobs (jobs -p | wc -l) + [ "$bg_jobs" -eq 0 ] + and set bg_jobs # clear it out so it doesn't show when `0` + else + # `jobs -p` is faster if we redirect to /dev/null, because it exits + # after the first match. We'll use that unless the user wants to + # display the actual job count + jobs -p >/dev/null + and set bg_jobs 1 + end + end + + if [ "$nonzero" -o "$fish_private_mode" -o "$superuser" -o "$bg_jobs" ] + __bobthefish_start_segment $color_initial_segment_exit + if [ "$nonzero" ] + set_color normal + set_color -b $color_initial_segment_exit + if [ "$theme_show_exit_status" = 'yes' ] + echo -ns $last_status ' ' + else + echo -n $nonzero_exit_glyph + end + end + + if [ "$fish_private_mode" ] + set_color normal + set_color -b $color_initial_segment_private + echo -n $private_glyph + end + + if [ "$superuser" ] + set_color normal + if [ -z "$FAKEROOTKEY" ] + set_color -b $color_initial_segment_su + else + set_color -b $color_initial_segment_exit + end + + echo -n $superuser_glyph + end + + if [ "$bg_jobs" ] + set_color normal + set_color -b $color_initial_segment_jobs + if [ "$theme_display_jobs_verbose" = 'yes' ] + echo -ns $bg_job_glyph $bg_jobs ' ' + else + echo -n $bg_job_glyph + end + end + end +end + + +# ============================== +# Container and VM segments +# ============================== + +function __bobthefish_prompt_vagrant -S -d 'Display Vagrant status' + [ "$theme_display_vagrant" = 'yes' -a -f Vagrantfile ] + or return + + # .vagrant/machines/$machine/$provider/id + for file in .vagrant/machines/*/*/id + read -l id <"$file" + + if [ -n "$id" ] + switch "$file" + case '*/virtualbox/id' + __bobthefish_prompt_vagrant_vbox $id + case '*/vmware_fusion/id' + __bobthefish_prompt_vagrant_vmware $id + case '*/parallels/id' + __bobthefish_prompt_vagrant_parallels $id + end + end + end +end + +function __bobthefish_prompt_vagrant_vbox -S -a id -d 'Display VirtualBox Vagrant status' + set -l vagrant_status + set -l vm_status (VBoxManage showvminfo --machinereadable $id 2>/dev/null | command grep 'VMState=' | tr -d '"' | cut -d '=' -f 2) + + switch "$vm_status" + case 'running' + set vagrant_status "$vagrant_status$vagrant_running_glyph" + case 'poweroff' + set vagrant_status "$vagrant_status$vagrant_poweroff_glyph" + case 'aborted' + set vagrant_status "$vagrant_status$vagrant_aborted_glyph" + case 'saved' + set vagrant_status "$vagrant_status$vagrant_saved_glyph" + case 'stopping' + set vagrant_status "$vagrant_status$vagrant_stopping_glyph" + case '' + set vagrant_status "$vagrant_status$vagrant_unknown_glyph" + end + + [ -z "$vagrant_status" ] + and return + + __bobthefish_start_segment $color_vagrant + echo -ns $vagrant_status ' ' +end + +function __bobthefish_prompt_vagrant_vmware -S -a id -d 'Display VMWare Vagrant status' + set -l vagrant_status + if [ (pgrep -f "$id") ] + set vagrant_status "$vagrant_status$vagrant_running_glyph" + else + set vagrant_status "$vagrant_status$vagrant_poweroff_glyph" + end + + [ -z "$vagrant_status" ] + and return + + __bobthefish_start_segment $color_vagrant + echo -ns $vagrant_status ' ' +end + +function __bobthefish_prompt_vagrant_parallels -S -d 'Display Parallels Vagrant status' + set -l vagrant_status + set -l vm_status (prlctl list $id -o status 2>/dev/null | command tail -1) + + switch "$vm_status" + case 'running' + set vagrant_status "$vagrant_status$vagrant_running_glyph" + case 'stopped' + set vagrant_status "$vagrant_status$vagrant_poweroff_glyph" + case 'paused' + set vagrant_status "$vagrant_status$vagrant_saved_glyph" + case 'suspended' + set vagrant_status "$vagrant_status$vagrant_saved_glyph" + case 'stopping' + set vagrant_status "$vagrant_status$vagrant_stopping_glyph" + case '' + set vagrant_status "$vagrant_status$vagrant_unknown_glyph" + end + + [ -z "$vagrant_status" ] + and return + + __bobthefish_start_segment $color_vagrant + echo -ns $vagrant_status ' ' +end + +function __bobthefish_prompt_docker -S -d 'Display Docker machine name' + [ "$theme_display_docker_machine" = 'no' -o -z "$DOCKER_MACHINE_NAME" ] + and return + + __bobthefish_start_segment $color_vagrant + echo -ns $DOCKER_MACHINE_NAME ' ' +end + +function __bobthefish_k8s_context -S -d 'Get the current k8s context' + set -l config_paths "$HOME/.kube/config" + [ -n "$KUBECONFIG" ] + and set config_paths (string split ':' "$KUBECONFIG") $config_paths + + for file in $config_paths + [ -f "$file" ] + or continue + + while read -l key val + if [ "$key" = 'current-context:' ] + set -l context (string trim -c '"\' ' -- $val) + [ -z "$context" ] + and return 1 + + echo $context + return + end + end <$file + end + + return 1 +end + +function __bobthefish_k8s_namespace -S -d 'Get the current k8s namespace' + kubectl config view --minify --output "jsonpath={..namespace}" +end + +function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context' + [ "$theme_display_k8s_context" = 'yes' ] + or return + + set -l context (__bobthefish_k8s_context) + or return + + [ "$theme_display_k8s_namespace" = 'yes' ] + and set -l namespace (__bobthefish_k8s_namespace) + + [ -z "$context" -o "$context" = 'default' ] + and [ -z "$namespace" -o "$namespace" = 'default' ] + and return + + set -l segment $k8s_glyph ' ' + [ "$context" != 'default' ] + and set segment $segment $context + [ "$namespace" != 'default' ] + and set segment $segment ':' $namespace + + __bobthefish_start_segment $color_k8s + echo -ns $segment ' ' +end + + +# ============================== +# Cloud Tools +# ============================== + +function __bobthefish_prompt_aws_vault_profile -S -d 'Show AWS Vault profile' + [ "$theme_display_aws_vault_profile" = 'yes' ] + or return + + [ -n "$AWS_VAULT" -a -n "$AWS_CREDENTIAL_EXPIRATION" ] + or return + + set -l profile $AWS_VAULT + + set -l now (date --utc +%s) + set -l expiry (date -d "$AWS_CREDENTIAL_EXPIRATION" +%s) + set -l diff_mins (math "floor(( $expiry - $now ) / 60)") + + set -l diff_time $diff_mins"m" + [ $diff_mins -le 0 ] + and set -l diff_time '0m' + [ $diff_mins -ge 60 ] + and set -l diff_time (math "floor($diff_mins / 60)")"h"(math "$diff_mins % 60")"m" + + set -l segment $profile ' (' $diff_time ')' + set -l status_color $color_aws_vault + [ $diff_mins -le 0 ] + and set -l status_color $color_aws_vault_expired + + __bobthefish_start_segment $status_color + echo -ns $segment ' ' +end + + +# ============================== +# User / hostname info segments +# ============================== + +# Polyfill for fish < 2.5.0 +if not type -q prompt_hostname + if not set -q __bobthefish_prompt_hostname + set -g __bobthefish_prompt_hostname (uname -n | string replace -r '\..*' '') + end + + function prompt_hostname + echo $__bobthefish_prompt_hostname + end +end + +function __bobthefish_prompt_user -S -d 'Display current user and hostname' + [ "$theme_display_user" = 'yes' -o \( "$theme_display_user" != 'no' -a -n "$SSH_CLIENT" \) -o \( -n "$default_user" -a "$USER" != "$default_user" \) ] + and set -l display_user + + [ "$theme_display_sudo_user" = 'yes' -a -n "$SUDO_USER" ] + and set -l display_sudo_user + + [ "$theme_display_hostname" = 'yes' -o \( "$theme_display_hostname" != 'no' -a -n "$SSH_CLIENT" \) ] + and set -l display_hostname + + if set -q display_user + __bobthefish_start_segment $color_username + echo -ns (whoami) + end + + if set -q display_sudo_user + if set -q display_user + echo -ns ' ' + else + __bobthefish_start_segment $color_username + end + echo -ns "($SUDO_USER)" + end + + if set -q display_hostname + if set -q display_user + or set -q display_sudo_user + # reset colors without starting a new segment... + # (so we can have a bold username and non-bold hostname) + set_color normal + set_color -b $color_hostname[1] $color_hostname[2..-1] + echo -ns '@' (prompt_hostname) + else + __bobthefish_start_segment $color_hostname + echo -ns (prompt_hostname) + end + end + + set -q display_user + or set -q display_sudo_user + or set -q display_hostname + and echo -ns ' ' +end + + +# ============================== +# Virtual environment segments +# ============================== + +function __bobthefish_rvm_parse_ruby -S -a ruby_string -a scope -d 'Parse RVM Ruby string' + # Function arguments: + # - 'ruby-2.2.3@rails', 'jruby-1.7.19'... + # - 'default' or 'current' + set -l IFS @ + echo "$ruby_string" | read __ruby __rvm_{$scope}_ruby_gemset __ + set IFS - + echo "$__ruby" | read __rvm_{$scope}_ruby_interpreter __rvm_{$scope}_ruby_version __ + set -e __ruby + set -e __ +end + +function __bobthefish_rvm_info -S -d 'Current Ruby information from RVM' + # look for rvm install path + set -q rvm_path + or set -l rvm_path ~/.rvm /usr/local/rvm + + # More `sed`/`grep`/`cut` magic... + set -l __rvm_default_ruby (grep GEM_HOME $rvm_path/environments/default 2>/dev/null | sed -e"s/'//g" | sed -e's/.*\///') + set -l __rvm_current_ruby (rvm-prompt i v g) + + [ "$__rvm_default_ruby" = "$__rvm_current_ruby" ] + and return + + set -l __rvm_default_ruby_gemset + set -l __rvm_default_ruby_interpreter + set -l __rvm_default_ruby_version + set -l __rvm_current_ruby_gemset + set -l __rvm_current_ruby_interpreter + set -l __rvm_current_ruby_version + + # Parse default and current Rubies to global variables + __bobthefish_rvm_parse_ruby $__rvm_default_ruby default + __bobthefish_rvm_parse_ruby $__rvm_current_ruby current + # Show unobtrusive RVM prompt + + # If interpreter differs form default interpreter, show everything: + if [ "$__rvm_default_ruby_interpreter" != "$__rvm_current_ruby_interpreter" ] + if [ "$__rvm_current_ruby_gemset" = 'global' ] + rvm-prompt i v + else + rvm-prompt i v g + end + # If version differs form default version + else if [ "$__rvm_default_ruby_version" != "$__rvm_current_ruby_version" ] + if [ "$__rvm_current_ruby_gemset" = 'global' ] + rvm-prompt v + else + rvm-prompt v g + end + # If gemset differs form default or 'global' gemset, just show it + else if [ "$__rvm_default_ruby_gemset" != "$__rvm_current_ruby_gemset" ] + rvm-prompt g + end +end + +function __bobthefish_prompt_rubies -S -d 'Display current Ruby information' + [ "$theme_display_ruby" = 'no' ] + and return + + set -l ruby_version + if type -fq rvm-prompt + set ruby_version (__bobthefish_rvm_info) + else if type -fq rbenv + set ruby_version (rbenv version-name) + # Don't show global ruby version... + set -q RBENV_ROOT + or set -l RBENV_ROOT $HOME/.rbenv + + [ -e "$RBENV_ROOT/version" ] + and read -l global_ruby_version <"$RBENV_ROOT/version" + + [ "$global_ruby_version" ] + or set -l global_ruby_version system + + [ "$ruby_version" = "$global_ruby_version" ] + and return + else if type -q chruby # chruby is implemented as a function, so omitting the -f is intentional + set ruby_version $RUBY_VERSION + else if type -fq asdf + set -l asdf_current_ruby (asdf current ruby 2>/dev/null) + or return + + echo "$asdf_current_ruby" | read -l _asdf_plugin asdf_ruby_version asdf_provenance + + # If asdf changes their ruby version provenance format, update this to match + [ (string trim -- "$asdf_provenance") = "$HOME/.tool-versions" ] + and return + + set ruby_version $asdf_ruby_version + end + + [ -z "$ruby_version" ] + and return + + __bobthefish_start_segment $color_rvm + echo -ns $ruby_glyph $ruby_version ' ' +end + +function __bobthefish_prompt_golang -S -a real_pwd -d 'Display current Go information' + # setting is 'no', don't display the prompt + [ "$theme_display_go" = 'no' ] + and return + + # find the closest go.mod + set -l gomod_version "0" + set -l d $real_pwd + while not [ -z "$d" ] + if [ -e $d/go.mod ] + grep "^go " "$d/go.mod" | read __ gomod_version + break + end + + [ "$d" = "/" ] + and return + + set d (__bobthefish_dirname $d) + end + + # no go.mod, not in a go project, don't display the prompt + if [ "$gomod_version" = "0" ] + return + end + + # check if there's a Go executable + set -l no_go_installed "0" + set -l actual_go_version "0" + set -l high_enough_version "0" + if type -fq go + set actual_go_version (go version | string match -r 'go version go(\\d+\\.\\d+(?:\\.\\d+)?)' -g) + if printf "%s\n%s" "$gomod_version" "$actual_go_version" | sort --check=silent --version-sort + set high_enough_version "1" + end + else + set no_go_installed "1" + end + + if [ "$high_enough_version" = "1" ] + __bobthefish_start_segment $color_virtualgo + else + __bobthefish_start_segment $color_rvm + end + + echo -ns $go_glyph + echo -ns "$gomod_version " + + # showing the prompt -- but plain ( for 'yes' ) or verbose? + if [ "$theme_display_go" = "verbose" ] + if [ "$actual_go_version" != "0" ] + # show the prompt with the required version AND the currently available + # version; same color rules as above + echo -ns " ($actual_go_version)" + end + end +end + +function __bobthefish_virtualenv_python_version -S -d 'Get current Python version' + switch (python --version 2>&1 | tr '\n' ' ') + case 'Python 2*PyPy*' + echo $pypy_glyph + case 'Python 3*PyPy*' + echo -s $pypy_glyph $superscript_glyph[3] + case 'Python 2*' + echo $superscript_glyph[2] + case 'Python 3*' + echo $superscript_glyph[3] + end +end + +function __bobthefish_prompt_virtualfish -S -d "Display current Python virtual environment (only for virtualfish, virtualenv's activate.fish changes prompt by itself) or conda environment." + type -fq python + or return + + [ "$theme_display_virtualenv" = 'no' -o -z "$VIRTUAL_ENV" -a -z "$CONDA_DEFAULT_ENV" ] + and return + + set -l version_glyph (__bobthefish_virtualenv_python_version) + set -l prompt_style 'default' + + if [ "$version_glyph" ] + __bobthefish_start_segment $color_virtualfish + if string match -q "Python 2*" (python --version 2>&1 | string trim) + set prompt_style 'verbose' + else if [ "$theme_display_virtualenv" = 'verbose' ] + set prompt_style 'verbose' + end + + if [ "$prompt_style" = 'verbose' ] + echo -ns $virtualenv_glyph $version_glyph ' ' + else + echo -ns $virtualenv_glyph + end + + end + + if [ "$VIRTUAL_ENV" ] + echo -ns (basename "$VIRTUAL_ENV") ' ' + else if [ "$CONDA_DEFAULT_ENV" ] + echo -ns (basename "$CONDA_DEFAULT_ENV") ' ' + end +end + +function __bobthefish_prompt_virtualgo -S -d 'Display current Go virtual environment' + [ "$theme_display_virtualgo" = 'no' -o -z "$VIRTUALGO" ] + and return + + __bobthefish_start_segment $color_virtualgo + echo -ns $go_glyph ' ' (basename "$VIRTUALGO") ' ' + set_color normal +end + +function __bobthefish_prompt_desk -S -d 'Display current desk environment' + [ "$theme_display_desk" = 'no' -o -z "$DESK_ENV" ] + and return + + __bobthefish_start_segment $color_desk + echo -ns $desk_glyph ' ' (basename -a -s '.fish' "$DESK_ENV") ' ' + set_color normal +end + +function __bobthefish_prompt_find_file_up -S -d 'Find file(s), going up the parent directories' + set -l dir "$argv[1]" + set -l files $argv[2..-1] + + if test -z "$dir" + or test -z "$files" + return 1 + end + + while [ "$dir" ] + for f in $files + if [ -e "$dir/$f" ] + return + end + end + + [ "$dir" = '/' ] + and return 1 + + set dir (__bobthefish_dirname "$dir") + end + return 1 +end + +function __bobthefish_prompt_node -S -d 'Display current node version' + set -l should_show + + if [ "$theme_display_node" = 'always' -o "$theme_display_nvm" = 'yes' ] + set should_show 1 + else if [ "$theme_display_node" = 'yes' ] + __bobthefish_prompt_find_file_up "$PWD" package.json .nvmrc .node-version + and set should_show 1 + end + + [ -z "$should_show" ] + and return + + set -l node_manager + set -l node_manager_dir + + if type -q nvm + set node_manager 'nvm' + set node_manager_dir $NVM_DIR + else if type -fq fnm + set node_manager 'fnm' + set node_manager_dir $FNM_DIR + end + + [ -n "$node_manager_dir" ] + or return + + set -l node_version ("$node_manager" current 2> /dev/null) + + [ -z $node_version -o "$node_version" = 'none' -o "$node_version" = 'system' ] + and return + + [ -n "$color_nvm" ] + and set -x color_node $color_nvm + + __bobthefish_start_segment $color_node + echo -ns $node_glyph $node_version ' ' + set_color normal +end + +function __bobthefish_prompt_nix -S -d 'Display current nix environment' + [ "$theme_display_nix" = 'no' -o -z "$IN_NIX_SHELL" ] + and return + + __bobthefish_start_segment $color_nix + echo -ns $nix_glyph $IN_NIX_SHELL ' ' + + set_color normal +end + +# ============================== +# VCS segments +# ============================== + +function __bobthefish_prompt_hg -S -a hg_root_dir -a real_pwd -d 'Display the actual hg state' + set -l dirty (command hg stat; or echo -n '*') + + set -l flags "$dirty" + [ "$flags" ] + and set flags '' + + set -l flag_colors $color_repo + if [ "$dirty" ] + set flag_colors $color_repo_dirty + end + + __bobthefish_path_segment $hg_root_dir project + + __bobthefish_start_segment $flag_colors + echo -ns $hg_glyph ' ' + + __bobthefish_start_segment $flag_colors + echo -ns (__bobthefish_hg_branch) $flags ' ' + set_color normal + + set -l project_pwd (__bobthefish_project_pwd $hg_root_dir $real_pwd) + if [ "$project_pwd" ] + if [ -w "$real_pwd" ] + __bobthefish_start_segment $color_path + else + __bobthefish_start_segment $color_path_nowrite + end + + echo -ns $project_pwd ' ' + end +end + +function __bobthefish_prompt_screen -S -d 'Display the screen name' + [ "$theme_display_screen" = 'no' -o -z "$STY" ] + and return + + __bobthefish_start_segment $color_screen + echo -ns (string split "." -- $STY)[2] ' ' + set_color normal +end + +function __bobthefish_prompt_git -S -a git_root_dir -a real_pwd -d 'Display the actual git state' + set -l dirty '' + if [ "$theme_display_git_dirty" != 'no' ] + set -l show_dirty (command git config --bool bash.showDirtyState 2>/dev/null) + if [ "$show_dirty" != 'false' ] + set dirty (command git diff --no-ext-diff --quiet --exit-code 2>/dev/null; or echo -n "$git_dirty_glyph") + if [ "$dirty" -a "$theme_display_git_dirty_verbose" = 'yes' ] + set dirty "$dirty"(__bobthefish_git_dirty_verbose) + end + end + end + + set -l staged (command git diff --cached --no-ext-diff --quiet --exit-code 2>/dev/null; or echo -n "$git_staged_glyph") + set -l stashed (__bobthefish_git_stashed) + set -l ahead (__bobthefish_git_ahead) + + set -l new '' + if [ "$theme_display_git_untracked" != 'no' ] + set -l show_untracked (command git config --bool bash.showUntrackedFiles 2>/dev/null) + if [ "$show_untracked" != 'false' ] + set new (command git ls-files --other --exclude-standard --directory --no-empty-directory "$git_root_dir" 2>/dev/null) + if [ "$new" ] + set new "$git_untracked_glyph" + end + end + end + + set -l flags "$dirty$staged$stashed$ahead$new" + + [ "$flags" ] + and set flags " $flags" + + set -l flag_colors $color_repo + if [ "$dirty" ] + set flag_colors $color_repo_dirty + else if [ "$staged" ] + set flag_colors $color_repo_staged + end + + __bobthefish_path_segment $git_root_dir project + + __bobthefish_start_segment $flag_colors + echo -ns (__bobthefish_git_branch) $flags ' ' + set_color normal + + if [ "$theme_git_worktree_support" != 'yes' ] + set -l project_pwd (__bobthefish_project_pwd $git_root_dir $real_pwd) + if [ "$project_pwd" ] + if [ -w "$real_pwd" ] + __bobthefish_start_segment $color_path + else + __bobthefish_start_segment $color_path_nowrite + end + + echo -ns $project_pwd ' ' + end + return + end + + set -l project_pwd (command git rev-parse --show-prefix 2>/dev/null | string trim --right --chars=/) + set -l work_dir (command git rev-parse --show-toplevel 2>/dev/null) + + # only show work dir if it's a parent… + if [ "$work_dir" ] + switch $real_pwd/ + case $work_dir/\* + string match "$git_root_dir*" $work_dir >/dev/null + and set work_dir (string sub -s (math 1 + (string length $git_root_dir)) $work_dir) + case \* + set -e work_dir + end + end + + if [ "$project_pwd" -o "$work_dir" ] + set -l colors $color_path + if not [ -w "$real_pwd" ] + set colors $color_path_nowrite + end + + __bobthefish_start_segment $colors + + # handle work_dir != project dir + if [ "$work_dir" ] + set -l work_parent (__bobthefish_dirname $work_dir) + if [ "$work_parent" ] + echo -n "$work_parent/" + end + + set_color normal + set_color -b $color_repo_work_tree + echo -n (__bobthefish_basename $work_dir) + + set_color normal + set_color -b $colors + [ "$project_pwd" ] + and echo -n '/' + end + + echo -ns $project_pwd ' ' + else + set project_pwd $real_pwd + + string match "$git_root_dir*" $project_pwd >/dev/null + and set project_pwd (string sub -s (math 1 + (string length $git_root_dir)) $project_pwd) + + set project_pwd (string trim --left --chars=/ -- $project_pwd) + + if [ "$project_pwd" ] + set -l colors $color_path + if not [ -w "$real_pwd" ] + set colors $color_path_nowrite + end + + __bobthefish_start_segment $colors + + echo -ns $project_pwd ' ' + end + end +end + +function __bobthefish_prompt_dir -S -a real_pwd -d 'Display a shortened form of the current directory' + __bobthefish_path_segment "$real_pwd" pwd +end + + +# ============================== +# Apply theme +# ============================== + +function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' + # Save the last status for later (do this before anything else) + set -l last_status $status + + # Use a simple prompt on dumb terminals. + if [ "$TERM" = 'dumb' ] + echo '> ' + return + end + + __bobthefish_glyphs + __bobthefish_colors $theme_color_scheme + + type -q bobthefish_colors + and bobthefish_colors + + # Start each line with a blank slate + set -l __bobthefish_current_bg + + set -l real_pwd (__bobthefish_pwd) + + # Status flags and input mode + __bobthefish_prompt_status $last_status + + # User / hostname info + __bobthefish_prompt_user + + # Screen + __bobthefish_prompt_screen + + # Containers and VMs + __bobthefish_prompt_vagrant + __bobthefish_prompt_docker + __bobthefish_prompt_k8s_context + + # Cloud Tools + __bobthefish_prompt_aws_vault_profile + + # Virtual environments + __bobthefish_prompt_nix + __bobthefish_prompt_desk + __bobthefish_prompt_rubies + __bobthefish_prompt_golang $real_pwd + __bobthefish_prompt_virtualfish + __bobthefish_prompt_virtualgo + __bobthefish_prompt_node + + + # VCS + set -l git_root_dir (__bobthefish_git_project_dir $real_pwd) + set -l hg_root_dir (__bobthefish_hg_project_dir $real_pwd) + + if [ "$git_root_dir" -a "$hg_root_dir" ] + # only show the closest parent + switch $git_root_dir + case $hg_root_dir\* + __bobthefish_prompt_git $git_root_dir $real_pwd + case \* + __bobthefish_prompt_hg $hg_root_dir $real_pwd + end + else if [ "$git_root_dir" ] + __bobthefish_prompt_git $git_root_dir $real_pwd + else if [ "$hg_root_dir" ] + __bobthefish_prompt_hg $hg_root_dir $real_pwd + else + __bobthefish_prompt_dir $real_pwd + end + + __bobthefish_finish_segments +end diff --git a/dotfiles/.config/fish/functions/fish_right_prompt.fish b/dotfiles/.config/fish/functions/fish_right_prompt.fish new file mode 100644 index 0000000..38276f3 --- /dev/null +++ b/dotfiles/.config/fish/functions/fish_right_prompt.fish @@ -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 diff --git a/dotfiles/.config/fish/functions/fish_title.fish b/dotfiles/.config/fish/functions/fish_title.fish new file mode 100644 index 0000000..91793c2 --- /dev/null +++ b/dotfiles/.config/fish/functions/fish_title.fish @@ -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