82 lines
1.6 KiB
JavaScript
Executable file
82 lines
1.6 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
// Relies on this being installed: https://github.com/F1LT3R/ansi-to-svg
|
|
const {stdin} = process;
|
|
|
|
const ansiToSVG = require('ansi-to-svg')
|
|
|
|
getStdin = async () => {
|
|
let result = '';
|
|
|
|
if (stdin.isTTY) {
|
|
return result;
|
|
}
|
|
|
|
stdin.setEncoding('utf8');
|
|
|
|
for await (const chunk of stdin) {
|
|
result += chunk;
|
|
}
|
|
|
|
return result;
|
|
};
|
|
|
|
(async () => {
|
|
// Returns an SVG string
|
|
console.log(ansiToSVG(await getStdin(), {
|
|
// Defaults to 2x for Retina compatibility
|
|
scale: 2,
|
|
|
|
// Font settings
|
|
fontFace: 'Courier',
|
|
fontSize: 14,
|
|
lineHeight: 18,
|
|
|
|
// Padding
|
|
paddingTop: 5,
|
|
paddingLeft: 5,
|
|
paddingBottom: 5,
|
|
paddingRight: 5,
|
|
|
|
// Supply an iTerm2 Color file
|
|
colors: './base16-flat-dark-f1lt3r-256.itermcolors',
|
|
|
|
// Or override the default colors
|
|
// (all defaults shown here)
|
|
colors: {
|
|
black: '#000000',
|
|
red: '#B22222',
|
|
green: '#32CD32',
|
|
yellow: '#DAA520',
|
|
blue: '#4169E1',
|
|
magenta: '#9932CC',
|
|
cyan: '#008B8B',
|
|
white: '#D3D3D3',
|
|
gray: '#A9A9A9',
|
|
redBright: '#FF4500',
|
|
greenBright: '#ADFF2F',
|
|
yellowBright: '#FFFF00',
|
|
blueBright: '#87CEEB',
|
|
magentaBright: '#FF00FF',
|
|
cyanBright: '#00FFFF',
|
|
whiteBright: '#FFFFFF',
|
|
bgBlack: '#000000',
|
|
bgRed: '#B22222',
|
|
bgGreen: '#32CD32',
|
|
bgYellow: '#DAA520',
|
|
bgBlue: '#4169E1',
|
|
bgMagenta: '#9932CC',
|
|
bgCyan: '#008B8B',
|
|
bgWhite: '#D3D3D3',
|
|
bgGray: '#A9A9A9',
|
|
bgRedBright: '#FF0000',
|
|
bgGreenBright: '#ADFF2F',
|
|
bgYellowBright: '#FFFF00',
|
|
bgBlueBright: '#87CEEB',
|
|
bgMagentaBright: '#FF00FF',
|
|
bgCyanBright: '#00FFFF',
|
|
bgWhiteBright: '#FFFFFF',
|
|
backgroundColor: '#000000',
|
|
foregroundColor: '#D3D3D3'
|
|
}
|
|
}))
|
|
})();
|