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 8b8ad44..72405d1 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,32 @@ # 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 + +## Installation 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 +## Features * A helpful, but not too distracting, greeting. * A subtle timestamp hanging out off to the right. @@ -35,7 +37,8 @@ This theme is based loosely on [agnoster][agnoster]. * Visual indication that you can't write to the current directory. -### The Prompt + +## The Prompt * Status flags: * Previous command failed (**`!`**) @@ -47,7 +50,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) @@ -63,93 +66,236 @@ This theme is based loosely on [agnoster][agnoster]. * Abbreviated project-relative path -### Configuration -You can override some of the following default options in your `config.fish`: +## Configuration + +You can override theme defaults in a Fish config file (for example `~/.config/fish/conf.d/bobthefish.fish`): ```fish -set -g theme_display_git no -set -g theme_display_git_dirty no -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_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 -set -g theme_display_docker_machine no -set -g theme_display_k8s_context yes -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_user ssh -set -g theme_display_hostname ssh -set -g theme_display_vi no -set -g theme_display_date no -set -g theme_display_cmd_duration yes -set -g theme_title_display_process yes -set -g theme_title_display_path no -set -g theme_title_display_user yes -set -g theme_title_use_abbreviated_path no -set -g theme_date_format "+%a %H:%M" -set -g theme_date_timezone America/Los_Angeles -set -g theme_avoid_ambiguous_glyphs yes -set -g theme_powerline_fonts no set -g theme_nerd_fonts yes -set -g theme_show_exit_status yes -set -g theme_display_jobs_verbose yes -set -g default_user your_normal_user set -g theme_color_scheme dark -set -g fish_prompt_pwd_dir_length 0 -set -g theme_project_dir_length 1 -set -g theme_newline_cursor yes -set -g theme_newline_prompt '$ ' +set -g theme_display_user ssh +set -g default_user bobthecow ``` -**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** - -- `theme_title_display_process`. By default theme doesn't show current process name in terminal title. If you want to show it, just set to `yes`. -- `theme_title_display_path`. Use `no` to hide current working directory from title. -- `theme_title_display_user`. Set to `yes` to show the current user in the tab title (unless you're the default user). -- `theme_title_use_abbreviated_path`. Default is `yes`. This means your home directory will be displayed as `~` and `/usr/local` as `/u/local`. Set it to `no` if you prefer full paths in title. - -**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_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. -- `theme_show_exit_status`. Set this option to `yes` to have the prompt show the last exit code if it was non_zero instead of just the exclamation mark. -- `theme_display_jobs_verbose`. If set to `yes` this option displays the number of currently running background jobs next to the percent sign. -- `theme_git_worktree_support`. If you do any git worktree shenanigans, setting this to `yes` will fix incorrect project-relative path display. If you don't do any git worktree shenanigans, leave it disabled. It's faster this way :) -- `theme_use_abbreviated_branch_name`. Set to `yes` to truncate git branch names in the prompt. -- `fish_prompt_pwd_dir_length`. bobthefish respects the Fish `$fish_prompt_pwd_dir_length` setting to abbreviate the prompt path. Set to `0` to show the full path, `1` (default) to show only the first character of each parent directory name, or any other number to show up to that many characters. -- `theme_project_dir_length`. The same as `$fish_prompt_pwd_dir_length`, but for the path relative to the current project root. Defaults to `0`; set to any other number to show an abbreviated path. -- `theme_newline_cursor`. Use `yes` to have cursor start on a new line. By default the prompt is only one line. When working with long directories it may be preferrend to have cursor on the next line. Setting this to `clean` instead of `yes` suppresses the caret on the new line. -- `theme_newline_prompt`. Use a custom prompt with newline cursor. By default this is the chevron right glyph or `>` when powerline fonts are disabled. - -**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] | | + +See (many) more options below. + + + +### Prompt options + +#### `set -g theme_display_vi yes` + +By default the vi mode indicator will be shown if vi or hybrid key bindings are enabled. Use `no` to always hide the indicator, or `yes` to always show the indicator. + +#### `set -g theme_show_exit_status yes` + +Use `yes` to show any non-zero exit code next to the exclamation mark. + +#### `set -g theme_display_jobs_verbose yes` + +Use `yes` to display the number of currently running background jobs next to the percent sign. + +#### `set -g theme_display_user yes` + +Set to `yes` to always display the username, to `ssh` to display only when an SSH session is active, or to `no` to never display the username. + +#### `set -g default_user your_normal_user` + +If a `default_user` is provided, the username will only be shown when it differs from the default. + +#### `set -g theme_display_sudo_user yes` + +If set to `yes`, displays the sudoer's username in a root shell. For example, when calling `sudo -s` with this option set to `yes`, the user who called `sudo -s` will be displayed. + +#### `set -g theme_display_hostname yes` + +Set to `yes` to always display the hostname, to `ssh` to display only when an SSH session is active, or to `no` to never display the hostname. + +#### `set -g fish_prompt_pwd_dir_length 1` + +Bobthefish respects the Fish `$fish_prompt_pwd_dir_length` setting to abbreviate the prompt path; set to `0` to show the full path, `1` (default) to show only the first character of each parent directory name, or any other number to show up to that many characters. + +#### `set -g theme_project_dir_length 1` + +The same as `$fish_prompt_pwd_dir_length`, but for the path relative to the current project root. Defaults to `0`; set to any other number to show an abbreviated path. + +#### `set -g theme_show_project_parent no` + +Use `no` to only show the project directory name, and not its parent path, when inside a project. + +#### `set -g theme_newline_cursor yes` + +Use `yes` to place the cursor on the next line, rather than the same line as the prompt. Setting this to `clean` instead of `yes` suppresses the caret on the new line. + +#### `set -g theme_newline_prompt "\$"` + +Use a custom prompt with newline cursor. By default this is the chevron right glyph or `>` when powerline fonts are disabled. + +#### `set -g theme_avoid_ambiguous_glyphs yes` + +You probably don't need this option, unless your terminal doesn't like Unicode. Setting to `yes` will avoid ambiguous-width characters in an attempt to + +#### `set -g theme_powerline_fonts no` + +Bobthefish really likes Powerline-enhanced fonts. If you can't make that work, set to `no` to use plaintext fallbacks. + +#### `set -g theme_nerd_fonts yes` + +Bobthefish likes Nerd Fonts even better! Use `yes` if you've got Nerd Font capable fonts. + +#### `set -g theme_color_scheme dark` + +See below for all the color scheming you can handle. + + + +### Virtual environments and version manager options + +#### `set -g theme_display_vagrant yes` + +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. + +#### `set -g theme_display_docker_machine no` + +Use `no` to disable the current Docker machine name. + +#### `set -g theme_display_ruby no` + +Use `no` to disable Ruby version information. By default, the Ruby version is displayed unless it's your system Ruby version. + +#### `set -g theme_display_virtualenv no` + +Use `no` to disable Python version information. By default, the Python version is shown when it's interesting, along with the Virtualenv or Conda environmenmt. + +#### `set -g theme_display_go verbose` + +Use `no` to disable the Go version information. Set to `verbose` to show both the required and current Go version. + +#### `set -g theme_display_node yes` + +This feature is disabled by default. Use `yes`, display the version if an `.nvmrc`, `.node-version` or `package.json` file is found in the parent path. Set to `always` to always display the current NPM, NVM or FNM node version. + +#### `set -g theme_display_nix no` + +Use `no` to disable Nix environment information. + +#### `set -g theme_display_k8s_context yes` + +This feature is disabled by default. Use `yes` to show the current Kubernetes context (`> kubectl config current-context`). + +#### `set -g theme_display_k8s_namespace yes` + +This feature is disabled by default. Use `yes` to show the current Kubernetes namespace. + +#### `set -g theme_display_aws_vault_profile yes` + +This feature is disabled by default. Use `yes` to show the currently executing [AWS Vault](https://github.com/99designs/aws-vault) profile. + + + +### Git (and other VCS) options + +#### `set -g theme_display_git no` + +Use `no` to disable Git integration. If you're doing this for performance reasons, try some of the options below before disabling it entirely! + +#### `set -g theme_display_git_dirty no` + +Use `no` to hide Git dirty state. Set the Git `bash.showDirtyState` option on a per-repository basis to disable it just for especially large repos. + +#### `set -g theme_display_git_dirty_verbose yes` + +This feature is disabled by default. Use `yes` to show more verbose dirty state information. + +#### `set -g theme_display_git_untracked no` + +Use `no` to hide Git untracked file state. Set the Git `bash.showUntrackedFiles` option on a per-repository basis to disable it just for especially large repos. + +#### `set -g theme_display_git_ahead_verbose yes` + +This feature is disabled by default. Use `yes` to show more verbose ahead/behind state information. + +#### `set -g theme_display_git_stashed_verbose yes` + +This feature is disabled by default. Use `yes` to show more verbose stashed state information. + +#### `set -g theme_display_git_default_branch yes` + +By default, Bobthefish hides the default branch name (e.g. `main` or `master`). Use `yes` to always show these branche names. + +#### `set -g theme_git_default_branches main trunk` + +By default, Bobthefish hides default branch names (e.g. `main` or `master`). To hide other branch names, you can set a custom default branch name via the `init.defaultBranch` Git config option, or override the list entirely. + +#### `set -g theme_use_abbreviated_branch_name yes` + +This feature is disabled by default. Use `yes` to truncate extremely long Git branch names. + +#### `set -g theme_git_worktree_support yes` + +If you do any Git worktree shenanigans, setting this to `yes` will fix incorrect project-relative paths. If you don't do any Git worktree shenanigans, leave it disabled. It's faster this way :) + +#### `set -g theme_display_hg yes` + +This feature is disabled by default. Use `yes` to enable Mercurial support in Bobthefish. If you don't use Mercurial, leave it disabled because it's ... not fast. + +#### `set -g theme_vcs_ignore_paths /some/path /some/other/path{foo,bar}` + +Ignore project paths for Git or Mercurial. Supports glob patterns. + + + +### Right prompt options + +The right prompt can be configured with the following options, or overridden entirely by supplying your own `fish_right_prompt` function. + +#### `set -g theme_display_date` + +Use `no` to disable the date in the right prompt. + +#### `set -g theme_date_format +%c` + +Customize date formatting. See `man date` for more information. + +#### `set -g theme_date_timezone America/Los_Angeles` + +Supply a TZ argument variable for date formatting. See `man date` for more information. + +#### `set -g theme_display_cmd_duration no` + +Use `no` to disable command duration in the right prompt. + + + +### Title options + +#### `set -g theme_title_display_process yes` + +This feature is disabled by default. Use `yes` to show current process name in the terminal title. + +#### `set -g theme_title_display_path no` + +Use `no` to hide current working directory from the terminal title. + +#### `set -g theme_title_display_user yes` + +Use `yes` to show the current user in the tab title (unless you're the default user). + +#### `set -g theme_title_use_abbreviated_path no` + +By default, directory names will be abbreviated in the terminal title, for example `~` instead of `$HOME` and `/u/local` instead of `/usr/local`. Set to `no` to always show full paths in the title. + + + +### Color schemes + +| ![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] | ![gruvbox-light][gruvbox-light] | You can use the function `bobthefish_display_colors` to preview the prompts in any color scheme. @@ -164,7 +310,7 @@ one of the following options to change the prompt colors. - `base16` (or `base16-dark`), `base16-light`. Dark and light variants of the default Base16 theme. - `zenburn`. An adaptation of Zenburn. -- `gruvbox`. An adaptation of gruvbox. +- `gruvbox`, `gruvbox-light`. An adaptation of gruvbox dark and light variants. - `dracula`. An adaptation of dracula. - `nord`. An adaptation of nord. @@ -201,10 +347,8 @@ variables to set the colors of the prompt. See the "Colors" section of `fish_prompt.fish` for details. -**VCS options** -- `set -g theme_vcs_ignore_paths /some/path /some/other/path{foo,bar}`. Ignore project paths for Git or Mercurial. Supports glob patterns. -### Overrides +## Overrides You can disable the theme default greeting, vi mode prompt, right prompt, or title entirely — or override with your own — by adding custom functions to `~/.config/fish/functions`: @@ -230,19 +374,20 @@ 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 - -[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-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 + +[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" +[gruvbox-light]: https://user-images.githubusercontent.com/458535/97345492-6a207e80-188a-11eb-92df-30f33419238b.png "gruvbox-light" diff --git a/functions/__bobthefish_colors.fish b/functions/__bobthefish_colors.fish index ad6673a..aeb1e4f 100644 --- a/functions/__bobthefish_colors.fish +++ b/functions/__bobthefish_colors.fish @@ -33,7 +33,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 @@ -68,7 +68,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 @@ -103,7 +103,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 @@ -138,7 +138,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 @@ -179,7 +179,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 @@ -231,7 +231,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 @@ -283,7 +283,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 @@ -335,7 +335,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 @@ -387,7 +387,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 @@ -432,7 +432,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 @@ -476,12 +476,54 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 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_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 @@ -516,13 +558,13 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_vi_mode_visual $orange $bg --bold set -x color_vagrant $pink $bg --bold - set -x color_k8s $green $fg --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_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 @@ -574,7 +616,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 @@ -634,6 +676,48 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe set -x color_virtualgo $light_green $darker_grey --bold set -x color_desk $light_grey $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_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 # ------ ------ ------ @@ -674,7 +758,7 @@ function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthe 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 diff --git a/functions/bobthefish_display_colors.fish b/functions/bobthefish_display_colors.fish index e1dfc62..e84f649 100644 --- a/functions/bobthefish_display_colors.fish +++ b/functions/bobthefish_display_colors.fish @@ -3,7 +3,7 @@ function bobthefish_display_colors -a color_scheme -d 'Print example prompt colo set -l color_schemes default light \ solarized solarized-light \ base16 base16-light \ - gruvbox zenburn \ + gruvbox gruvbox-light zenburn \ dracula nord \ terminal terminal-dark-white \ terminal-light terminal-light-black \ @@ -140,6 +140,7 @@ function bobthefish_display_colors -a color_scheme -d 'Print example prompt colo __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 ') ' @@ -149,5 +150,9 @@ function bobthefish_display_colors -a color_scheme -d 'Print example prompt colo 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/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 85% rename from fish_prompt.fish rename to functions/fish_prompt.fish index e0a653e..ebb3983 100644 --- a/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -15,42 +15,8 @@ # # https://github.com/ryanoasis/nerd-fonts # -# You can override some default prompt options in your config.fish: +# See README.md for setup and configuration options. # -# set -g theme_display_git no -# set -g theme_display_git_dirty no -# 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_default_branch yes -# set -g theme_git_default_branches main trunk -# set -g theme_git_worktree_support 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 -# set -g theme_display_ruby no -# set -g theme_display_user ssh -# 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_avoid_ambiguous_glyphs yes -# set -g theme_powerline_fonts no -# set -g theme_nerd_fonts yes -# set -g theme_show_exit_status yes -# set -g theme_display_jobs_verbose yes -# set -g default_user your_normal_user -# set -g theme_color_scheme dark -# set -g fish_prompt_pwd_dir_length 0 -# set -g theme_project_dir_length 1 -# set -g theme_newline_cursor yes - # ============================== # Helper methods @@ -78,10 +44,13 @@ 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 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 + 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 @@ -97,12 +66,11 @@ function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish and return end - set -l tag (command git describe --tags --exact-match 2>/dev/null) - and echo "$tag_glyph $tag" - and return - - set -l branch (command git show-ref --head -s --abbrev | head -n1 2>/dev/null) - echo "$detached_glyph $branch" + # 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' @@ -158,6 +126,10 @@ function __bobthefish_git_project_dir -S -a real_pwd -d 'Print the current git p [ -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/\* @@ -185,7 +157,7 @@ function __bobthefish_git_project_dir -S -a real_pwd -d 'Print the current git p or return pushd $git_dir - set git_dir $real_pwd + set git_dir (__bobthefish_pwd) popd switch $real_pwd/ @@ -357,7 +329,7 @@ function __bobthefish_start_segment -S -d 'Start a prompt segment' set __bobthefish_current_bg $bg end -function __bobthefish_path_segment -S -a segment_dir -d 'Display a shortened form of a directory' +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 @@ -381,7 +353,9 @@ function __bobthefish_path_segment -S -a segment_dir -d 'Display a shortened for set directory (__bobthefish_basename "$segment_dir") end - echo -n $parent + [ "$theme_show_project_parent" != "no" -o "$path_type" != "project" ] + and echo -n $parent + set_color -b $segment_basename_color echo -ns $directory ' ' end @@ -399,7 +373,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 " @@ -637,16 +611,18 @@ function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context' [ "$theme_display_k8s_namespace" = 'yes' ] and set -l namespace (__bobthefish_k8s_namespace) - [ -z $context -o "$context" = 'default' ] - and [ -z $namespace -o "$namespace" = 'default' ] + [ -z "$context" -o "$context" = 'default' ] + and [ -z "$namespace" -o "$namespace" = 'default' ] and return - set -l segment $k8s_glyph " " $context - [ -n "$namespace" ] - and set segment $segment ":" $namespace + 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 " " + echo -ns $segment ' ' end @@ -658,28 +634,28 @@ 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" ] + [ -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_SESSION_EXPIRATION" +%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" + 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 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 " " + echo -ns $segment ' ' end @@ -690,7 +666,7 @@ end # Polyfill for fish < 2.5.0 if not type -q prompt_hostname if not set -q __bobthefish_prompt_hostname - set -g __bobthefish_prompt_hostname (hostname | string replace -r '\..*' '') + set -g __bobthefish_prompt_hostname (uname -n | string replace -r '\..*' '') end function prompt_hostname @@ -830,10 +806,10 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information' set -l asdf_current_ruby (asdf current ruby 2>/dev/null) or return - echo "$asdf_current_ruby" | read -l asdf_ruby_version asdf_provenance + 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") = "(set by $HOME/.tool-versions)" ] + [ (string trim -- "$asdf_provenance") = "$HOME/.tool-versions" ] and return set ruby_version $asdf_ruby_version @@ -846,6 +822,63 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information' 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+)' -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*' @@ -860,14 +893,29 @@ function __bobthefish_virtualenv_python_version -S -d 'Get current Python versio 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 - echo -ns $virtualenv_glyph $version_glyph ' ' + 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" ] @@ -891,20 +939,70 @@ 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_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 (nvm current 2> /dev/null) + 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 @@ -928,14 +1026,14 @@ 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" ] set flag_colors $color_repo_dirty end - __bobthefish_path_segment $hg_root_dir + __bobthefish_path_segment $hg_root_dir project __bobthefish_start_segment $flag_colors echo -ns $hg_glyph ' ' @@ -976,7 +1074,7 @@ function __bobthefish_prompt_git -S -a git_root_dir -a real_pwd -d 'Display the 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 2>/dev/null) + 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 @@ -995,7 +1093,7 @@ function __bobthefish_prompt_git -S -a git_root_dir -a real_pwd -d 'Display the set flag_colors $color_repo_staged end - __bobthefish_path_segment $git_root_dir + __bobthefish_path_segment $git_root_dir project __bobthefish_start_segment $flag_colors echo -ns (__bobthefish_git_branch) $flags ' ' @@ -1077,7 +1175,7 @@ function __bobthefish_prompt_git -S -a git_root_dir -a real_pwd -d 'Display the end function __bobthefish_prompt_dir -S -a real_pwd -d 'Display a shortened form of the current directory' - __bobthefish_path_segment "$real_pwd" + __bobthefish_path_segment "$real_pwd" pwd end @@ -1090,8 +1188,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 @@ -1104,6 +1202,8 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' # 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 @@ -1122,11 +1222,11 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' __bobthefish_prompt_nix __bobthefish_prompt_desk __bobthefish_prompt_rubies + __bobthefish_prompt_golang $real_pwd __bobthefish_prompt_virtualfish __bobthefish_prompt_virtualgo - __bobthefish_prompt_nvm + __bobthefish_prompt_node - set -l real_pwd (__bobthefish_pwd) # VCS set -l git_root_dir (__bobthefish_git_project_dir $real_pwd) diff --git a/fish_right_prompt.fish b/functions/fish_right_prompt.fish similarity index 93% rename from fish_right_prompt.fish rename to functions/fish_right_prompt.fish index ef54772..45e14d6 100644 --- a/fish_right_prompt.fish +++ b/functions/fish_right_prompt.fish @@ -1,6 +1,4 @@ -# You can override some default right prompt options in your config.fish: -# set -g theme_date_format "+%a %H:%M" -# set -g theme_date_timezone America/Los_Angeles +# See "Right prompt options" in README.md for configuration options function __bobthefish_cmd_duration -S -d 'Show command duration' [ "$theme_display_cmd_duration" = "no" ] diff --git a/fish_title.fish b/functions/fish_title.fish similarity index 63% rename from fish_title.fish rename to functions/fish_title.fish index a14e1b6..91793c2 100644 --- a/fish_title.fish +++ b/functions/fish_title.fish @@ -1,15 +1,11 @@ -# You can override some default title options in your config.fish: -# set -g theme_title_display_process no -# set -g theme_title_display_path no -# set -g theme_title_display_user yes -# set -g theme_title_use_abbreviated_path no +# 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 . - hostname | read -l hostname __ - echo -ns (whoami) '@' $hostname ' ' + uname -n | read -l host __ + echo -ns (whoami) '@' $host ' ' end end end @@ -18,7 +14,7 @@ function fish_title __bobthefish_title_user if [ "$theme_title_display_process" = 'yes' ] - echo $_ + status current-command [ "$theme_title_display_path" != 'no' ] and echo ' '