Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16143

Re: [PATCH] Add active mark, face support; activate mark on paste

From Ángel <angel@16bits.net>
Newsgroups gnu.bash.bug
Subject Re: [PATCH] Add active mark, face support; activate mark on paste
Date 2020-04-16 02:41 +0200
Message-ID <mailman.364.1586997714.3066.bug-bash@gnu.org> (permalink)
References <M4dFweU--3-2@tutanota.com> <875c423e-0420-78d2-af4b-dfb168432e2d@case.edu> <M4dz8wC--3-2@tutanota.com> <1586997707.1070.15.camel@16bits.net>

Show all headers | View raw


On 2020-04-11 at 18:04 +0200, gentoo_eshoes wrote:
> $ echo ${PS1@A}
> declare -x PS1=$'\\\n-----------\\n\\\n\\[\\a\\]\\\n\\[\\e[1;37m\
> \e[42m\\]\\u@\\H\\[\\e[0m\\] \\\n\\[\\033[1;30m\\]$(date "+%Y/%m/%d %
> H:%M:%S")\\[\\033[0m\\] \\\n\\[\\e[0;37m\\]\\s\\V t:\\l j:\\j \\\nd:
> ${SHLVL} pp:${PPID} p:$$ ut`cat /proc/uptime | cut -f1 -d.`\\[\\e[0m\
> \]\\n\\\n\\[\\e[0;37m\\]!\\!\\[\\e[0m\\] \\\n\\[\\033[0;36m\\]\\#\\[\
> \033[0m\\] \\\n$(evalexitcode "${__earlyec[@]}" ) \\\n\\[\\e[0m\
> \]$(uname -r) $(uname -v)\n$(ps_lepath "\\w")\\[ \\033];\\w\\a\\]\n\
> \[\\e[1;32m\\]\\$\\[\\e[0m\\] \\\n'


That was an… 'interesting' prompt.

Note that there are several subprocesses that you could easily avoid:

$(date "+%Y/%m/%d %H:%M:%S") is equivalent to \D{%Y/%m/%d %H:%M:%S}


`cat /proc/uptime | cut -f1 -d.`  this could be simplified to `cut -f1 -d. /proc/uptime`
it may be replaced with just builtins by `uptime=$(</proc/uptime); builtin echo ${uptime/.*}`

$(uname -r) $(uname -v)  is equivalent to $(uname -r -v)  I wonder why you need these fairly static values on every prompt line, though.

$(ps_lepath "\\w")  is expanding \w which is actually summarizing $HOME
into a ~. So you end up calculating a lepath which is equivalent to
$PWD. In fact, you are then discarding the calculated var, and using
directly $PWD. So any call to ps_lepath is actually equivalent to printf
%q "$PWD"


Seems $PIPESTATUS does not change inside the $PS1 ($? does vary after
you launch those process substitutions), so you could just replace
evalexitcode "${__earlyec[@]}" with evalexitcode "${PIPESTATUS[@]}" and
get rid of the PROMPT_COMMAND, unless I'm missing some interaction.


Kind regards

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: [PATCH] Add active mark, face support; activate mark on paste Ángel <angel@16bits.net> - 2020-04-16 02:41 +0200

csiph-web