From: Mark Wooding Date: Sat, 9 May 2020 23:45:20 +0000 (+0100) Subject: dot/shell-rc: Calculate the hostname qualifiers once in advance. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/profile/commitdiff_plain/d4bbc0c0e3c55dde57b1514c9646f4e42cd87ebe dot/shell-rc: Calculate the hostname qualifiers once in advance. The `qualifiers' here are things like the chroot or cross-environment name. --- diff --git a/dot/shell-rc b/dot/shell-rc index 51abd6e..2478edb 100644 --- a/dot/shell-rc +++ b/dot/shell-rc @@ -62,11 +62,12 @@ __mdw_runhook () { ### Prompt machinery. __mdw_host=$(hostname) +__mdw_hqual= +__mdw_hqual=$__mdw_hqual${SCHROOT_CHROOT_NAME+/$SCHROOT_CHROOT_NAME} +__mdw_hqual=$__mdw_hqual${CROSS_BUILDENV+/$CROSS_BUILDENV} __mdw_set_prompt_hacks () { host=$__mdw_host; dir=""; } __mdw_set_prompt_pieces () { - local hqual - hqual="" ## Fancy highlighting in some terminals. local bold unbold nl gitcolour rccolour uncolour @@ -108,11 +109,9 @@ __mdw_set_prompt_pieces () { ## If this is an schroot environment or some other interesting augmented ## environment then point this out. - hqual="$hqual${SCHROOT_CHROOT_NAME+/$SCHROOT_CHROOT_NAME}" - hqual="$hqual${CROSS_BUILDENV+/$CROSS_BUILDENV}" ## Put together the main pieces. - __mdw_prompt_left="$nl$bold$left$sec_l$u$host$hqual$sec_r$dir" + __mdw_prompt_left="$nl$bold$left$sec_l$u$host$__mdw_hqual$sec_r$dir" __mdw_prompt_git_left="$unbold$gitcolour" __mdw_prompt_git_right="$uncolour$bold" __mdw_prompt_rc_left="$unbold$rccolour"