hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Remove $ from command

Open az-pz opened this issue 1 year ago • 11 comments

Remove $ from command to easily paste in terminal without getting an error. $ at the beginning gives an error.

az-pz avatar Dec 11 '23 16:12 az-pz

For an actual complete solution I'd suggest to continue to use $ and ```console consistently but just make the $ part non-selectable in the browser, by adding extra_css like this:

.highlight .gp { /* Generic.Prompt */
    user-select: none;
}

oprypin avatar Dec 12 '23 23:12 oprypin

Oh interesting! Does that also affect the copy button?

ofek avatar Dec 13 '23 01:12 ofek

Updating https://github.com/az-pz/hatch/blob/master/docs/assets/css/custom.css to hide $ from copying is certainly a possibility. But shell commands elsewhere in the docs don't use $ or console code type. $ was removed to make it consistent with other shell commands in the install.md .

az-pz avatar Dec 13 '23 02:12 az-pz

Oh right you bring up a good point about console. @oprypin Can you recommend an approach that neglects syntax highlighting? I deliberately do not use that because the output gets highlighted randomly sometimes which I do not want users to see.

ofek avatar Dec 13 '23 02:12 ofek

But shell commands elsewhere in the docs don't use $ or console code type.

https://github.com/search?q=repo%3Apypa%2Fhatch+%2F%5E+*%5C%24+%2F&type=code

I deliberately do not use that because the output gets highlighted randomly sometimes which I do not want users to see.

Hmm that's the first time I hear such a conclusion on the topic, wasn't aware

oprypin avatar Dec 13 '23 06:12 oprypin

$ command foo 11 bar
Echo 123
More stuff
Why is this blue

ofek avatar Dec 13 '23 06:12 ofek

It's conceivable that it is late at night after a long day and I don't know what I'm talking about, perhaps I was thinking about Bash since I do appear to use console elsewhere

ofek avatar Dec 13 '23 06:12 ofek

Right- there can be arbitrary highlighting for the first word in the command, maybe that's what you were thinking of. But maybe we could configure and fix specific types of highlighting that you don't like, let me know

The text is blue because this the "output" highlighting

oprypin avatar Dec 13 '23 06:12 oprypin

I am inclined to keep the dollar signs. Not only that, but when I think more about the situation, why would someone even press the copy button on a console snippet? Wouldn't it make more sense to disable copy there?

I'm not dismissing the other potential fix for copying to ignore that character I'm just curious what both of you think.

ofek avatar Dec 13 '23 06:12 ofek

I definitely like dollar signs 😄 I think it can be confusing without them

oprypin avatar Dec 13 '23 06:12 oprypin

perhaps I was thinking about Bash since I do appear to use console elsewhere

# console
$ command --that gets --syntax highlighting
no $ prefix here is for the output from command
so all of this content is intentionally the same colour
syntax highlighting for output would be awkward
# bash (technically the command shouldn't have the $ prefix
$ command --that gets --syntax highlighting
no $ prefix here is for the output from command
so all of this content is intentionally the same colour
syntax highlighting for output would be awkward

In mkdocs, depending on the config the syntax highlighting varies.

On github with the styling above, you can see the difference between the two for actual command highlighting is not all that useful... but it's better with actual bash scripts syntax, while console is more suitable for here is a command with the output.

polarathene avatar May 09 '24 11:05 polarathene