oh-my-fish / theme-bobthefish

A Powerline-style, Git-aware fish theme optimized for awesome.
MIT License
1.44k stars 222 forks source link

Question on `theme_newline_cursor/prompt` behavior #348

Closed gmagno closed 10 months ago

gmagno commented 10 months ago

Hello, :wave: :nerd_face:

Would you have some tips on what/where to change to have the behavior I describe below, when set -g theme_newline_cursor yes?

I have this habit of pressing enter a few times after the previous command output to add some spacing. It helps me understand where commands output begin/end.

So I would like when I press ENTER (and only ENTER) that the theme_new_line_prompt gets shown again and not the entire prompt.

bobthecow commented 10 months ago

something like this maybe?

diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish
index b9037d4..4eecfd2 100644
--- a/functions/fish_prompt.fish
+++ b/functions/fish_prompt.fish
@@ -1101,6 +1101,10 @@ end
 # Apply theme
 # ==============================

+function __bobthefish_postexec --on-event fish_postexec
+    set -e __bobthefish_just_rendered
+end
+
 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
@@ -1120,6 +1124,14 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
     # Start each line with a blank slate
     set -l __bobthefish_current_bg

+    if [ "$theme_newline_cursor" = 'yes' ]
+        if set -q __bobthefish_just_rendered
+            __bobthefish_finish_segments
+            return
+        end
+        set -g __bobthefish_just_rendered 1
+    end
+
     # Status flags and input mode
     __bobthefish_prompt_status $last_status
gmagno commented 10 months ago

That's exactly it!

image

I wonder why there are two new lines instead of one, between prompts '-> ' :thinking: