install.fairie/home/.chezmoitemplates/universal/zx
Brian Zalewski ea10ebba44 Update 3 files
- /home/.chezmoiscripts/universal/run_onchange_after_20-apply-settings.tmpl
- /home/.chezmoitemplates/universal/zx
- /home/private_dot_config/xsettingsd/xsettingsd.conf
2023-01-05 09:09:21 +00:00

83 lines
No EOL
2 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const execSync = require('child_process').execSync
// Log symbols
const figuresDefault = {
bullet: '●',
circle: '◯',
cross: '✖',
lozenge: '◆',
play: '▶',
pointer: '',
square: '◼',
star: '★',
tick: '✔'
}
const figuresFallback = {
bullet: '■',
circle: '□',
cross: '×',
lozenge: '♦',
play: '►',
pointer: '>',
square: '■',
star: '✶',
tick: '√'
}
function isUnicodeSupported() {
if (process.platform !== 'win32') {
// Linux console (kernel)
return process.env.TERM !== 'linux'
}
return (
Boolean(process.env.CI) ||
// Windows Terminal
Boolean(process.env.WT_SESSION) ||
// ConEmu and cmder
process.env.ConEmuTask === '{cmd::Cmder}' ||
process.env.TERM_PROGRAM === 'vscode' ||
process.env.TERM === 'xterm-256color' ||
process.env.TERM === 'alacritty'
)
}
const figures = isUnicodeSupported() ? figuresDefault : figuresFallback
function log(type, label, msg) {
let icon, message
if (type === 'info') {
icon = chalk.cyanBright(figures.pointer)
message = chalk.gray.bold(msg)
} else if (type === 'star') {
icon = chalk.yellowBright(figures.star)
message = chalk.bold(msg)
} else if (type === 'success') {
icon = chalk.greenBright(figures.play)
message = chalk.bold(msg)
} else if (type === 'warn') {
icon = `${chalk.yellowBright(figures.lozenge)} ${chalk.bold.black.bgYellowBright(' WARNING ')}`
message = chalk.yellowBright(msg)
} else if (type === 'error') {
icon = `${chalk.redBright(figures.cross)} ${chalk.black.bold.bgRedBright(' ERROR ')}`
message = chalk.redBright(msg)
}
const outputMessage = `${icon} ${chalk.bold(label)} ${message}`
console.log(outputMessage)
}
function runCommand(spinnerTitle, command) {
execSync(`gum spin --spinner dot --title "${spinnerTitle}" -- ${command}`, {
stdio: 'inherit',
shell: true
})
}
async function runSilentCommand(command) {
execSync(`${command}`, { stdio: 'inherit', shell: true })
}
function fileExists(pathToFile) {
return fs.existsSync(pathToFile)
}