Reputation: 448
How do I go about changing my fish shell prompt when I'm on a different machine via ssh
.
I get it working with running a set -q __fish_prompt_hostname
at the top of my prompt config and "$__fish_prompt_hostname"
when I want to call it, but when I ssh
to another machine it cannot find the hostname and display it.
I know in bash $HOSTNAME
is the way to go, but with fish I'm not sure how to get the hostname. (I also would like to change the colors of my prompt based on the hostname due to some machines being more volatile than others.)
Any suggestions?
Upvotes: 2
Views: 3549
Reputation: 7459
You can emulate bash by putting set -x HOSTNAME (hostname)
in your ~/.config/fish/config.fish. You may prefer to strip the domain name from it with set -x HOSTNAME (hostname | string split -m1 '.')[1]
. That is what the prompt_hostname
function does to set the __fish_prompt_hostname
var.
Upvotes: 4