-
Notifications
You must be signed in to change notification settings - Fork 10
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
Alternative specification for pipe formatting #60
Comments
Agreed. |
Hi! Yes, this is really useful. When I wrote some lines in the specification I though this as a parameter "do you want the pipelines to be connected?" and exactly these scripts are the perfect example 😊 |
i think this should be modifiable in some settings, i personally quite strongly dislike the second way 🤣 and i would write the following instead def "apply to" [
file: path
modification: closure
] {
$file
| path expand
| open --raw
| from toml
| do $modification
| save --force $file
} |
This falls into the same issue for windows users - you can't have a | at the start of the line, indent or not. |
'tis why i propose to make in configurable :) |
@amtoine Having it configurable, is good, but I'm also talking about what the default formatting should be. I believe that you would want default formatting that could work properly regardless of OS, since nushell aims to work regardless of OS. |
What do you mean with Windows users? I can copy and paste that script in my nushell terminal and it works 🤩. Do you have trouble with that script? |
yeah i think Nushell should be able to handle copy pasting any way to format pipelines, the parser shouldn't care at all 😕 if that's not possible, i agree the default should work the best for everyone -even though it's Windows which is annoying again, ugh...-, i would just turn that default off as soon as i start a Nushell project 😉 my gut feeling is that, putting the let vals = rec.
values().
cloned().
enumerate().
map(|(i, v)| {
if i == id {
mutate_value_cell(&v, &cell_path, cell).unwrap()
} else {
v
}
}).
collect(); instead of the conventional let vals = rec
.values()
.cloned()
.enumerate()
.map(|(i, v)| {
if i == id {
mutate_value_cell(&v, &cell_path, cell).unwrap()
} else {
v
}
})
.collect(); anyways 😉 |
@AucaCoyan |
On 24/06/02 04:00AM, Antoine Stevan wrote:
@AucaCoyan
if there is no issue anymore with copy pasting pipelines on Windows, then it's all good 😌
fdncred shared the issue. I'm not on windows so I can't talk about the issue first hand.
|
Here is an example @AucaCoyan, if your terminal does not support bracketed paste, such as Windows Terminal, when you paste the middle portion of the custom command, something like this $file
| path expand
| open --raw
| from toml
| do $modification
| save --force $file nushell/reedline pastes one line at a time. So, it looks like this to nushell and each line tries to be executed giving you a different result than what you want. $file # it runs this | path expand # then tries to run this | open --raw # then tries to run this, and so on alternatively, if you paste this $file |
path expand |
open --raw |
from toml |
do $modification |
save --force $file nushell sees $file | # oh, this statement isn't complete, don't execute it yet path expand | # oh, there's another pipe, so this statement isn't complete, don't execute yet open --raw | # oh, another pipe, don't execute yet So, all I was saying is that I prefer the pipes at the end because Windows users won't have a problem with copying and pasting pieces out of the script/custom command. You are correct that the entire custom command can be pasted fine but that's because it's in a You can see here that I pasted the entire custom command and it worked just fine. But if I want just the part in question, it pukes because the pipes are in the wrong place for windows to understand what to do. |
Thanks for the clarification! I tried also in Windows and had the same result in Windows Terminal. Because I've been using nushell in windows for so long I didn't expect it to "magically work" in linux 😋. |
I'm not sure. I'm hopeful that once Ghostty gets fully supported in Windows that it will be I'm not sure. I think in most terminals you have to enable the feature though. |
The specification.md describes the default formatting for pipelines to be a wall of lines.
In the nushell discord fdncred mentioned how this creates issues with copy pasting code to the terminal on windows. Because of this I would like to suggest alternative formatting & indenting:
This python style indenting still showcases that a pipeline is continued, despite that the pipe symbol is not at the start of the line.
The text was updated successfully, but these errors were encountered: