Skip to content

Remove $ prompts when copying terminal commands - #4490

Closed
JairajJangle wants to merge 1 commit into
rust-lang:mainfrom
JairajJangle:main
Closed

Remove $ prompts when copying terminal commands#4490
JairajJangle wants to merge 1 commit into
rust-lang:mainfrom
JairajJangle:main

Conversation

@JairajJangle

@JairajJangle JairajJangle commented Aug 29, 2025

Copy link
Copy Markdown

QOL improvement for online doc interaction - prevent $ prompt char from being copied with the copy to clipboard button on code blocks.

This might not be the most elegant way to tackle this; however, the other solution was to introduce HTML to specifically exclude the $ char from the code block and thus from being selected at all. However, that would break the printability of the book.

For reference:
Screenshot 2025-08-29 at 10 39 23 PM

Earlier, if you pressed the copy button, it would copy the entire line like so:
$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

After the improvement, the copied text would be:
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh


Copying of texts without $ is unaffected.


Copying of texts having $ but aren't necessarily shell code is smartly exempted. So, if you copy this:
Screenshot 2025-08-29 at 10 42 44 PM

It would remain as is:

$ cargo run
   Compiling functions v0.1.0 (file:///projects/functions)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.21s
     Running `target/debug/functions`
The value of x is: 5

@JairajJangle

Copy link
Copy Markdown
Author

Closing due to: #4108 (comment) :(

@JairajJangle

Copy link
Copy Markdown
Author

Nvm, closing this for good after checking the long history of failures to tackle this particular QOL issue. + The mdBook(upstream as everyone says) is no longer accepting PRs on new issues as per the contribution guide:

Only issues that have an E-Help-wanted or Feature accepted label will likely receive reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant