I'm trying to create a simple script that, among other things, will create a subshell:
#!/bin/sh
# setup
"${@:-$SHELL}"
# teardown
The question is: I need to change the default prompt, so for example:
$ # default shell
$ ./myscript
(myscript) $ # subshell
(myscript) $ exit
$
I tried to change PROMPT
and PS1
, but none of these works. How can I do that?
PS.: I need a solution that works both on Bash and ZSH, if possible.
Best Answer
I think you can create a subshell with a different prompt like this:
Example
Current env:
In sub shell:
Back to original shell: