> 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.

More generally, a loadable module command can do whatever you want, and
that's going to be more efficient than any subprocess fork and exec.


      • R... Chet Ramey
        • ... gentoo_eshoes--- via Bug reports for the GNU Bourne Again SHell
        • ... Chet Ramey
        • ... Daniel Colascione
        • ... gentoo_eshoes--- via Bug reports for the GNU Bourne Again SHell
        • ... Chet Ramey
      • R... Chet Ramey
        • ... gentoo_eshoes--- via Bug reports for the GNU Bourne Again SHell
        • ... Chet Ramey
  • Re: [PATCH... Ángel
    • Re: [... Daniel Colascione

Reply via email to