linguist icon indicating copy to clipboard operation
linguist copied to clipboard

Enhance shell syntax highlighting

Open mahozad opened this issue 4 years ago • 3 comments

Describe the enhancement

I don't know whether the issue is related to linguist.

Is it possible to improve the highlighting for code snippets marked with shell or bash that denote running a command?
It would be great if the name of the command/program was colored and the color of string arguments was improved.

For example, the commands used in the README file of linguist itself:

```shell
gem install github-linguist "string argument"
```

results in:

gem install github-linguist "string argument"

The color of "string argument" is barely distinguishable from the color of the background (on GitHub light theme) and the gem is not colored at all.

Some IDEs like IntelliJ IDEA highlight markdown code snippets labeled with shell or bash language identifier like below. Light theme: Syntax highlighting for markdown code snippets in IntelliJ light theme Dark theme: Syntax highlighting for markdown code snippets in IntelliJ dark theme

mahozad avatar Dec 11 '21 12:12 mahozad

The colour of "string argument" is barely distinguishable from the colour of the background (on GitHub light theme)

This is a common gripe of mine as well. Strings are more noticeable in GitHub's dark theme, though overall, most of the colours GitHub uses for syntax highlighting are quite... austere. You can find an exhaustive list of colours here.

and the gem is not coloured at all.

That's a known limitation of the grammar Linguist currently uses for highlighting shell-scripts. Best I can recommend at this point is filing an issue upstream, although it should be noted that such things have been reported to that repository before.

Alhadis avatar Dec 11 '21 12:12 Alhadis

Hi, this is highly unrelated, but shell syntax highlighting works. Just requires a specific syntax: use console, and the text before the $ needs to have :~ E.g:


foo/bar/dir:~ (main) $ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/rust-bin`
error getting string?? "foo/bar/string"

foo@coolUseri:~ (main) $ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s

Strings don't stand out though

islami00 avatar Feb 19 '22 20:02 islami00

Almost no use cases I find want to visualize a session though.


Just simple readable commands usually found in

Install Instructions

that you can copy 1 To 1 into your terminal.

ElectronicsArchiver avatar Apr 15 '22 16:04 ElectronicsArchiver

Agreed. Here are some examples from a project I work on where the contents are easy to copy and paste into a terminal. This is also how they would appear if written in a shell script. First example with shell:

sudo systemctl start docker.service
sudo systemctl enable docker.service
npm run local:down
npm run local

The syntax highlighting here is not consistent and not highlighting what I would expect. The shell-script highlighting is the same:

sudo systemctl start docker.service
sudo systemctl enable docker.service
npm run local:down
npm run local

mstefanwalker avatar Nov 11 '22 06:11 mstefanwalker