Search code examples
fish

How to remove blank line before prompt when I set fish_greating to null?


I want to remove the blank line before prompt when I open a new fish shell window.

I try to remove fish_greating use official FAQ.

➜ set fish_greeting

Here's my plugins.

vue-multiple-pages on  master [!] is 📦 v0.1.0 via ⬢ none 
➜ fisher ls
edc/bass
FabioAntunes/fish-nvm
matchai/spacefish

It works. I remove the greating "Welcome to fish, the friendly interactive shell".

But, I got a blank line like this:

blankline

How to remove this blank line?

======updated======

This is is gif that I want to explain.

enter image description here

Thanks.


Solution

  • After a few hours of hard work, I found the answer.

    It's the matchai/spacefish plugin which add new line to my prompt.

    Here is the function

    # Defined in /Users/liwei/.config/fish/functions/fish_prompt.fish @ line 1
    function fish_prompt
    
      set -g sf_exit_code $status
        set -g SPACEFISH_VERSION 2.6.0
    
      # ------------------------------------------------------------------------------
        # Configuration
        # ------------------------------------------------------------------------------
    
      __sf_util_set_default SPACEFISH_PROMPT_ADD_NEWLINE true
        __sf_util_set_default SPACEFISH_PROMPT_FIRST_PREFIX_SHOW false
        __sf_util_set_default SPACEFISH_PROMPT_PREFIXES_SHOW true
        __sf_util_set_default SPACEFISH_PROMPT_SUFFIXES_SHOW true
        __sf_util_set_default SPACEFISH_PROMPT_DEFAULT_PREFIX "via "
        __sf_util_set_default SPACEFISH_PROMPT_DEFAULT_SUFFIX " "
        __sf_util_set_default SPACEFISH_PROMPT_ORDER time user dir host git package node ruby golang php rust haskell julia elixir docker aws venv conda pyenv dotnet kubecontext exec_time line_sep battery vi_mode jobs exit_code char
    
      # ------------------------------------------------------------------------------
        # Sections
        # ------------------------------------------------------------------------------
    
      # Keep track of whether the prompt has already been opened
        set -g sf_prompt_opened $SPACEFISH_PROMPT_FIRST_PREFIX_SHOW
    
      if test "$SPACEFISH_PROMPT_ADD_NEWLINE" = "true"
            echo
        end
    
      for i in $SPACEFISH_PROMPT_ORDER
            eval __sf_section_$i
        end
        set_color normal
    end
    

    Just set SPACEFISH_PROMPT_ADD_NEWLINE to false,

    add this line to your config.fish and solve the problem.

    set SPACEFISH_PROMPT_ADD_NEWLINE false
    

    Thanks to all.