commit 2af69547102a6001023ead81b94117e4ca729e4c parent 6248d5a394e85795a04dca3eb5923f96fe7bbd67 Author: hhvn <dev@hhvn.uk> Date: Tue, 4 Jan 2022 14:58:35 +0000 .rcrc: indented $prompt(2) Diffstat:
M | .rcrc | | | 24 | +++++++++++++++--------- |
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/.rcrc b/.rcrc @@ -23,13 +23,6 @@ fn __prompt { __prompt_exitcodes = $status __prompt_gitoutput = 0 - # missing newline - # https://www.vidarholen.net/contents/blog/?p=878 - __prompt_tput setaf 14 - printf '%%' - tr '\0' ' ' < /dev/zero | head -c `{tput cols} | sed 's/.//' - printf '\r' - # exit codes # rc produces a list if there is a pipeline if (~ $__prompt_exitcodes(2) ()) { @@ -118,9 +111,22 @@ fn __prompt { # Frontend prompt function fn prompt { + # missing newline + # https://www.vidarholen.net/contents/blog/?p=878 + __prompt_tput setaf 14 + printf '%%' + tr '\0' ' ' < /dev/zero | head -c `{tput cols} | sed 's/.//' + printf '\r' + + # set X11 title printf '\033]0;rc: %s\007' `{pwd} - __prompt_content = ``(''){__prompt} - prompt = ($__prompt_content '') + + # prompt stuff + __prompt_content = `''{__prompt} + __prompt_indent = `$nl{printf '%s' $__prompt_content | + awk '{gsub(/\001[^\002]*\002/, ""); print}' | + sed 's/[^ ]/ /g;s/$/ /g'} + prompt = ($__prompt_content $__prompt_indent) } # Aliases