Skip to content

Consider syntax highlighting for shell sessions #1449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
menschel-d opened this issue Jul 20, 2018 · 2 comments · Fixed by #2352
Closed

Consider syntax highlighting for shell sessions #1449

menschel-d opened this issue Jul 20, 2018 · 2 comments · Fixed by #2352

Comments

@menschel-d
Copy link

Currently, code blocks that show interaction with the shell use plain text style.
It has already been discussed in issue #327 that the styles bash or sh are not appropriate since they're intended for shell scripts only.

As shell sessions are such a common case, they are supported by multiple highlighting engines, including both highlight.js and GitHub linguist.

In highlight.js, it is known as shell or console:
https://github.com/highlightjs/highlight.js/blob/master/src/languages/shell.js

In GitHub linguist, it is named ShellSession with the aliases bash session and console:
https://github.com/github/linguist/blob/2942bf9f1bf7a4871167c046c1e27d26cb198200/lib/linguist/languages.yml#L4410-L4421

Here is a demo in linguist (from ch01-03-hello-cargo.md):

$ cargo run
   Compiling hello_cargo v0.1.0 (file:///projects/hello_cargo)
    Finished dev [unoptimized + debuginfo] target(s) in 0.33 secs
     Running `target/debug/hello_cargo`
Hello, world!

I'd like to suggest the usage of console for the following reasons:

  • It is supported by both highlight.js (and hence mdbook) and also GitHub linguist.
  • It clearly states the intention.
  • It should be less error prone than shell, which can easily be confused with sh (which is intended for shell scripts and not sessions).
@steveklabnik
Copy link
Member

console sounds great!

carols10cents added a commit to carols10cents/diesel.rs-website that referenced this issue Jul 28, 2018
I learned in rust-lang/book#1449 that
highlight.js has `shell` for console sessions. This is more appropriate
than `bash`, which is for highlighting bash scripts.
steveklabnik added a commit that referenced this issue Jun 2, 2020
The "text" style is just plain text, but we were also using it for
command line examples. Turns out that highlight.js has a style for this,
called "console."

This commit updates all instances of using text for a command line
example to use console instead.

Fixes #1449
@steveklabnik
Copy link
Member

Almost two years later, I've now done this. Thanks for bringing it up!

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

Successfully merging a pull request may close this issue.

3 participants