Always show full prompt regardless of window width?

Viewed 41

I have tried a few of the prompts that are available through the fish config tool. All of them have had prompts that become progressively shorter with a smaller window width. I personally don't like this as I always want to see the folder and git branch that I am in.

Is there a simple setting (or a popular off the shelf prompt) that makes the prompt be full width regardless of window width.

1 Answers

You can run the command fish_config, it will open a new tab in your browser, then select the Prompt tab and you will see some pre-setup prompts. If any of those suits you then you need to configure a prompt by yourself. On terminal you can do:

  1. Go to .config/fish (generally it is located in your home folder. Linux or macOS you can do: cd ~/.config/fish
  2. Create a folder named functions (mkdir functions ; cd functions)
  3. Create a file named fish_prompt.fish with the content bellow:
function fish_prompt --description 'Informative prompt'
    #Save the return status of the previous command
    set -l last_pipestatus $pipestatus

    switch "$USER"
        case root toor
            printf '%s@%s %s%s%s# ' $USER (prompt_hostname) (set -q fish_color_cwd_root
                                                             and set_color $fish_color_cwd_root
                                                             or set_color $fish_color_cwd) \
                (prompt_pwd) (set_color normal)
        case '*'
            set -l pipestatus_string (__fish_print_pipestatus "[" "] " "|" (set_color $fish_color_status) \
                                      (set_color --bold $fish_color_status) $last_pipestatus)

            printf '\f\r> %s%s@%s %s%s %s%s%s' (set_color brblue) \
                $USER (prompt_hostname) (set_color $fish_color_cwd) $PWD \
                (set_color normal)
    end
end

Please, note that the code bellow is adapted from the Informative prompt

The Awesome Fish repository has some interesting prompts that you can install if you like.

Related