سؤال

هل هناك طريقة في Fish Interactive Shell لعرض المسار الكامل.حاليًا عندما أنتقل إلى دليل أحصل على الصدفة التالية.

millermj@Dodore ~/o/workspace

لكنني أفضل أن أرى

millermj@Dodore ~/o-town/workspace
هل كانت مفيدة؟

المحلول

ومع fishshell الجديدة (V2.3) يمكنك القيام به set -U fish_prompt_pwd_dir_length 0. وسوف تستخدم المسار الكامل. أنا أيضا استخدام dartfish للحصول على موضوعي. انظر المثال أدناه:

نصائح أخرى

وهنا لي نسخة من 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 لجعل السلوك تستمر في الدورات المقبلة.

أنا شخصياً لا أحب لمس المشترك/الافتراضي.تتمتع الأسماك بتصميم رائع للوظائف، لذا استفد من ذلك.

يخلق ~/.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

وظيفة prompt_pwd تحدد وظيفة ليتم عرضها. يجب أن تكون قادرا على كتابة النسخة الخاصة بك للحصول على ما تريد.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top