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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -