문제
물고기 대화식 껍질에 전체 경로가 표시되는 방법이 있습니까? 현재 디렉토리로 이동하면 다음 쉘을 얻습니다.
millermj@Dodore ~/o/workspace
그러나 나는 차라리보고 싶다
millermj@Dodore ~/o-town/workspace
해결책
새로운 FishShell (v2.3)으로 할 수 있습니다. set -U fish_prompt_pwd_dir_length 0
. 그리고 그것은 전체 경로를 사용합니다. 나도 사용합니다 다트 피쉬 내 테마를 위해. 아래 예를 참조하십시오 :
다른 팁
여기 내 버전이 있습니다 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
이것은 평소와 같이 홈 디렉토리의 tilde를 표시하지만 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
함수는 표시 될 기능을 결정합니다. 원하는 것을 얻기 위해 자신의 버전을 작성할 수 있어야합니다.