Is it possible to extract the user's PS1 from the environment in a Swift script, so that I can replicate their prompt?
I left a note for myself a few years ago saying that it "disappears from the environment in the context of the script", but I figured it would be useful to ask.
(I'm aware that this question won't necessarily work between shells, but assume that I only care about bash
. Furthermore, I know I can't necessarily interpret everything in a user's prompt, but I would like to get it).
CodePudding user response:
Try this in Swift script :
bash -i -c 'echo "$PS1"'