-
-
Notifications
You must be signed in to change notification settings - Fork 15k
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
stdoutisatty: init at 1.0 #345558
stdoutisatty: init at 1.0 #345558
Conversation
Homepage: https://github.com/lilydjwg/stdoutisatty It is surprisingly difficult to get consistent, colored outputs in the terminal, especially when commands are piped into a pager. In fact, there is a whole Arch wiki page on related topics: - https://wiki.archlinux.org/title/Color_output_in_console#Reading_from_stdin Among the solutions listed there, `stdoutisatty` is one of the simplest: it hijacks the `isatty` function call used by most apps to determine whether `stdout` is an actual terminal, and always returns `1 (true)`. With this I can simply do: ```bash stdoutisatty tree | less cat flake.lock | stdoutisatty jq | less ... ``` and enjoy my colorful outputs, without figuring out whatever `--color=always` type of flags these cli apps may or may not provide for colored outputs.
Also, we have faketty for the same purpose: https://github.com/dtolnay/faketty |
Ah, this is awesome! Thank you! And it's Memory Safe (trademark) 😆 So the existence of |
|
||
cmakeFlags = [ | ||
# must specify the full path to `libstdoutisatty.so` in the nix store | ||
"-DCMAKE_C_FLAGS=-DLIB_FILE='\"${placeholder "out"}/lib/libstdoutisatty.so\"'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"-DCMAKE_C_FLAGS=-DLIB_FILE='\"${placeholder "out"}/lib/libstdoutisatty.so\"'" | |
(lib.cmakeFeature "CMAKE_C_FLAGS" "-DLIB_FILE='\"${placeholder "out"}/lib/libstdoutisatty.so\"'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that's much better! Thank you!
The old version may lead to confusing `overrideAttrs` behaviors. See discussions linked in the PR review comments. Co-authored-by: Nick Cao <nickcao@nichi.co>
Co-authored-by: Nick Cao <nickcao@nichi.co>
Co-authored-by: Nick Cao <nickcao@nichi.co>
Fixed and squashed some commits (unsquashed: master...7a5f7b9). |
Description of changes
Homepage: https://github.com/lilydjwg/stdoutisatty
It is surprisingly difficult to get consistent, colored outputs in the terminal, especially when commands are piped into a pager. In fact, there is a whole Arch wiki page on related topics:
Among the solutions listed there,
stdoutisatty
is one of the simplest: it hijacks theisatty
function call used by most apps to determine whetherstdout
is an actual terminal, and always returns1 (true)
. With this I can simply do:... and enjoy my colorful outputs, without figuring out whatever
--color=always
type of flags these cli apps may or may not provide for colored outputs. Afaik, there is nothing like this in nixpkgs yet, so I would like to package and maintain it.Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.