radio: files: fish: Update fish_prompt

impermanence
Luis Guilherme Coelho 2024-08-25 15:58:32 -03:00
parent f79c1d9f87
commit 569e0142df
No known key found for this signature in database
GPG Key ID: 1F2E76ACE3F531C8
1 changed files with 15 additions and 18 deletions

View File

@ -24,16 +24,15 @@ function fish_cwd_prompt
case "/" case "/"
printf "/" printf "/"
case "*" case "*"
set -l parent_dir (dirname $cwd) set -l parent_dir (dirname "$cwd")
switch "$parent_dir" switch "$parent_dir"
case "$HOME" case "$HOME"
printf "~/%s" (basename $cwd) printf "~/%s" (basename "$cwd")
case "/" case "/"
printf "/%s" (basename $cwd) printf "/%s" (basename "$cwd")
case "/gnu/store"
printf "/gnu/store/%s" (basename $cwd)
case "*" case "*"
printf "%s/%s" (basename $parent_dir) (basename $cwd) test (dirname "$parent_dir") = "/" && printf "/"
printf "%s/%s" (basename "$parent_dir") (basename "$cwd")
end end
end end
end end
@ -46,16 +45,15 @@ end
# Actual prompt # Actual prompt
function fish_prompt function fish_prompt
if test -n "$GUIX_ENVIRONMENT" if test -n "$GUIX_ENVIRONMENT"
set -l fish_environment_prompt_length \ set -l fish_git_prompt (fish_git_prompt)
(displayed_string_length (fish_environment_prompt)) set -l fish_environment_prompt (fish_environment_prompt)
set -l fish_git_prompt_length \ set -l fish_environment_prompt_length (displayed_string_length "$fish_environment_prompt")
(displayed_string_length (fish_git_prompt)) set -l fish_git_prompt_length (displayed_string_length "$fish_git_prompt")
set -l fish_prompt_padding (math $COLUMNS - $fish_environment_prompt_length - $fish_git_prompt_length)
fish_environment_prompt printf "$fish_environment_prompt"
printf (padding (math $COLUMNS - $fish_environment_prompt_length \ printf (padding $fish_prompt_padding)
- $fish_git_prompt_length)) printf "$fish_git_prompt\n"
fish_git_prompt | string replace -ra ' ' ''
printf '\n'
else else
function fish_right_prompt function fish_right_prompt
fish_git_prompt fish_git_prompt
@ -74,6 +72,5 @@ function fish_prompt
end end
function fish_default_mode_prompt -d "Display vi prompt mode" function fish_default_mode_prompt -d "Display vi prompt mode"
# Do nothing
end end