Files
fish-shell/doc_src
Johannes Altmanninger f415413bfb Strip "$ " prefixes on paste
Code blocks are often written like

	$ echo hello world
	hello world

The "$ " is widely understood to introduce a shell command.  It's often
easier to copy the whole line than copying everything after "$ ".

This gets more pronounced when there are multiple commands without interleaved
output (either due to omission or the rule of silence). Copying the whole
code block is the most natural first step.

You could argue that this is a presentation issue - the dollar prefix
should be rendered but not copied to clipboard. But in my experience there
are many cases where there is no HTML or Javascript that would allow the
copy-to-clipboard functionality to strip the prefixes.

The "$ " prefix is almost never useful when pasting; strip it automatically.

Privileged commands use "# " as prefix which overlaps with comments, so do
not strip that until we can disambiguate (another potential reason not to
do that would be safety but it's unclear if that really matters).

Add the new logic to the commandline builtin, because we don't know about the
AST in fish script. (Technically, the tokenizer already knows whether a "$
" is in command position and at the beginning of a line, but we don't
have that either (yet).)

Maybe we should move the rest of __fish_paste over as well. I'm not sure what
difference that would make; for one, pasting could no longer be cancelled
by ctrl-c (in theory), which seems like a good direction?
2025-03-01 07:55:53 +01:00
..
2025-03-01 07:55:53 +01:00
2025-01-08 20:38:43 +08:00
2022-09-17 21:31:06 +08:00
2024-11-21 18:28:43 +01:00
2023-08-23 23:08:56 +02:00
2025-02-27 21:10:07 +01:00
2024-09-15 09:39:13 +02:00
2024-06-22 14:58:07 +02:00