From 569e0142dfee33c3fae34daaac4c9cc7a00640db Mon Sep 17 00:00:00 2001 From: Luis Guilherme Coelho Date: Sun, 25 Aug 2024 15:58:32 -0300 Subject: [PATCH] radio: files: fish: Update fish_prompt --- .../.config/fish/functions/fish_prompt.fish | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/home-environments/radio/files/.config/fish/functions/fish_prompt.fish b/home-environments/radio/files/.config/fish/functions/fish_prompt.fish index 4318a06..14b5278 100644 --- a/home-environments/radio/files/.config/fish/functions/fish_prompt.fish +++ b/home-environments/radio/files/.config/fish/functions/fish_prompt.fish @@ -18,22 +18,21 @@ end # Current working directory prompt function fish_cwd_prompt set -l cwd (pwd) - switch "$cwd" + switch "$cwd" case "$HOME" printf "~" case "/" printf "/" case "*" - set -l parent_dir (dirname $cwd) + set -l parent_dir (dirname "$cwd") switch "$parent_dir" case "$HOME" - printf "~/%s" (basename $cwd) + printf "~/%s" (basename "$cwd") case "/" - printf "/%s" (basename $cwd) - case "/gnu/store" - printf "/gnu/store/%s" (basename $cwd) + printf "/%s" (basename "$cwd") 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 @@ -46,16 +45,15 @@ end # Actual prompt function fish_prompt if test -n "$GUIX_ENVIRONMENT" - set -l fish_environment_prompt_length \ - (displayed_string_length (fish_environment_prompt)) - set -l fish_git_prompt_length \ - (displayed_string_length (fish_git_prompt)) + set -l fish_git_prompt (fish_git_prompt) + set -l fish_environment_prompt (fish_environment_prompt) + set -l fish_environment_prompt_length (displayed_string_length "$fish_environment_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 (padding (math $COLUMNS - $fish_environment_prompt_length \ - - $fish_git_prompt_length)) - fish_git_prompt | string replace -ra ' ' '' - printf '\n' + printf "$fish_environment_prompt" + printf (padding $fish_prompt_padding) + printf "$fish_git_prompt\n" else function fish_right_prompt fish_git_prompt @@ -63,7 +61,7 @@ function fish_prompt end set -g fish_key_bindings fish_vi_key_bindings - switch "$fish_key_bindings" + switch "$fish_key_bindings" case fish_vi_key_bindings fish_hybrid_key_bindings test $fish_bind_mode = 'default' && normal ':' || normal '+' end @@ -74,6 +72,5 @@ function fish_prompt end function fish_default_mode_prompt -d "Display vi prompt mode" - # Do nothing end