37

フルパスを表示する方法はFishInteractiveシェルにありますか?現在、ディレクトリに移動すると、次のシェルが表示されます。

millermj@Dodore ~/o/workspace

しかし、私はむしろ見たい

millermj@Dodore ~/o-town/workspace
4

6 に答える 6

50

新しいフィッシュシェル (v2.3) を使用すると、次のことができますset -U fish_prompt_pwd_dir_length 0。そして、フルパスを使用します。また、ダーツフィッシュをテーマに使用しています。以下の例を参照してください。

ここに画像の説明を入力

于 2016-05-20T03:47:58.220 に答える
17

prompt_pwd探しているものが表示される私のバージョンは次のとおりです。

function prompt_pwd --description 'Print the current working directory, NOT shortened to fit the prompt'
    if test "$PWD" != "$HOME"
        printf "%s" (echo $PWD|sed -e 's|/private||' -e "s|^$HOME|~|")
    else
        echo '~'
    end

end

これにより、通常どおりホームディレクトリのチルダが表示されsedますが、ディレクトリが数階層深い場合に各ディレクトリから最初の文字のみを取得するコマンドが削除されます。

を使用して編集prompt_pwdしますfunced。これにより、関数をインタラクティブに変更できます。コマンドラインからfunced prompt_pwd. プロンプトが好みに合わせて表示されたら、 を使用funcsave prompt_pwdして、今後のセッションで動作を持続させます。

于 2010-04-05T18:31:05.840 に答える
6

個人的には、共有/デフォルトに触れるのは好きではありません。Fish には優れた関数設計があるので、それを活用してください。

~/.config/fish/functions/prompt_long_pwd.fish次の内容で作成します。

function prompt_long_pwd --description 'Print the current working directory'
        echo $PWD | sed -e "s|^$HOME|~|" -e 's|^/private||'
end

次に、使用するように編集~/.config/fish/functions/fish_prompt.fishしますprompt_long_pwd。私が使用するカスタムプロンプトは次のとおりです。

~/.config/fish/config.fish :

set -g __fish_git_prompt_show_informative_status 1
set -g __fish_git_prompt_hide_untrackedfiles 1

set -g __fish_git_prompt_color_branch magenta bold
set -g __fish_git_prompt_showupstream "informative"
set -g __fish_git_prompt_char_upstream_ahead "↑"
set -g __fish_git_prompt_char_upstream_behind "↓"
set -g __fish_git_prompt_char_upstream_prefix ""

set -g __fish_git_prompt_char_stagedstate "●"
set -g __fish_git_prompt_char_dirtystate "✚"
set -g __fish_git_prompt_char_untrackedfiles "…"
set -g __fish_git_prompt_char_conflictedstate "✖"
set -g __fish_git_prompt_char_cleanstate "✔"

set -g __fish_git_prompt_color_dirtystate blue
set -g __fish_git_prompt_color_stagedstate yellow
set -g __fish_git_prompt_color_invalidstate red
set -g __fish_git_prompt_color_untrackedfiles $fish_color_normal
set -g __fish_git_prompt_color_cleanstate green bold

~/.config/fish/functions/fish_prompt.fish

function fish_prompt --description 'Write out the prompt'

    set -l last_status $status

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

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

    printf '%s ' (__fish_git_prompt)

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

    echo -n '$ '

end
于 2014-10-31T20:14:09.753 に答える
-4

関数は、表示されるprompt_pwd関数を決定します。必要なものを取得するには、独自のバージョンを作成できる必要があります。

于 2009-06-08T04:47:54.513 に答える