From a3d43d35bd63f4fbe08acb74f93d1b61a0694041 Mon Sep 17 00:00:00 2001 From: Florian Meinicke Date: Thu, 10 Oct 2019 22:12:47 +0200 Subject: [PATCH] Add option to display the number of background jobs --- README.md | 2 ++ fish_prompt.fish | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aa2584b..327695b 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ 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_show_job_number yes set -g default_user your_normal_user set -g theme_color_scheme dark set -g fish_prompt_pwd_dir_length 0 @@ -123,6 +124,7 @@ set -g theme_newline_prompt '$ ' - `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_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_show_job_number`. 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. diff --git a/fish_prompt.fish b/fish_prompt.fish index 149dfd2..5314c26 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -39,6 +39,7 @@ # set -g theme_powerline_fonts no # set -g theme_nerd_fonts yes # set -g theme_show_exit_status yes +# set -g theme_show_job_number yes # set -g default_user your_normal_user # set -g theme_color_scheme dark # set -g fish_prompt_pwd_dir_length 0 @@ -420,7 +421,8 @@ function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a no and set superuser 1 # Jobs display - jobs -p >/dev/null + set num_bg_jobs (jobs -p | wc -l) + [ $num_bg_jobs -gt 0 ] and set bg_jobs 1 if [ "$nonzero" -o "$superuser" -o "$bg_jobs" ] @@ -449,7 +451,11 @@ function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a no if [ "$bg_jobs" ] set_color normal set_color -b $color_initial_segment_jobs - echo -n $bg_job_glyph + if [ "$theme_show_job_number" = 'yes' ] + echo -ns $bg_job_glyph $bg_jobs ' ' + else + echo -n $bg_job_glyph + end end end end