This is not the first time I have ranted about command prompts, but I cannot help ranting about them whenever I see them in source code. In short, a piece of source code with command prompts is like a bag of cooked shrimps sold in grocery stores – it does not make sense, and an otherwise good thing is ruined. I like cooking raw shrimps (way more tasty).
The command prompt here refers to the characters you saw in commands as the prefix, which indicates “I’m ready to take your commands”. In a Unix shell, it is often $. In R, it is > by default. A shell example from the GTK web page:1
$ jhbuild bootstrap
$ jhbuild build meta-gtk-osx-bootstrap
$ jhbuild build meta-gtk-osx-core
And an R example from R and Data Mining:
> data("bodyfat", package = "mboost")
> str(bodyfat)
There are numerous examples like this on the web and in the books (sorry, GTK developers and Yanchang Zhao; I came to you randomly). Most people seem to post their code like this. I can probably spend half a day figuring out a problem in measure theory, but I cannot, even if I spend two years, figure out why people include command prompts when publishing source code.
Isn’t it too obvious that you are wasting the time of your readers?
Whenever the command prompts are present in the source code, the reader has to copy the code, remove the prompts, and use the code. Why there has to be an additional step of removing the prompts? Why cannot you make your code directly usable to other people?
jhbuild bootstrap
jhbuild build meta-gtk-osx-bootstrap
jhbuild build meta-gtk-osx-core
data("bodyfat", package = "mboost")
str(bodyfat)
I’m aware of the column selection mode in some editors. I just do not understand why the correct thing should not happen in the first place.
-
Some may argue the prompt helps typesetting, and it makes the code stand out because of the common prefix. In R,
+means the last line is not complete, so>and+present the structure of the code, e.g.> for (i in 1:10) { + print(i) + }I believe the structure of code should be presented by the level of indentation, which does not hurt the source code. To make the code stand out, choose a background color (shading) for it. That is the only correct way for typesetting purposes.
-
Some may argue that we see prompt characters in the console / shell / REPL by default. Readers may be confused if we are not consistent. To me, this argument is like after I have seen your picture in a frame once, every time you should carry a frame with you (consistently), otherwise I won’t be able to recognize you.
So, please stop code pollution, and post usable code.
-
Update on Dec 8, 2017: Wow wow wow! I just checked it again, and they have updated the code and removed the prompt characters! ↩︎
Donate
As a freelancer (currently working as a contractor) and a dad of three kids, I truly appreciate your donation to support my writing and open-source software development! Your contribution helps me cope with financial uncertainty better, so I can spend more time on producing high-quality content and software. You can make a donation through methods below.
-
Venmo:
@yihui_xie, or Zelle:xie@yihui.name -
Paypal
-
If you have a Paypal account, you can follow the link https://paypal.me/YihuiXie or find me on Paypal via my email
xie@yihui.name. Please choose the payment type as “Family and Friends” (instead of “Goods and Services”) to avoid extra fees. -
If you don’t have Paypal, you may donate through this link via your debit or credit card. Paypal will charge a fee on my side.
-
-
Other ways:
WeChat Pay (微信支付:谢益辉) Alipay (支付宝:谢益辉) 

When sending money, please be sure to add a note “gift” or “donation” if possible, so it won’t be treated as my taxable income but a genuine gift. Needless to say, donation is completely voluntary and I appreciate any amount you can give.
Please feel free to email me if you prefer a different way to give. Thank you very much!
I’ll give back a significant portion of the donations to the open-source community and charities. For the record, I received about $30,000 in total (before tax) in 2024-25, and gave back about $15,000 (after tax).