Skip to content

NO_COLOR or --no-color options #3057

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

Open
sebastien opened this issue Jan 11, 2024 · 3 comments
Open

NO_COLOR or --no-color options #3057

sebastien opened this issue Jan 11, 2024 · 3 comments

Comments

@sebastien
Copy link

zellij does not seem to support the NO_COLOR environment variable, or have a a --no-color option, which makes it hard to script the CLI as for instance:

LAST_SESSION="$(zellij list-sessions|head -n1|cut -d' ' -f1)"
echo "$LAST_SESSION"
zellij attach "$LAST_SESSION"

will fail with

No session with the name 'zippy-megalodon' found!

while

▷ zellij list-sessions
zippy-megalodon [Created 0s ago] (EXITED - attach to resurrect)

The reason is that LAST_SESSION contains the color codes. Now, if we do this instead, this will work.

LAST_SESSION="$(zellij list-sessions|sed 's/\x1B\[[0-9;]*m//g'|head -n1|cut -d' ' -f1)"
echo "$LAST_SESSION"
zellij attach "$LAST_SESSION"

TL;DR supporting NO_COLOR or --no-color would make scripting zellij with the shell much easier.

@cristiand391
Copy link
Contributor

Even supporting NO_COLOR, change to the output could break scripts like these. I would prefer support for json output.

In the meantime, you should be using zellij list-sessions --no-formatting --short in your script.

@imsnif
Copy link
Member

imsnif commented Jan 12, 2024

What's wrong with the --no-formatting option? That's exactly the reason for it.

@sebastien
Copy link
Author

I didn't know there was a --no-formatting option (not listed in --help), but it does the trick. It would be nice to turn the --no-formatting flag on when NO_COLOR is set, but this solves my problem.

eliasp added a commit to eliasp/no_color that referenced this issue Jan 28, 2024
zellijz doesn't support `NO_COLOR` (yet), but there's a GitHub issue at zellij-org/zellij#3057
which also provides the hint to use the `--no-formatting` arg.
jcs pushed a commit to jcs/no_color that referenced this issue Dec 2, 2024
zellijz doesn't support `NO_COLOR` (yet), but there's a GitHub issue at zellij-org/zellij#3057
which also provides the hint to use the `--no-formatting` arg.
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

No branches or pull requests

3 participants