diff --git a/LICENSE b/LICENSE index 093b08c..ba9a2db 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013-2014 Justin Hileman +Copyright (c) 2013-2021 Justin Hileman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 381fb89..85a6550 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # bobthefish -`bobthefish` is a Powerline-style, Git-aware [fish][fish] theme optimized for awesome. +`bobthefish` is a Powerline-style, Git-aware [fish][btf-fish] theme optimized for awesome. [![Oh My Fish](https://img.shields.io/badge/Framework-Oh_My_Fish-blue.svg?style=flat)](https://github.com/oh-my-fish/oh-my-fish) [![MIT License](https://img.shields.io/github/license/oh-my-fish/theme-bobthefish.svg?style=flat)](/LICENSE.md) -![bobthefish][screencast] +![bobthefish][btf-screencast] ### Installation @@ -13,15 +13,15 @@ Be sure to have Oh My Fish installed. Then just: omf install bobthefish -You will need a [Powerline-patched font][patching] for this to work, unless you enable the compatibility fallback option: +You will need a [Powerline-patched font][btf-patching] for this to work, unless you enable the compatibility fallback option: set -g theme_powerline_fonts no -[I recommend picking one of these][fonts]. For more advanced awesome, install a [nerd fonts patched font][nerd-fonts], and enable nerd fonts support: +[I recommend picking one of these][btf-fonts]. For more advanced awesome, install a [nerd fonts patched font][btf-nerd-fonts], and enable nerd fonts support: set -g theme_nerd_fonts yes -This theme is based loosely on [agnoster][agnoster]. +This theme is based loosely on [agnoster][btf-agnoster]. ### Features @@ -47,7 +47,7 @@ This theme is based loosely on [agnoster][agnoster]. * Current RVM, rbenv or chruby (Ruby) version * Current virtualenv (Python) version * _If you use virtualenv, you will probably need to disable the default virtualenv prompt, since it doesn't play nice with fish: `set -x VIRTUAL_ENV_DISABLE_PROMPT 1`_ - * Current NVM version (Nodejs) (inactive by default; see configurations in the next paragraph) + * Current NVM/FNM version (Nodejs) (inactive by default; see configurations in the next paragraph) * Abbreviated parent directory * Current directory, or Git or Mercurial project name * Current project's repo branch (branch-glyph master) or detached head (`➦` d0dfd9b) @@ -74,7 +74,8 @@ set -g theme_display_git_untracked no set -g theme_display_git_ahead_verbose yes set -g theme_display_git_dirty_verbose yes set -g theme_display_git_stashed_verbose yes -set -g theme_display_git_master_branch yes +set -g theme_display_git_default_branch yes +set -g theme_git_default_branches master main set -g theme_git_worktree_support yes set -g theme_use_abbreviated_branch_name yes set -g theme_display_vagrant yes @@ -84,7 +85,7 @@ set -g theme_display_hg yes set -g theme_display_virtualenv no set -g theme_display_nix no set -g theme_display_ruby no -set -g theme_display_nvm yes +set -g theme_display_node yes set -g theme_display_user ssh set -g theme_display_hostname ssh set -g theme_display_vi no @@ -108,6 +109,10 @@ set -g theme_project_dir_length 1 set -g theme_newline_cursor yes set -g theme_newline_prompt '$ ' ``` +**Git options** + +- `theme_display_git_default_branch`. By default theme will hide/collapse the branch name in your prompt when you are using a Git _default branch_ i.e. historically `master` and often `main` now. Set to `yes` to stop these branches from being hidden/collapsed. +- `theme_git_default_branches`. The big cloud repos (GitHub, Bitbucket, GitLab et al.) are moving away from using `master` as the default branch name, and allow you to choose your own. As of version **2.28**, Git also supports custom default branch names via the `init.defaultBranch` config option. If our defaults of `master main` don't suit you, you can add/remove names in thist list i.e. `main trunk`. This ensures correct hiding/collapsing behaviour with custom default branch names (unless option above is activated). **Title options** @@ -119,11 +124,12 @@ set -g theme_newline_prompt '$ ' **Prompt options** - `theme_display_ruby`. Use `no` to completely hide all information about Ruby version. By default Ruby version displayed if there is the difference from default settings. -- `theme_display_nvm`. If set to `yes`, will display current NVM node version. +- `theme_display_node`. If set to `yes`, will display current NVM or FNM node version. - `theme_display_vagrant`. This feature is disabled by default, use `yes` to display Vagrant status in your prompt. Please note that only the VirtualBox and VMWare providers are supported. - `theme_display_vi`. By default the vi mode indicator will be shown if vi or hybrid key bindings are enabled. Use `no` to hide the indicator, or `yes` to show the indicator. - `theme_display_k8s_context`. This feature is disabled by default. Use `yes` to show the current kubernetes context (`> kubectl config current-context`). - `theme_display_k8s_namespace`. This feature is disabled by default. Use `yes` to show the current kubernetes namespace. +- `theme_display_aws_vault_profile`. This feature is disabled by default. Use `yes` to show the currently executing [AWS Vault](https://github.com/99designs/aws-vault) profile. - `theme_display_user`. If set to `yes`, display username always, if set to `ssh`, only when an SSH-Session is detected, if set to no, never. - `theme_display_hostname`. Same behaviour as `theme_display_user`. - `theme_display_sudo_user`. If set to `yes`, displays the sudo-username in a root shell. For example, when calling `sudo -s` and having this option set to `yes`, the username of the user, who called `sudo -s`, will be displayed. @@ -138,12 +144,12 @@ set -g theme_newline_prompt '$ ' **Color scheme options** -| ![dark][dark] | ![light][light] | -| ----------------------- | ----------------------------------- | -| ![solarized][solarized] | ![solarized-light][solarized-light] | -| ![base16][base16] | ![base16-light][base16-light] | -| ![zenburn][zenburn] | ![terminal-dark][terminal-dark] | -| ![nord][nord] | | +| ![dark][btf-dark] | ![light][btf-light] | +| --------------------------- | --------------------------------------- | +| ![solarized][btf-solarized] | ![solarized-light][btf-solarized-light] | +| ![base16][btf-base16] | ![base16-light][btf-base16-light] | +| ![zenburn][btf-zenburn] | ![terminal-dark][btf-terminal-dark] | +| ![nord][btf-nord] | | You can use the function `bobthefish_display_colors` to preview the prompts in any color scheme. @@ -224,19 +230,19 @@ end ``` -[fish]: https://github.com/fish-shell/fish-shell -[screencast]: https://cloud.githubusercontent.com/assets/53660/18028510/f16f6b2c-6c35-11e6-8eb9-9f23ea3cce2e.gif -[patching]: https://powerline.readthedocs.org/en/master/installation.html#patched-fonts -[fonts]: https://github.com/Lokaltog/powerline-fonts -[nerd-fonts]: https://github.com/ryanoasis/nerd-fonts -[agnoster]: https://gist.github.com/agnoster/3712874 +[btf-fish]: https://github.com/fish-shell/fish-shell +[btf-screencast]: https://cloud.githubusercontent.com/assets/53660/18028510/f16f6b2c-6c35-11e6-8eb9-9f23ea3cce2e.gif +[btf-patching]: https://powerline.readthedocs.org/en/master/installation.html#patched-fonts +[btf-fonts]: https://github.com/Lokaltog/powerline-fonts +[btf-nerd-fonts]: https://github.com/ryanoasis/nerd-fonts +[btf-agnoster]: https://gist.github.com/agnoster/3712874 -[dark]: https://cloud.githubusercontent.com/assets/53660/16141569/ee2bbe4a-3411-11e6-85dc-3d9b0226e833.png "dark" -[light]: https://cloud.githubusercontent.com/assets/53660/16141570/f106afc6-3411-11e6-877d-fc2a8f6d3175.png "light" -[solarized]: https://cloud.githubusercontent.com/assets/53660/16141572/f7724032-3411-11e6-8771-b43769e7afec.png "solarized" -[solarized-light]: https://cloud.githubusercontent.com/assets/53660/16141575/fbed8036-3411-11e6-92e9-90da6d45f94b.png "solarized-light" -[base16]: https://cloud.githubusercontent.com/assets/53660/16141577/0134763a-3412-11e6-9cca-6040d39c8fd4.png "base16" -[base16-light]: https://cloud.githubusercontent.com/assets/53660/16141579/02f7245e-3412-11e6-97c6-5f3cecffb73c.png "base16-light" -[zenburn]: https://cloud.githubusercontent.com/assets/53660/16141580/06229dd4-3412-11e6-84aa-a48de127b6da.png "zenburn" -[terminal-dark]: https://cloud.githubusercontent.com/assets/53660/16141583/0b3e8eea-3412-11e6-8068-617c5371f6ea.png "terminal-dark" -[nord]: https://user-images.githubusercontent.com/39213657/72811435-f64ca800-3c5f-11ea-8711-dcce8cfc50fb.png "nord" +[btf-dark]: https://cloud.githubusercontent.com/assets/53660/16141569/ee2bbe4a-3411-11e6-85dc-3d9b0226e833.png "dark" +[btf-light]: https://cloud.githubusercontent.com/assets/53660/16141570/f106afc6-3411-11e6-877d-fc2a8f6d3175.png "light" +[btf-solarized]: https://cloud.githubusercontent.com/assets/53660/16141572/f7724032-3411-11e6-8771-b43769e7afec.png "solarized" +[btf-solarized-light]: https://cloud.githubusercontent.com/assets/53660/16141575/fbed8036-3411-11e6-92e9-90da6d45f94b.png "solarized-light" +[btf-base16]: https://cloud.githubusercontent.com/assets/53660/16141577/0134763a-3412-11e6-9cca-6040d39c8fd4.png "base16" +[btf-base16-light]: https://cloud.githubusercontent.com/assets/53660/16141579/02f7245e-3412-11e6-97c6-5f3cecffb73c.png "base16-light" +[btf-zenburn]: https://cloud.githubusercontent.com/assets/53660/16141580/06229dd4-3412-11e6-84aa-a48de127b6da.png "zenburn" +[btf-terminal-dark]: https://cloud.githubusercontent.com/assets/53660/16141583/0b3e8eea-3412-11e6-8068-617c5371f6ea.png "terminal-dark" +[btf-nord]: https://user-images.githubusercontent.com/39213657/72811435-f64ca800-3c5f-11ea-8711-dcce8cfc50fb.png "nord" diff --git a/functions/__bobthefish_colors.fish b/functions/__bobthefish_colors.fish index bf2f299..17c8605 100644 --- a/functions/__bobthefish_colors.fish +++ b/functions/__bobthefish_colors.fish @@ -29,10 +29,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant brcyan $colorfg set -x color_tf 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_rvm brmagenta $colorfg --bold - set -x color_nvm brgreen $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 @@ -63,10 +65,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant brcyan $colorfg set -x color_tf 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_rvm brmagenta $colorfg --bold - set -x color_nvm brgreen $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 @@ -97,10 +101,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant brcyan $colorfg set -x color_tf 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_rvm brmagenta $colorfg --bold - set -x color_nvm brgreen $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 @@ -131,10 +137,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant brcyan $colorfg set -x color_tf 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_rvm brmagenta $colorfg --bold - set -x color_nvm brgreen $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 @@ -171,10 +179,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $blue $green --bold set -x color_tf $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_rvm $red $grey --bold - set -x color_nvm $green $white --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 @@ -222,10 +232,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $base0C $colorfg --bold set -x color_tf $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_rvm $base08 $colorfg --bold - set -x color_nvm $base0B $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 @@ -273,10 +285,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $base0C $colorfg --bold set -x color_tf $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_rvm $base08 $colorfg --bold - set -x color_nvm $base0B $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 @@ -324,10 +338,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $violet $colorfg --bold set -x color_tf $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_rvm $red $colorfg --bold - set -x color_nvm $green $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 @@ -375,10 +391,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $violet $colorfg --bold set -x color_tf $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_rvm $red $colorfg --bold - set -x color_nvm $green $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 @@ -419,10 +437,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $blue[1] $white --bold set -x color_tf $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_rvm $ruby_red $grey[1] --bold - set -x color_nvm $green $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 @@ -462,10 +482,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $blue[2] $fg[2] --bold set -x color_tf $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_rvm $red[2] $fg[2] --bold - set -x color_nvm $green[1] $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 @@ -507,10 +529,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $pink $bg --bold set -x color_tf $pink $bg --bold set -x color_k8s $green $fg --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_rvm $red $bg --bold - set -x color_nvm $green $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 @@ -536,10 +560,10 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -l colorfg $base00 - set -x color_initial_segment_exit $base05 $base08 --bold + set -x color_initial_segment_exit $base05 $base0B --bold set -x color_initial_segment_private $base05 $base02 - set -x color_initial_segment_su $base05 $base0B --bold - set -x color_initial_segment_jobs $base08 $base0D --bold + 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 @@ -558,10 +582,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $base02 $colorfg --bold set -x color_tf $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_rvm $base09 $colorfg --bold - set -x color_nvm $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 @@ -602,10 +628,12 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vagrant $blue[1] $white --bold set -x color_tf $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_rvm $ruby_red $grey[1] --bold - set -x color_nvm $green[1] $white --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 @@ -669,6 +697,8 @@ function __bobthefish_user_color_scheme_deprecated 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 diff --git a/functions/bobthefish_display_colors.fish b/functions/bobthefish_display_colors.fish index 836de13..e1dfc62 100644 --- a/functions/bobthefish_display_colors.fish +++ b/functions/bobthefish_display_colors.fish @@ -141,5 +141,13 @@ function bobthefish_display_colors -a color_scheme -d 'Print example prompt colo echo -ns $desk_glyph desk ' ' __bobthefish_finish_segments + __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 + echo -e "\n" end diff --git a/fish_greeting.fish b/functions/fish_greeting.fish similarity index 100% rename from fish_greeting.fish rename to functions/fish_greeting.fish diff --git a/fish_mode_prompt.fish b/functions/fish_mode_prompt.fish similarity index 100% rename from fish_mode_prompt.fish rename to functions/fish_mode_prompt.fish diff --git a/fish_prompt.fish b/functions/fish_prompt.fish similarity index 92% rename from fish_prompt.fish rename to functions/fish_prompt.fish index 1f86ca5..c5e97a2 100644 --- a/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -23,13 +23,15 @@ # set -g theme_display_git_ahead_verbose yes # set -g theme_display_git_dirty_verbose yes # set -g theme_display_git_stashed_verbose yes -# set -g theme_display_git_master_branch yes +# set -g theme_display_git_default_branch yes +# set -g theme_git_default_branches main trunk # set -g theme_git_worktree_support yes # set -g theme_display_tf_workspace yes # set -g theme_display_vagrant yes # set -g theme_display_docker_machine no # set -g theme_display_k8s_context yes # set -g theme_display_k8s_namespace no +# set -g theme_display_aws_vault_profile yes # set -g theme_display_hg yes # set -g theme_display_virtualenv no # set -g theme_display_nix no @@ -38,7 +40,7 @@ # set -g theme_display_hostname ssh # set -g theme_display_sudo_user yes # set -g theme_display_vi no -# set -g theme_display_nvm yes +# set -g theme_display_node yes # set -g theme_avoid_ambiguous_glyphs yes # set -g theme_powerline_fonts no # set -g theme_nerd_fonts yes @@ -77,18 +79,22 @@ function __bobthefish_escape_regex -a str -d 'A backwards-compatible `string esc end function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish)' - set -l ref (command git symbolic-ref HEAD 2>/dev/null) + set -l branch (command git symbolic-ref HEAD 2>/dev/null | string replace -r '^refs/heads/' '') and begin - [ "$theme_display_git_master_branch" != 'yes' -a "$ref" = 'refs/heads/master' ] + [ -n "$theme_git_default_branches" ] + or set -l theme_git_default_branches master main + + [ "$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 $ref + set -l truncname $branch [ "$theme_use_abbreviated_branch_name" = 'yes' ] - and set truncname (string replace -r '^(.{28}).{3,}(.{5})$' "\$1…\$2" $ref) + and set truncname (string replace -r '^(.{17}).{3,}(.{5})$' "\$1…\$2" $branch) - string replace -r '^refs/heads/' "$branch_glyph " $truncname + echo $branch_glyph $truncname and return end @@ -394,7 +400,7 @@ function __bobthefish_finish_segments -S -d 'Close open prompt segments' if set -q theme_newline_prompt echo -ens "$theme_newline_prompt" - else if [ "$theme_powerline_fonts" = "no" -a "$theme_nerd_fonts" != "yes" ] + else if [ "$theme_powerline_fonts" = 'no' -a "$theme_nerd_fonts" != 'yes' ] echo -ns '> ' else echo -ns "$right_arrow_glyph " @@ -648,12 +654,45 @@ function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context' and [ -z $namespace -o "$namespace" = 'default' ] and return - set -l segment $k8s_glyph " " $context + set -l segment $k8s_glyph ' ' $context [ -n "$namespace" ] - and set segment $segment ":" $namespace + and set segment $segment ':' $namespace __bobthefish_start_segment $color_k8s - echo -ns $segment " " + 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_SESSION_EXPIRATION" ] + or return + + set -l profile $AWS_VAULT + + set -l now (date --utc +%s) + set -l expiry (date -d "$AWS_SESSION_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 @@ -865,20 +904,37 @@ function __bobthefish_prompt_desk -S -d 'Display current desk environment' and return __bobthefish_start_segment $color_desk - echo -ns $desk_glyph ' ' (basename -a -s ".fish" "$DESK_ENV") ' ' + echo -ns $desk_glyph ' ' (basename -a -s '.fish' "$DESK_ENV") ' ' set_color normal end -function __bobthefish_prompt_nvm -S -d 'Display current node version through NVM' - [ "$theme_display_nvm" = 'yes' -a -n "$NVM_DIR" ] +function __bobthefish_prompt_node -S -d 'Display current node version' + [ "$theme_display_node" = 'yes' -o "$theme_display_nvm" = 'yes' ] or return - set -l node_version (nvm current 2> /dev/null) + 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 - __bobthefish_start_segment $color_nvm + [ -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 @@ -902,7 +958,7 @@ function __bobthefish_prompt_hg -S -a hg_root_dir -a real_pwd -d 'Display the ac set -l flags "$dirty" [ "$flags" ] - and set flags "" + and set flags '' set -l flag_colors $color_repo if [ "$dirty" ] @@ -1064,8 +1120,8 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' set -l last_status $status # Use a simple prompt on dumb terminals. - if [ "$TERM" = "dumb" ] - echo "> " + if [ "$TERM" = 'dumb' ] + echo '> ' return end @@ -1090,13 +1146,16 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' __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_virtualfish __bobthefish_prompt_virtualgo - __bobthefish_prompt_nvm + __bobthefish_prompt_node set -l real_pwd (__bobthefish_pwd) diff --git a/fish_right_prompt.fish b/functions/fish_right_prompt.fish similarity index 94% rename from fish_right_prompt.fish rename to functions/fish_right_prompt.fish index bd6ee94..ef54772 100644 --- a/fish_right_prompt.fish +++ b/functions/fish_right_prompt.fish @@ -63,7 +63,9 @@ function __bobthefish_timestamp -S -d 'Show the current timestamp' or set -l theme_date_format "+%c" echo -n ' ' - env TZ="$theme_date_timezone" date $theme_date_format + 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' diff --git a/fish_title.fish b/functions/fish_title.fish similarity index 100% rename from fish_title.fish rename to functions/fish_title.fish