Skip to content
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

Adapt remaining arcticicestudio "fade-out" changes #18

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ node_modules/
# ESLint automatically applies ignore pattern for "dotfiles" by default to prevent accidentally lint over paths like
# `.git` or any other critical paths.
!**/.eslintrc.js
!.remarkrc.js
!lint-staged.config.js
!prettier.config.js
!.remarkrc.mjs
12 changes: 10 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2016-present Sven Greb <[email protected]>
* This source code is licensed under the MIT license found in the license file.
* This source code is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license found in the license file.
*/

/**
Expand All @@ -12,7 +12,15 @@
*/
module.exports = {
root: true,
extends: ["@arcticicestudio/eslint-config-base", "@arcticicestudio/eslint-config-base/prettier"],
extends: [
"@svengreb/eslint-config-base",
/*
* Enable support for projects using Prettier.
* Note that this must always be placed after the `@svengreb/eslint-config-base` preset to take precedence, otherwise it won't prevent errors
* due to useless and possibly conflicting rules!
*/
"@svengreb/eslint-config-base/prettier",
],
overrides: [
{
files: ["*.js"],
Expand Down
7 changes: 6 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/bin/sh

# Copyright (c) 2016-present Sven Greb <[email protected]>
# This source code is licensed under the MIT license found in the license file.
# This source code is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license found in the license file.

# Git "pre-commit" hook for husky.
# References:
# 1. https://github.com/typicode/husky
# 2. https://git-scm.com/docs/githooks#_pre_commit

. "$(dirname "$0")/_/husky.sh"

Expand Down
7 changes: 7 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
# Configurations for npm.
# See https://docs.npmjs.com/cli/v7/configuring-npm/npmrc for more details.

# Disable the vulnerability auditing and checks which includes often way too many false-positives, insignificant
# problems that are only for local development, and many other warnings that are overhelming.
# Use dedicated vulnerability tools instead to filter and identify issue that really impact the project.
# References:
# 1. https://docs.npmjs.com/cli/v9/commands/npm-audit
audit=false

# Only use a lockfile for single-consumer projects, like applications, but not for multi-consumer projects like
# libraries.
# It helps to pin dependency versions, improves the security through integrity checksums, prevents possible errors
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
**/*.png
.husky/_/
node_modules/
go.*
1 change: 1 addition & 0 deletions .remarkignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
# See https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/ignore.md for more details.

node_modules/
license
4 changes: 2 additions & 2 deletions .remarkrc.js → .remarkrc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
* @see https://github.com/remarkjs/remark-lint
* @see https://remark.js.org
*/
module.exports = {
plugins: ["@arcticicestudio/remark-preset-lint"],
export default {
plugins: ["@svengreb/remark-preset-lint"],
};
105 changes: 105 additions & 0 deletions cmd/srgb-to-hex/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Forked from https://git.dim13.org/itermcolors.git/tree/main.go
// Inspired by https://github.com/F1LT3R/itermcolors-to-hex/blob/master/index.js
package main

import (
"flag"
"fmt"
"io/ioutil"
"math"
"os"
"path/filepath"
"strings"
"text/template"

"howett.net/plist"
)

type Scheme struct {
Name string
Ansi0 Color `plist:"Ansi 0 Color"`
Ansi1 Color `plist:"Ansi 1 Color"`
Ansi2 Color `plist:"Ansi 2 Color"`
Ansi3 Color `plist:"Ansi 3 Color"`
Ansi4 Color `plist:"Ansi 4 Color"`
Ansi5 Color `plist:"Ansi 5 Color"`
Ansi6 Color `plist:"Ansi 6 Color"`
Ansi7 Color `plist:"Ansi 7 Color"`
Ansi8 Color `plist:"Ansi 8 Color"`
Ansi9 Color `plist:"Ansi 9 Color"`
Ansi10 Color `plist:"Ansi 10 Color"`
Ansi11 Color `plist:"Ansi 11 Color"`
Ansi12 Color `plist:"Ansi 12 Color"`
Ansi13 Color `plist:"Ansi 13 Color"`
Ansi14 Color `plist:"Ansi 14 Color"`
Ansi15 Color `plist:"Ansi 15 Color"`
Background Color `plist:"Background Color"`
Badge Color `plist:"Badge Color"`
Bold Color `plist:"Bold Color"`
Cursor Color `plist:"Cursor Color"`
CursorGuide Color `plist:"Cursor Guide Color"`
CursorText Color `plist:"Cursor Text Color"`
Foreground Color `plist:"Foreground Color"`
Link Color `plist:"Link Color"`
SelectedText Color `plist:"Selected Text Color"`
Selection Color `plist:"Selection Color"`
}

type Color struct {
Alpha float64 `plist:"Alpha Component"`
Red float64 `plist:"Red Component"`
Green float64 `plist:"Green Component"`
Blue float64 `plist:"Blue Component"`
Space string `plist:"Color Space"`
}

func (c Color) String() string {
r := int(math.MaxUint8 * c.Red)
g := int(math.MaxUint8 * c.Green)
b := int(math.MaxUint8 * c.Blue)
return fmt.Sprintf("#%02x%02x%02x", r, g, b)
}

func name(s string) string {
return strings.TrimSuffix(filepath.Base(s), filepath.Ext(s))
}

func exitErr(code int, err error) {
fmt.Println(err)
os.Exit(code)
}

func main() {
file := flag.String("file", "", "Color scheme .itemcolors")
tmpl := flag.String("tmpl", "scheme.tmpl", "Xresources template")
out := flag.String("out", "-", "output")
flag.Parse()

body, err := ioutil.ReadFile(*file)
if err != nil {
exitErr(1, err)
}

var s Scheme
if _, err := plist.Unmarshal(body, &s); err != nil {
exitErr(1, err)
}
s.Name = name(*file)
fd := os.Stdout

if *out != "-" {
fd, err = os.Create(*out)
if err != nil {
exitErr(1, err)
}
}

t, err := template.ParseFiles(*tmpl)
if err != nil {
exitErr(1, err)
}

if err := t.Execute(fd, s); err != nil {
exitErr(1, err)
}
}
32 changes: 32 additions & 0 deletions cmd/srgb-to-hex/templates/xresources.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
! Color scheme {{.Name}}
*VT100*foreground: {{.Foreground}}
*VT100*background: {{.Background}}
*VT100*cursorColor: {{.Cursor}}
! Black
*VT100*color0: {{.Ansi0}}
*VT100*color8: {{.Ansi8}}
! Red
*VT100*color1: {{.Ansi1}}
*VT100*color9: {{.Ansi9}}
! Green
*VT100*color2: {{.Ansi2}}
*VT100*color10: {{.Ansi10}}
! Yellow
*VT100*color3: {{.Ansi3}}
*VT100*color11: {{.Ansi11}}
! Blue
*VT100*color4: {{.Ansi4}}
*VT100*color12: {{.Ansi12}}
! Magenta
*VT100*color5: {{.Ansi5}}
*VT100*color13: {{.Ansi13}}
! Cyan
*VT100*color6: {{.Ansi6}}
*VT100*color14: {{.Ansi14}}
! White
*VT100*color7: {{.Ansi7}}
*VT100*color15: {{.Ansi15}}
! Bold
*VT100*colorBD: {{.Bold}}
!*colorIT:
!*colorUL:
53 changes: 53 additions & 0 deletions cmd/srgb-to-hex/templates/yml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "{{.Name}}"
terminal:
# nord4
foreground: "{{.Foreground}}"
# nord0
background: "{{.Background}}"
# nord4
cursorColor: "{{.Cursor}}"
colors:
black:
# nord0
color0: "{{.Ansi0}}"
# nord3
color8: "{{.Ansi8}}"
red:
# nord11
color1: "{{.Ansi1}}"
# nord11
color9: "{{.Ansi9}}"
green:
# nord14
color2: "{{.Ansi2}}"
# nord14
color10: "{{.Ansi10}}"
yellow:
# nord13
color3: "{{.Ansi3}}"
# nord13
color11: "{{.Ansi11}}"
blue:
# nord9
color4: "{{.Ansi4}}"
# nord9
color12: "{{.Ansi12}}"
magenta:
# nord15
color5: "{{.Ansi5}}"
# nord15
color13: "{{.Ansi13}}"
cyan:
# nord8
color6: "{{.Ansi6}}"
# nord7
color14: "{{.Ansi14}}"
white:
# nord5
color7: "{{.Ansi7}}"
# nord6
color15: "{{.Ansi15}}"
font:
bold: "{{.Bold}}"
italic:
underline:
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/nordtheme/iterm2

go 1.15

require howett.net/plist v0.0.0-20201026045517-117a925f2150
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
howett.net/plist v0.0.0-20201026045517-117a925f2150 h1:s7O/9fwMNd6O1yXyQ8zv+U7dfl8k+zdiLWAY8h7XdVI=
howett.net/plist v0.0.0-20201026045517-117a925f2150/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
2 changes: 1 addition & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
module.exports = {
"*.{itermcolors,json,svg}": "prettier --check --ignore-unknown --no-editorconfig",
"*.js": ["eslint", "prettier --check --ignore-unknown --no-editorconfig"],
"*.{js,mjs}": ["eslint", "prettier --check --ignore-unknown --no-editorconfig"],
"*.md": ["remark --no-stdout", "prettier --check --ignore-unknown --no-editorconfig"],
".husky/pre-*": "prettier --check --ignore-unknown --no-editorconfig",
};
Loading