fish shellのプロンプトを変更する

やること

タイトル通りです。fish shellを最近使い始めたが、プロンプトに出ているユーザー名とホスト名がいらないと感じているので、消すことにしました。

方法

$HOME/.config/fish/functionsにあるfish_prompt.fishを修正します。デフォルトでは以下のようになっています。

function fish_prompt --description 'Write out the prompt'
    set -l last_status $status

    # User
    set_color $fish_color_user
    echo -n $USER
    set_color normal

    echo -n '@'

    # Host
    set_color $fish_color_host
    echo -n (prompt_hostname)
    set_color normal

    echo -n ':'

    # PWD
    set_color $fish_color_cwd
    echo -n (prompt_pwd)
    set_color normal

    __terlar_git_prompt
    fish_hg_prompt
    echo

    if not test $last_status -eq 0
        set_color $fish_color_error
    end

    echo -n '➤ '
    set_color normal
end

ご丁寧に# Userなど、適宜コメントが残っているので、UserHostを丸ごと消してしまいましょう。

function fish_prompt --description 'Write out the prompt'
    set -l last_status $status

    # PWD
    set_color $fish_color_cwd
    echo -n (prompt_pwd)
    set_color normal

    __terlar_git_prompt
    fish_hg_prompt
    echo

    if not test $last_status -eq 0
        set_color $fish_color_error
    end

    echo -n '➤ '
    set_color normal
end

以上です。