parse bash $PS1 escape characters
npm install decode-promptparse bash
$PS1 escape characters


`` js`
var decode = require('../');
var s = decode(process.argv[2], { env: process.env });
console.log(s);
``
$ node example/prompt.js '\w \$ '
~/projects/decode-prompt $
$
``
substack : decode-prompt $ node example/prompt.js "<$PS1>"
substack : decode-prompt $
` js`
var decode = require('decode-prompt')
Return the decoded bash $PS1 string str.
* opts.env - environment variables to use. $NAME and ${NAME} are decoded andopts.env
some options use as a fallback default value.opts.now
* - date for all the time functions to use, default: new Dateopts.hostname
* - the os.hostname() value to use, otherwise os.hostname()opts.jobs
* - number of jobs currently managed by the shell, default: 0opts.tty
* - the shell's tty name (like the tty command gives), default: -1opts.shell
* - the current $SHELL, default: opts.env.SHELL.opts.user
* - username to use, default: opts.env.USER.opts.version
* - version of the shell (bash), default: '0.0.0'opts.cwd
* - current working directory,opts.env.PWD || process.cwd()
default: opts.dirtrim
* - number of directories to trim output at with an ellipsis,opts.env.DIRTRIM || 0
default: opts.history
* - history number, default: 0opts.command
* - command number, default: 0opts.uid
* - uid, default: opts.env.UID || process.getuid()
With npm do:
```
npm install decode-prompt
MIT