Vyxal D
, 18 bytes
`{Ȯq‛DĖ+$/Ḣ℅h:₴`DĖ
Try it Online!
Sample outputs:
`{Ȯq‛DĖ
`DĖ
`{Ȯq‛DĖ+$/Ḣ℅h:₴`{Ȯq‛DĖ
`DĖ+$/Ḣ℅h:₴`{Ȯq‛DĖ+$/Ḣ℅h:₴`DĖ+$/Ḣ℅h:₴`{Ȯq‛DĖ+$/Ḣ℅h:₴`DĖ
`DĖ+$/Ḣ℅h:₴`{Ȯq‛DĖ
Explanation:
` `D # push this string to the stack and triplicate => [ <code> , <code> , <code> ]
Ė # Execute the top => [ <code>, <code> ]
{ # While true
Ȯ # push the second to last item on the stack => [ <code> , <code> , <code> ]
q‛DĖ+ # quote and add ‛DĖ => [ <code> , <code> , `<code>`DĖ ]
$ # swap => [ <code> , `<code>`DĖ , <code> ]
/Ḣ # split and discard the first element => [ <code> , [`DĖ] ]
℅h # choose at random an element and get it's first element => [ <code> , ` ]
:₴ # duplicate and print without a newline => [ <code> , ` ]
## on loop ##
{ # While true
Ȯ # push the second to last item on the stack => [ <code> , ` , <code> ]
q‛DĖ+ # quote and add ‛DĖ => [ <code> , ` , `<code>`DĖ ]
$ # swap => [ <code> , `<code>`DĖ , ` ]
/Ḣ # split and discard the first element => [ <code> , [<code>, DĖ] ]
℅h # choose at random an element and get it's first element => [ <code> , <char> ]
:₴ # duplicate and print without a newline => [ <code> , <char> ]