I'm migrating to a new Mac, and I'm having trouble setting up my shell to match the old one.

Old:

New:

Notice the host color is different? I copied the entire .config/fish folder over to the computer, but it's still not working. The only difference I can think of is the version - 2.1.2, vs. 2.5.0. Here's my fish_prompt.fish:

function fish_prompt --description 'Write out the prompt'

    set -l last_status $status

    # Just calculate these once, to save a few cycles when displaying the prompt
    if not set -q __fish_prompt_hostname
        set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
    end

    if not set -q __fish_prompt_normal
        set -g __fish_prompt_normal (set_color normal)
    end

    if not set -q -g __fish_classic_git_functions_defined
        set -g __fish_classic_git_functions_defined

        function __fish_repaint_user --on-variable fish_color_user --description "Event handler, repaint when fish_color_user changes"
            if status --is-interactive
                set -e __fish_prompt_user
                commandline -f repaint ^/dev/null
            end
        end

        function __fish_repaint_host --on-variable fish_color_host --description "Event handler, repaint when fish_color_host changes"
            if status --is-interactive
                set -e __fish_prompt_host
                commandline -f repaint ^/dev/null
            end
        end

        function __fish_repaint_status --on-variable fish_color_status --description "Event handler; repaint when fish_color_status changes"
            if status --is-interactive
                set -e __fish_prompt_status
                commandline -f repaint ^/dev/null
            end
        end
    end

    set -l delim '>'

    switch $USER

    case root

        if not set -q __fish_prompt_cwd
            if set -q fish_color_cwd_root
                set -g __fish_prompt_cwd (set_color $fish_color_cwd_root)
            else
                set -g __fish_prompt_cwd (set_color $fish_color_cwd)
            end
        end

    case '*'

        if not set -q __fish_prompt_cwd
            set -g __fish_prompt_cwd (set_color $fish_color_cwd)
        end

    end

    set -l prompt_status
    if test $last_status -ne 0
        if not set -q __fish_prompt_status
            set -g __fish_prompt_status (set_color $fish_color_status)
        end
        set prompt_status "$__fish_prompt_status [$last_status]$__fish_prompt_normal"
    end

    if not set -q __fish_prompt_user
        set -g __fish_prompt_user (set_color $fish_color_user)
    end
    if not set -q __fish_prompt_host
        set -g __fish_prompt_host (set_color $fish_color_host)
    end

    echo -n -s "$__fish_prompt_user" "$USER" "$__fish_prompt_normal" @ "$__fish_prompt_host" "$__fish_prompt_hostname" "$__fish_prompt_normal" ' ' "$__fish_prompt_cwd" (prompt_pwd) (__fish_git_prompt) "$__fish_prompt_normal" "$prompt_status" "$delim" ' '
end
up vote 2 down vote accepted

This is a consequence of fish color settings being stored as universal variables that are machine specific. If you look in your ~/.config/fish directory you'll see one or more files named fishd.* where the wildcard matches the mac address of the primary network interface of your computer. This is something many of us have argued should be changed. See this issue. The solution is to simply copy the fish_color_* entries from the fishd file for your old system to your new one.

  • Accepting for now, though in looking at that file: # This file is automatically generated by the fishd universal variable daemon. # Do NOT edit it directly, your changes will be overwritten. – brandonscript Feb 21 '17 at 19:38
  • You can safely ignore that warning in this case. It's basically telling you that if you edit the file by hand and then execute a set -u of the var you just hand edited your edit will be overwritten -- just as you would expect. It's a warning to keep people who don't know what they're doing from shooting themselves in the foot. – Kurtis Rader Feb 22 '17 at 20:02

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.