Вопрос

Есть ли способ в оболочке Fish Interactive отобразить полный путь.В настоящее время, когда я перехожу в каталог, я получаю следующую оболочку.

millermj@Dodore ~/o/workspace

но я бы предпочел увидеть

millermj@Dodore ~/o-town/workspace
Это было полезно?

Решение

С новой fishshell (v2.3) вы можете сделать set -U fish_prompt_pwd_dir_length 0.И он будет использовать полный путь.я также использую рыба-дротик для моей темы.См. пример ниже:

enter image description here

Другие советы

Вот моя версия 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 чтобы поведение сохранялось в будущих сеансах.

Лично мне не нравится трогать общие/по умолчанию.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/рыба/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 function определяет отображаемую функцию.Вы должны быть в состоянии написать свою собственную версию, чтобы получить то, что вы хотите.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top