help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Expand a prompt string to calculate its length?


From: Greg Wooledge
Subject: Re: [Help-bash] Expand a prompt string to calculate its length?
Date: Wed, 19 Jun 2019 14:13:58 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Wed, Jun 19, 2019 at 01:09:33PM -0500, Jesse Hathaway wrote:
> Is there anyway to expand a partial prompt string to calculate its length?

In bash 4.4 and above, yes.

wooledg:~$ tmp=${PS1@P}; echo "<$PS1> <${#PS1}> <$tmp> <${#tmp}>"
<\h:\w\$ > <8> <wooledg:~$ > <11>

The @P parameter expansion is one of the new "Parameter transformation"
options.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]