CLI 2: op run removes colors, ignores terminal size

gboudrea
gboudrea
Community Member

ls outputs colors, and uses multiple columns:

But using op run, it doesn't:


1Password Version: CLI 2.1.0
Extension Version: Not Provided
OS Version: macOS

Comments

  • XIII
    XIII
    Community Member

    What happens if you add --no-masking to op run?

  • gboudrea
    gboudrea
    Community Member

    Then the result shows in columns, but no colors.

  • Hey @gboudrea, thank you for reaching out to us!
    I think the problem here is that ls detects op run to not be a terminal-type output, which is why colours are disabled by default (since the default setting for the --color flag is auto).
    Easiest way to fix this would be to include the --color flag in your command, i.e. op run -- ls --color.
    Please do let us know if this helps.

    Best,
    Horia

  • gboudrea
    gboudrea
    Community Member

    Indeed, that fixes it.
    I also noticed other commands (heroku, terraform) correctly detect that colors can be used with op run, and will use color with no additions in the command : i.e. op run --no-masking -- heroku will output colors.

    Thanks.

  • Great! Let us know if we can help with anything else.

  • Rotendahl
    Rotendahl
    Community Member

    I'm having the same problem.
    I would really prefer having the output masked, but removing the colours from for instance compile output makes it hard to find errors.

  • Hey Rotendahl,

    We currently have a ticket tracking this very problem internally. Although not our top focus, we will try to prioritise it between our development cycles. We'll keep the thread updated with any progress on this!

    Best,
    Horia

  • jonb1
    jonb1
    Community Member

    +1

  • lukany
    lukany
    Community Member

    Hi @Horia.Culea_1P, has there been any progress? I am also using op run with a tool where I'd really appreciate coloured output.

  • Hacksore
    Hacksore
    Community Member
    edited March 2023

    Looking for this feature as well and here is example of where both programs seem to need to handle this.

    Pass a color flag to watch and npm and that seems to let watch handle colors correctly, maybe the CLI needs something similar?
    watch --color npm start --color always

    So I'd imagine we'd want 1password CLI to support a --color flag.

  • Hacksore
    Hacksore
    Community Member

    Wait maybe it's really only the downstream program needing support cause this seems to work for me.

  • Hi @lukany:

    We don't have anything to share just yet, so please keep an eye out for updates.

    @Hacksore:

    That's exactly right, support for the --color flag will depend on the program you're running. 1Password CLI masking secrets means that to the run program, it's no longer considered a terminal-type output, so generally tools that use auto-detection to decide whether or not to send colors will default to no color. If a program has a "force color" flag or similar, that should generally work with op run .....

    Jack

  • Hacksore
    Hacksore
    Community Member
    edited March 2023

    Just wanted to share for those here it's possible to set the environment variable FORCE_COLOR for most programs to force color output.

    Not quite sure about the compatibility from program to program but it works for node based loggers 😅.

    However, it seems to be working now in my contrived test somehow without --color or FORCE_COLOR 😬.

  • Thanks for sharing @Hacksore!

    Jack

This discussion has been closed.