Search code examples
terminalzshzshrcansi-escapealacritty

How to find/replace a specific ANSI escape code in all STDOUT/STDERR from any source


My terminal background colour is dark blue.

A few tools that I use emit dark blue text regardless, making the text invisible to me.

Can I add something to my .zshrc that will read all STDOUT/STDERR from any/every source and automatically replace any dark blue ANSI escape code with a white one?

From my alacritty.yml:

colors:
  primary:
    background: '0x002b36'
    foreground: '0x839496'
    dim_background: '0x002b36'
    dim_foreground: '0x839496'
    bright_background: '0x002b36'
    bright_foreground: '0x839496'
  cursor:
    text:   '#002b36' # base03
    cursor: '#839496' # base0
  normal:
    black: '0x073642'
    red: '0xdc322f'
    green: '0x859900'
    yellow: '0xb58900'
    blue: '0x268bd2'
    magenta: '0xd33682'
    cyan: '0x2aa198'
    white: '0xeee8d5'
  bright:
    black: '0x002b36'
    red: '0xcb4b16'
    green: '0x586e75'
    yellow: '0x657b83'
    blue: '0x839496'
    magenta: '0x6c71c4'
    cyan: '0x93a1a1'
    white: '0xfdf6e3'

From my .zshrc:

autoload -U colors
colors

Solution

  • Well, no, not from your .zshrc file, but you can edit your alacritty.yml file. In there, under normal:, replace the value of blue: with another value of your choice. You can read more about setting these values in the example alacritty.yml file distributed with Alacritty.