bash - How to generate PS1 in a function (escaping issues) -
i'd move bash prompt's construction function can build modularly. problem cannot figure out how function's result interpreted.
example:
function build_prompt { echo "\@" } export ps1="\$(build_prompt)"
my prompt shows \@
, should current time.
sure there ways around particular example, i'd general solution can use other escaped components, such colours.
this 1 use case prompt_command
variable: running function before displaying prompt updates value of ps1
.
function build_prompt { ps1='\@' } prompt_command='build_prompt'
Comments
Post a Comment