pull/272/merge
David Judge 3 years ago committed by GitHub
commit 7a1f27ebe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -105,6 +105,8 @@ 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_prompt_max_size_percentage 90
set -g theme_prompt_keep_space 10
set -g theme_project_dir_length 1
set -g theme_newline_cursor yes
set -g theme_newline_prompt '$ '
@ -138,6 +140,8 @@ set -g theme_newline_prompt '$ '
- `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_prompt_max_size_percentage`. When the prompt is wider then the given number, show a smaller prompt instead. The default is `90` (90% of the terminal's width). Fish cannot show wider prompt than 100% (this case fish would show: `> `). See the option below.
- `theme_prompt_keep_space`. When the prompt is too wide to provide the given number of free space (chars), show a smaller prompt instead. The default is `10` chars. See the option above.
- `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.

@ -48,6 +48,8 @@
# set -g default_user your_normal_user
# set -g theme_color_scheme dark
# set -g fish_prompt_pwd_dir_length 0
# set -g theme_prompt_max_size_percentage 90
# set -g theme_prompt_keep_space 10
# set -g theme_project_dir_length 1
# set -g theme_newline_cursor yes
@ -1080,12 +1082,7 @@ function __bobthefish_prompt_dir -S -a real_pwd -d 'Display a shortened form of
__bobthefish_path_segment "$real_pwd"
end
# ==============================
# Apply theme
# ==============================
function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
function __bobthefish_fish_prompt -d 'The whole prompt'
# Save the last status for later (do this before anything else)
set -l last_status $status
@ -1150,3 +1147,46 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
__bobthefish_finish_segments
end
function __bobthefish_limited_fish_prompt -d "show shorter prompt if it is too large"
# Prompt should be smaller than X% of the terminal's width
set -q theme_prompt_max_size_percentage
or set -l theme_prompt_max_size_percentage 90
# Prompt should leave N chars free space
set -q theme_prompt_keep_space
or set -l theme_prompt_keep_space 10
set -l prompt (__bobthefish_fish_prompt)
# Do nothing if we cannot determine the size of the terminal
if test -z "$COLUMNS"
echo $prompt
end
set -l prompt_chars (echo "$prompt" | sed -r 's/\x1b[^m]+m//g')
set -l prompt_size (string length "$prompt_chars")
set -l prompt_max_size_percentage (math "$COLUMNS * ( $theme_prompt_max_size_percentage / 100 )")
set -l prompt_max_size_keep (math "$COLUMNS - $theme_prompt_keep_space")
set -l prompt_max_size (
test "$prompt_max_size_percentage" -lt "$prompt_max_size_keep" \
&& echo $prompt_max_size_percentage \
|| echo $prompt_max_size_keep
)
if test "$prompt_size" -gt "$prompt_max_size"
echo "> "
return
end
# Do nothing if the prompt could fit well
echo $prompt
end
# ==============================
# Apply theme
# ==============================
function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
__bobthefish_limited_fish_prompt
end

Loading…
Cancel
Save