How do I get fish shell prompt to show the hostname?

5

3

I'm attempting to make my Fish prompt look like the old Gentoo shell did.

user@hostname ~ % where the user@hostname is green, and the $PWD and symbol were blue.

Right now it only shows: user@ ~ %, and no hostname.

aaron@ ~ % su -
Password: 
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
root@ ~ % hostname
rpi
root@ ~ % cat .config/fish/functions/fish_prompt.fish 
function fish_prompt
      if not set -q $__fish_prompt_hostname
        set -g __fish_prompt_hostname (hostname)
     end
     set_color -o red
     echo -n -s "$USER" @ "$__fish_prompt_hostname" " "
     set_color -o blue
     echo -n (prompt_pwd)
     echo -n " % "
     set_color normal
end

Another odd thing... before I rebooted, it was showing up correctly:

enter image description here

longviewbits

Posted 2015-06-28T06:00:47.037

Reputation: 53

Answers

3

You want set -q __fish_prompt_hostname without the $

You'll notice, in the fine documentation:

set ( -q | --query ) [SCOPE_OPTIONS] VARIABLE_NAMES...
# ............................................^^^^

glenn jackman

Posted 2015-06-28T06:00:47.037

Reputation: 18 546

Thank you very much, Glenn. That did the trick. Much appreciated, sir! – longviewbits – 2015-06-29T00:43:09.663