Skip to content

Commit

Permalink
Fully modularized
Browse files Browse the repository at this point in the history
  • Loading branch information
NotTheDr01ds committed Jul 18, 2024
1 parent b32ab11 commit a4eaffe
Show file tree
Hide file tree
Showing 893 changed files with 48,228 additions and 6,720 deletions.
90 changes: 60 additions & 30 deletions themes/make.nu
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,27 @@ let SOURCE = {
local: ($current_dir | path join "lemnos")
remote: "https://github.com/lemnos/theme.sh"
}
let THEMES = ($current_dir | path join "nu-themes")
let themes_dir = ($current_dir | path join "nu-themes")
let color_defs_dir = ($current_dir | path join $themes_dir | path join "theme-colors")

def make_theme [ name: string ] {
$"
export-env {
use ./theme-colors/($name).nu *
export-env {
use ./($name)_colors.nu
let theme = \(($name)_colors)
$env.config.color_config = $theme
# Set terminal colors
let osc_screen_foreground_color = '10;'
let osc_screen_background_color = '11;'
let osc_cursor_color = '12;'
print $\"
\(ansi -o $osc_screen_foreground_color)\($theme.foreground)\(char bel)
\(ansi -o $osc_screen_background_color)\($theme.background)\(char bel)
\(ansi -o $osc_cursor_color)\($theme.cursor)\(char bel)
\"
}
"
($name)-theme set color_config
($name)-theme update terminal
}
"
| str dedent
| save --force ({
parent: $THEMES
parent: $themes_dir
stem: $"($name)"
extension: "nu"
} | path join)

}
def make_theme_colors [name: string] {
def make_theme_commands [name: string] {
let colors = (
open ($SOURCE.dir | path join $name)
| lines --skip-empty
Expand All @@ -50,9 +39,35 @@ def make_theme_colors [name: string] {
| into record
)

(
$'
export def main [] {
let update_terminal_command = $"
export def \"update terminal\" [] {
let theme = \(get color_config)
# Set terminal colors
let osc_screen_foreground_color = '10;'
let osc_screen_background_color = '11;'
let osc_cursor_color = '12;'
$\"
\(ansi -o $osc_screen_foreground_color)\($theme.foreground)\(char bel)
\(ansi -o $osc_screen_background_color)\($theme.background)\(char bel)
\(ansi -o $osc_cursor_color)\($theme.cursor)\(char bel)
\"
| str replace --all \"\\n\" ''
| print $in
}
"
| str dedent

let set_color_config_command = $"
export def --env \"set color_config\" [] {
$env.config.color_config = \(get color_config)
}
"
| str dedent

let get_color_config_command = $'
export def "get color_config" [] {
return {
separator: "($colors.color7)"
leading_trailing_space_bg: { attr: "n" }
Expand Down Expand Up @@ -137,17 +152,31 @@ def make_theme_colors [name: string] {
}
}
'
)
| str dedent

let fix_indent = {
str replace -ra '(.*)' ' $1'
| str replace -r '(?m)^ ' ''
}

$"
export module \"($name)-theme\" {
($update_terminal_command | do $fix_indent)
($get_color_config_command | do $fix_indent)
($set_color_config_command | do $fix_indent)
}
"
| str dedent
| save --force ({
parent: $THEMES
stem: $"($name)_colors"
parent: $color_defs_dir
stem: $"($name)"
extension: "nu"
} | path join)
}

def main [] {
mkdir $THEMES
mkdir $themes_dir
mkdir $color_defs_dir

try { git clone $SOURCE.remote $SOURCE.local }

Expand All @@ -158,10 +187,11 @@ def main [] {
| each {|theme|
print $"Converting ($theme)"
try {
make_theme_colors $theme
make_theme_commands $theme
make_theme $theme
} catch {
} catch {|e|
print -e $"Error converting ($theme)"
print -e $e.debug
}
}
| ignore
Expand Down
18 changes: 3 additions & 15 deletions themes/nu-themes/3024-day.nu
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@

export-env {
use ./3024-day_colors.nu

let theme = (3024-day_colors)
$env.config.color_config = $theme
use ./theme-colors/3024-day.nu *

# Set terminal colors
let osc_screen_foreground_color = '10;'
let osc_screen_background_color = '11;'
let osc_cursor_color = '12;'

print $"
(ansi -o $osc_screen_foreground_color)($theme.foreground)(char bel)
(ansi -o $osc_screen_background_color)($theme.background)(char bel)
(ansi -o $osc_cursor_color)($theme.cursor)(char bel)
"
3024-day-theme set color_config
3024-day-theme update terminal
}
18 changes: 3 additions & 15 deletions themes/nu-themes/3024-night.nu
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@

export-env {
use ./3024-night_colors.nu

let theme = (3024-night_colors)
$env.config.color_config = $theme
use ./theme-colors/3024-night.nu *

# Set terminal colors
let osc_screen_foreground_color = '10;'
let osc_screen_background_color = '11;'
let osc_cursor_color = '12;'

print $"
(ansi -o $osc_screen_foreground_color)($theme.foreground)(char bel)
(ansi -o $osc_screen_background_color)($theme.background)(char bel)
(ansi -o $osc_cursor_color)($theme.cursor)(char bel)
"
3024-night-theme set color_config
3024-night-theme update terminal
}
18 changes: 3 additions & 15 deletions themes/nu-themes/3024.nu
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@

export-env {
use ./3024_colors.nu

let theme = (3024_colors)
$env.config.color_config = $theme
use ./theme-colors/3024.nu *

# Set terminal colors
let osc_screen_foreground_color = '10;'
let osc_screen_background_color = '11;'
let osc_cursor_color = '12;'

print $"
(ansi -o $osc_screen_foreground_color)($theme.foreground)(char bel)
(ansi -o $osc_screen_background_color)($theme.background)(char bel)
(ansi -o $osc_cursor_color)($theme.cursor)(char bel)
"
3024-theme set color_config
3024-theme update terminal
}
18 changes: 3 additions & 15 deletions themes/nu-themes/abyss.nu
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@

export-env {
use ./abyss_colors.nu

let theme = (abyss_colors)
$env.config.color_config = $theme
use ./theme-colors/abyss.nu *

# Set terminal colors
let osc_screen_foreground_color = '10;'
let osc_screen_background_color = '11;'
let osc_cursor_color = '12;'

print $"
(ansi -o $osc_screen_foreground_color)($theme.foreground)(char bel)
(ansi -o $osc_screen_background_color)($theme.background)(char bel)
(ansi -o $osc_cursor_color)($theme.cursor)(char bel)
"
abyss-theme set color_config
abyss-theme update terminal
}
18 changes: 3 additions & 15 deletions themes/nu-themes/aci.nu
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@

export-env {
use ./aci_colors.nu

let theme = (aci_colors)
$env.config.color_config = $theme
use ./theme-colors/aci.nu *

# Set terminal colors
let osc_screen_foreground_color = '10;'
let osc_screen_background_color = '11;'
let osc_cursor_color = '12;'

print $"
(ansi -o $osc_screen_foreground_color)($theme.foreground)(char bel)
(ansi -o $osc_screen_background_color)($theme.background)(char bel)
(ansi -o $osc_cursor_color)($theme.cursor)(char bel)
"
aci-theme set color_config
aci-theme update terminal
}
18 changes: 3 additions & 15 deletions themes/nu-themes/aco.nu
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@

export-env {
use ./aco_colors.nu

let theme = (aco_colors)
$env.config.color_config = $theme
use ./theme-colors/aco.nu *

# Set terminal colors
let osc_screen_foreground_color = '10;'
let osc_screen_background_color = '11;'
let osc_cursor_color = '12;'

print $"
(ansi -o $osc_screen_foreground_color)($theme.foreground)(char bel)
(ansi -o $osc_screen_background_color)($theme.background)(char bel)
(ansi -o $osc_cursor_color)($theme.cursor)(char bel)
"
aco-theme set color_config
aco-theme update terminal
}
18 changes: 3 additions & 15 deletions themes/nu-themes/adventuretime.nu
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@

export-env {
use ./adventuretime_colors.nu

let theme = (adventuretime_colors)
$env.config.color_config = $theme
use ./theme-colors/adventuretime.nu *

# Set terminal colors
let osc_screen_foreground_color = '10;'
let osc_screen_background_color = '11;'
let osc_cursor_color = '12;'

print $"
(ansi -o $osc_screen_foreground_color)($theme.foreground)(char bel)
(ansi -o $osc_screen_background_color)($theme.background)(char bel)
(ansi -o $osc_cursor_color)($theme.cursor)(char bel)
"
adventuretime-theme set color_config
adventuretime-theme update terminal
}
18 changes: 3 additions & 15 deletions themes/nu-themes/afterglow.nu
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@

export-env {
use ./afterglow_colors.nu

let theme = (afterglow_colors)
$env.config.color_config = $theme
use ./theme-colors/afterglow.nu *

# Set terminal colors
let osc_screen_foreground_color = '10;'
let osc_screen_background_color = '11;'
let osc_cursor_color = '12;'

print $"
(ansi -o $osc_screen_foreground_color)($theme.foreground)(char bel)
(ansi -o $osc_screen_background_color)($theme.background)(char bel)
(ansi -o $osc_cursor_color)($theme.cursor)(char bel)
"
afterglow-theme set color_config
afterglow-theme update terminal
}
18 changes: 3 additions & 15 deletions themes/nu-themes/alien-blood.nu
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@

export-env {
use ./alien-blood_colors.nu

let theme = (alien-blood_colors)
$env.config.color_config = $theme
use ./theme-colors/alien-blood.nu *

# Set terminal colors
let osc_screen_foreground_color = '10;'
let osc_screen_background_color = '11;'
let osc_cursor_color = '12;'

print $"
(ansi -o $osc_screen_foreground_color)($theme.foreground)(char bel)
(ansi -o $osc_screen_background_color)($theme.background)(char bel)
(ansi -o $osc_cursor_color)($theme.cursor)(char bel)
"
alien-blood-theme set color_config
alien-blood-theme update terminal
}
18 changes: 3 additions & 15 deletions themes/nu-themes/alucard.nu
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@

export-env {
use ./alucard_colors.nu

let theme = (alucard_colors)
$env.config.color_config = $theme
use ./theme-colors/alucard.nu *

# Set terminal colors
let osc_screen_foreground_color = '10;'
let osc_screen_background_color = '11;'
let osc_cursor_color = '12;'

print $"
(ansi -o $osc_screen_foreground_color)($theme.foreground)(char bel)
(ansi -o $osc_screen_background_color)($theme.background)(char bel)
(ansi -o $osc_cursor_color)($theme.cursor)(char bel)
"
alucard-theme set color_config
alucard-theme update terminal
}
18 changes: 3 additions & 15 deletions themes/nu-themes/amora.nu
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@

export-env {
use ./amora_colors.nu

let theme = (amora_colors)
$env.config.color_config = $theme
use ./theme-colors/amora.nu *

# Set terminal colors
let osc_screen_foreground_color = '10;'
let osc_screen_background_color = '11;'
let osc_cursor_color = '12;'

print $"
(ansi -o $osc_screen_foreground_color)($theme.foreground)(char bel)
(ansi -o $osc_screen_background_color)($theme.background)(char bel)
(ansi -o $osc_cursor_color)($theme.cursor)(char bel)
"
amora-theme set color_config
amora-theme update terminal
}
Loading

0 comments on commit a4eaffe

Please sign in to comment.