You can try a simple hook:
---
output: html_document
---
```{r}
library('knitr')
knit_hooks$set(
prompt = function(before, options, envir) {
options(prompt = if (options$engine %in% c('sh','bash')) '$ ' else 'R> ')
})
```
```{r, prompt=TRUE}
1+1
```
but for the bash chunks this
```{bash, prompt=TRUE}
pandoc --version | head -1
```
```{r, prompt=TRUE}
1+1
```

And you can add opts_chunk$set(prompt=TRUE), so you do not need to write prompt=TRUEfor each fragment
source
share