mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-14 05:31:14 -03:00
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?
32 lines
2.3 KiB
Fish
32 lines
2.3 KiB
Fish
complete -c commandline -s h -l help -d "Display help and exit"
|
|
complete -c commandline -s a -l append -d "Add text to the end of the selected area"
|
|
complete -c commandline -s i -l insert -d "Add text at cursor"
|
|
complete -c commandline -s i -l insert-smart -d 'Add text at cursor but DWIM, stripping leading $'
|
|
complete -c commandline -s r -l replace -d "Replace selected part"
|
|
|
|
complete -c commandline -s j -l current-job -d "Select job under cursor"
|
|
complete -c commandline -s p -l current-process -d "Select process under cursor"
|
|
complete -c commandline -s s -l current-selection -d "Select current selection"
|
|
complete -c commandline -s t -l current-token -d "Select token under cursor"
|
|
complete -c commandline -s b -l current-buffer -d "Select entire command line (default)"
|
|
|
|
complete -c commandline -s c -l cut-at-cursor -d "Only return that part of the command line before the cursor"
|
|
complete -c commandline -s f -l function -d "Inject readline functions to reader"
|
|
complete -c commandline -s x -l tokens-expanded -d "Print a list of expanded tokens"
|
|
complete -c commandline -l tokens-raw -d "Print a list of raw tokens"
|
|
|
|
complete -c commandline -s I -l input -d "Specify command to operate on"
|
|
complete -c commandline -s C -l cursor -d "Set/get cursor position, not buffer contents"
|
|
complete -c commandline -s B -l selection-start -d "Get current selection starting position"
|
|
complete -c commandline -s E -l selection-end -d "Get current selection ending position"
|
|
complete -c commandline -s L -l line -d "Print/set the line the cursor is on"
|
|
complete -c commandline -l column -d "Print/set the column the cursor is on"
|
|
complete -c commandline -s S -l search-mode -d "Return true if performing a history search"
|
|
complete -c commandline -s P -l paging-mode -d "Return true if showing pager content"
|
|
complete -c commandline -l paging-full-mode -d "Return true if pager is showing all content"
|
|
complete -c commandline -l search-field -d "Operate on the pager search field"
|
|
complete -c commandline -l is-valid -d "Return true if the command line is syntactically valid and complete"
|
|
complete -c commandline -l showing-suggestion -d "Return true if the command line has an autosuggestion"
|
|
|
|
complete -c commandline -n '__fish_contains_opt -s f function' -a '(bind --function-names)' -d 'Function name' -x
|