How to print prompt content for test purpose in Elvish shell?

134 Views Asked by At

related: https://github.com/elves/elvish/issues/827


I'm on a prompt implementation and would like to test I correctly support elvish. I already do that for other shells by invoking their prompt variable/method, e.g.

bash
bash -ci 'echo $PS1'
fish
fish -c 'fish_prompt'

How can I print te prompt content in Elvish?

1

There are 1 best solutions below

0
On

From IRC I got some hint:

edit:prompt = { tilde-abbr $pwd; put '❱ ' }

But output is not the same as what elvish render:

~/.pure❱ $edit:prompt
▶ '~/.pure'
▶ '❱ '

I'm expecting:

~/.pure❱ 

The outputs from prompts are stringified and concatenated, you can achieve it with:

$edit:prompt | each $print~

However this doesn't work with elvish -c or echo ... | elvish.

elvish doesn't have an interactive mode per se. Unlike POSIX shells. I know it's been discussed before but I can't recall why the edit: namespace isn't available when doing elvish -c '$edit:prompt | each $print~'