Skip to content
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

Additional clip copy options #1028

Merged
merged 2 commits into from
Jan 31, 2025

Conversation

NotTheDr01ds
Copy link
Contributor

@NotTheDr01ds NotTheDr01ds commented Jan 30, 2025

Proposal for #1009:

  • Passes complex values through table -e to render properly
  • By default, strips ansi codes, unless --ansi (-a) switch is used
  • Can accept a Nushell commandline and highlight using clip copy --nu-highlight. Uses a nu -n instance to ensure basic color codes that will work on Discord (might need to consider alternatives)
  • Can accept a prefix string like # => which will be added to the beginning of each line.

cc: @Bahex for review and feedback

@Bahex
Copy link
Contributor

Bahex commented Jan 30, 2025

Rendering non string input with table -e is fine, and once we're doing that including --ansi makes sense.

I feel like including nu-highlight and prefixing options are a little too much and optimizing for the specific use case of pasting to discord. I would prefer including another std command like nu-highlight-default.

PS: because $env is scoped to the command, you can just set $env.config.color_config = {} in the command and that should make table use the default colors too.

@NotTheDr01ds
Copy link
Contributor Author

NotTheDr01ds commented Jan 30, 2025

I agree with you on the nu-highlight - Probably better as a separate command. As you can probably tell, I was second-guessing this one even as I posted :-).

A prefix would be useful for any content, though. It could be a > for Markdown, a # => for doc or GitHub pasting, adding indentation, etc.

@Bahex
Copy link
Contributor

Bahex commented Jan 30, 2025

I guess I can accept it. I just think of clip commands as primitive building blocks for more complex commands rather than ones to be used on their own all that much.

@NotTheDr01ds
Copy link
Contributor Author

@Bahex You're probably right that the prefix functionality should be a separate command. I guess the only concern is that it pretty much has to duplicate the "structured-data -> string" functionality of the clip copy anyway. I've pushed an update with it separated out, though. Let me know what you think. Thanks!

@NotTheDr01ds NotTheDr01ds merged commit bab7845 into nushell:main Jan 31, 2025
1 check passed
@Bahex
Copy link
Contributor

Bahex commented Feb 1, 2025

Looks good to me, though depending on other potential additions, we might wanna move prefix to a different module in the future, like render or format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants