AI prompts
base on stderr in red # stderred
stderr in red.
## About
stderred hooks on write() and a family of stream functions (fwrite, fprintf,
error...) from libc in order to colorize all stderr output that goes to
terminal thus making it distinguishable from stdout. Basically it wraps text
that goes to file with descriptor "2" with proper ANSI escape codes making text
red.
It's implemented as a shared library and doesn't require recompilation of
existing binaries thanks to _preload/insert_ feature of dynamic linkers.
It's supported on Linux (with `LD_PRELOAD`), FreeBSD (also `LD_PRELOAD`) and
OSX (with `DYLD_INSERT_LIBRARIES`).
Watch this [intro asciicast](https://asciinema.org/a/1705) to see it in action.
## Installation
Clone this repository:
$ git clone git://github.com/ku1ik/stderred.git
$ cd stderred
Important: In all cases below make sure that path to `libstderred.so` is absolute!
### Linux and FreeBSD
Make sure you have cmake and the gcc toolchain required for compilation installed:
# Ubuntu
sudo apt-get install build-essential cmake
# Fedora
sudo yum install make cmake gcc gcc-c++
# FreeBSD
pkg install cmake
Build:
$ make
Export `LD_PRELOAD` variable in your shell's config file by putting following
in your .bashrc/.zshrc:
export LD_PRELOAD="/absolute/path/to/stderred/build/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}"
#### Multi-arch Linux and FreeBSD
On some Linux distros you can install 32-bit packages on 64-bit system. Shared
libraries compiled for 64-bit doesn't work with 32-bit binaries though. It
happens that 64-bit binaries call 32-bit ones resulting in warning message
printed to terminal about not compatible `LD_PRELOAD` shared lib.
Fortunately Linux's dynamic linker has a feature called Dynamic String Token
(DST). It allows dynamic substitution of `$LIB` token in `LD_PRELOAD` variable
with "lib" or "lib64" respectively for 32 and 64-bit binaries when the binary
is being run. Thanks to that you can compile stderred for both architectures
and automatically use proper version of this shared library.
On 64-bit Fedora, for example, you need to install libc development headers for
both architectures:
$ sudo yum install glibc-devel.i686 glibc-devel.x86_64
compile it like this:
$ make 32 && make 64
and export `LD_PRELOAD` like this in your shell's config:
export LD_PRELOAD="/path/to/stderred/\$LIB/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}"
_\* Note that [there is no support for $LIB token on Ubuntu](http://comments.gmane.org/gmane.comp.lib.glibc.user/974)._
### OSX
$ make
Export `DYLD_INSERT_LIBRARIES` variable in your shell's config file by putting following
in your .bashrc/.zshrc:
export DYLD_INSERT_LIBRARIES="/absolute/path/to/build/libstderred.dylib${DYLD_INSERT_LIBRARIES:+:$DYLD_INSERT_LIBRARIES}"
#### Universal lib on OSX
OSX solves multi-arch problem (described above in "Multi-arch Linux and
FreeBSD") by supporting so called "universal" libraries that include 2 copies
of code compiled for both 32 and 64-bit architecture in the single library
file.
If you feel you will want universal library then build it this way:
$ make universal
and export shell env like above.
### Checking if it works
$ find -q
$ cat nonexistingfile
$ ls nonexistingfile
$ python -c 'import os; print "Yo!"; os.write(2, "Jola\n\r")'
$ STDERRED_ESC_CODE=$(echo -e '\e[;92m') ruby -e 'puts "Yo!"; warn "Jola"'
"Jola" should be printed in red color.
## Alternative way: aliasing
Alternative to enabling it globally via shell config is to create alias and
use it to selectively colorize stderr for the commands you run:
$ alias stderred="LD_PRELOAD=/absolute/path/to/build/libstderred.so\${LD_PRELOAD:+:\$LD_PRELOAD}"
$ stderred java lol
## Configuration
### Custom color code
If you prefer other color or you want to use additional escape codes
(for bold/bright, italic, different background) you can export
`STDERRED_ESC_CODE` with desired escape code sequence.
Here's an example for bold red:
bold=$(tput bold || tput md)
red=$(tput setaf 1)
export STDERRED_ESC_CODE=`echo -e "$bold$red"`
### Program Blacklisting
Some programs abuse stderr and print stuff on it even when they really
shouldn't. If you want to turn off stderred for particular programs you can
export `STDERRED_BLACKLIST` with a desired POSIX Extended Regular Expression
matching names of these programs.
Here's an example that will blacklist bash, and all programs with names
starting with "test":
export STDERRED_BLACKLIST="^(bash|test.*)$"
## Authors
Current implementation:
* [Marcin Kulik](https://github.com/ku1ik/)
* [Chris Hoffman](https://github.com/cehoffman/)
* [Brian Tarricone](https://github.com/kelnos/)
[Original concept](http://www.asheesh.org/note/software/stderred.html) and
[initial implementation](http://git.asheesh.org/?p=zzz/colorize-stderr.git;a=summary):
* Asheesh Laroia
## License
You are free to use this program under the terms of the license found in
LICENSE file.
", Assign "at most 3 tags" to the expected json: {"id":"5974","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"