1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-02 07:07:46 +00:00

Simplify theme usage (#896)

* Primary change: Simplifies theme usage by adding an `export-env` to
each theme so that `$env.config.color_config` is automatically set when
importing the module.

  Rather than the old:

  ```nu
  use nu-themes/nushell-dark.nu
  $env.config.color_config = (nushell-dark)
  ```

  It's now a single-step:

  ```nu
  use nu-themes/nushell-dark.nu
  ```

* Updates `make.nu` to create the theme files (uses the previously added
`str dedent` for clean output).
* A couple (literally, 2) of the remote themes did not have all
necessary colors and failed. Updated `make.nu` to continue on error, but
report the failures.
* Updated `README.md`
This commit is contained in:
NotTheDr01ds 2024-07-18 16:39:46 -04:00 committed by GitHub
parent ca309b988e
commit bd1ab4e7a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
458 changed files with 53269 additions and 36274 deletions

View file

@ -1,82 +1,121 @@
export def main [] { return {
separator: "#f8f8f2"
leading_trailing_space_bg: { attr: "n" }
header: { fg: "#a6e22e" attr: "b" }
empty: "#66d9ef"
bool: {|| if $in { "#a1efe4" } else { "light_gray" } }
int: "#f8f8f2"
filesize: {|e|
if $e == 0b {
"#f8f8f2"
} else if $e < 1mb {
"#a1efe4"
} else {{ fg: "#66d9ef" }}
}
duration: "#f8f8f2"
date: {|| (date now) - $in |
if $in < 1hr {
{ fg: "#f92672" attr: "b" }
} else if $in < 6hr {
"#f92672"
} else if $in < 1day {
"#f4bf75"
} else if $in < 3day {
"#a6e22e"
} else if $in < 1wk {
{ fg: "#a6e22e" attr: "b" }
} else if $in < 6wk {
"#a1efe4"
} else if $in < 52wk {
"#66d9ef"
} else { "dark_gray" }
}
range: "#f8f8f2"
float: "#f8f8f2"
string: "#f8f8f2"
nothing: "#f8f8f2"
binary: "#f8f8f2"
cellpath: "#f8f8f2"
row_index: { fg: "#a6e22e" attr: "b" }
record: "#f8f8f2"
list: "#f8f8f2"
block: "#f8f8f2"
hints: "dark_gray"
search_result: { fg: "#f92672" bg: "#f8f8f2" }
# Update terminal colors
export def "update terminal" [] {
let theme = (main)
shape_and: { fg: "#ae81ff" attr: "b" }
shape_binary: { fg: "#ae81ff" attr: "b" }
shape_block: { fg: "#66d9ef" attr: "b" }
shape_bool: "#a1efe4"
shape_custom: "#a6e22e"
shape_datetime: { fg: "#a1efe4" attr: "b" }
shape_directory: "#a1efe4"
shape_external: "#a1efe4"
shape_externalarg: { fg: "#a6e22e" attr: "b" }
shape_filepath: "#a1efe4"
shape_flag: { fg: "#66d9ef" attr: "b" }
shape_float: { fg: "#ae81ff" attr: "b" }
shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: "b" }
shape_globpattern: { fg: "#a1efe4" attr: "b" }
shape_int: { fg: "#ae81ff" attr: "b" }
shape_internalcall: { fg: "#a1efe4" attr: "b" }
shape_list: { fg: "#a1efe4" attr: "b" }
shape_literal: "#66d9ef"
shape_match_pattern: "#a6e22e"
shape_matching_brackets: { attr: "u" }
shape_nothing: "#a1efe4"
shape_operator: "#f4bf75"
shape_or: { fg: "#ae81ff" attr: "b" }
shape_pipe: { fg: "#ae81ff" attr: "b" }
shape_range: { fg: "#f4bf75" attr: "b" }
shape_record: { fg: "#a1efe4" attr: "b" }
shape_redirection: { fg: "#ae81ff" attr: "b" }
shape_signature: { fg: "#a6e22e" attr: "b" }
shape_string: "#a6e22e"
shape_string_interpolation: { fg: "#a1efe4" attr: "b" }
shape_table: { fg: "#66d9ef" attr: "b" }
shape_variable: "#ae81ff"
# 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)
"
# Line breaks above are just for source readability
# but create extra whitespace when activating. Collapse
# to one line
| str replace --all "\n" ''
| print $in
}
background: "#272822"
foreground: "#f8f8f2"
cursor: "#f8f8f2"
}}
# Update the Nushell configuration
export def --env "set color_config" [] {
$env.config.color_config = (main)
}
# Retrieve the theme settings
export def main [] {
return {
separator: '#f8f8f2'
leading_trailing_space_bg: { attr: 'n' }
header: { fg: '#a6e22e' attr: 'b' }
empty: '#66d9ef'
bool: {|| if $in { '#a1efe4' } else { 'light_gray' } }
int: '#f8f8f2'
filesize: {|e|
if $e == 0b {
'#f8f8f2'
} else if $e < 1mb {
'#a1efe4'
} else {{ fg: '#66d9ef' }}
}
duration: '#f8f8f2'
date: {|| (date now) - $in |
if $in < 1hr {
{ fg: '#f92672' attr: 'b' }
} else if $in < 6hr {
'#f92672'
} else if $in < 1day {
'#f4bf75'
} else if $in < 3day {
'#a6e22e'
} else if $in < 1wk {
{ fg: '#a6e22e' attr: 'b' }
} else if $in < 6wk {
'#a1efe4'
} else if $in < 52wk {
'#66d9ef'
} else { 'dark_gray' }
}
range: '#f8f8f2'
float: '#f8f8f2'
string: '#f8f8f2'
nothing: '#f8f8f2'
binary: '#f8f8f2'
cellpath: '#f8f8f2'
row_index: { fg: '#a6e22e' attr: 'b' }
record: '#f8f8f2'
list: '#f8f8f2'
block: '#f8f8f2'
hints: 'dark_gray'
search_result: { fg: '#f92672' bg: '#f8f8f2' }
shape_and: { fg: '#ae81ff' attr: 'b' }
shape_binary: { fg: '#ae81ff' attr: 'b' }
shape_block: { fg: '#66d9ef' attr: 'b' }
shape_bool: '#a1efe4'
shape_custom: '#a6e22e'
shape_datetime: { fg: '#a1efe4' attr: 'b' }
shape_directory: '#a1efe4'
shape_external: '#a1efe4'
shape_externalarg: { fg: '#a6e22e' attr: 'b' }
shape_filepath: '#a1efe4'
shape_flag: { fg: '#66d9ef' attr: 'b' }
shape_float: { fg: '#ae81ff' attr: 'b' }
shape_garbage: { fg: '#FFFFFF' bg: '#FF0000' attr: 'b' }
shape_globpattern: { fg: '#a1efe4' attr: 'b' }
shape_int: { fg: '#ae81ff' attr: 'b' }
shape_internalcall: { fg: '#a1efe4' attr: 'b' }
shape_list: { fg: '#a1efe4' attr: 'b' }
shape_literal: '#66d9ef'
shape_match_pattern: '#a6e22e'
shape_matching_brackets: { attr: 'u' }
shape_nothing: '#a1efe4'
shape_operator: '#f4bf75'
shape_or: { fg: '#ae81ff' attr: 'b' }
shape_pipe: { fg: '#ae81ff' attr: 'b' }
shape_range: { fg: '#f4bf75' attr: 'b' }
shape_record: { fg: '#a1efe4' attr: 'b' }
shape_redirection: { fg: '#ae81ff' attr: 'b' }
shape_signature: { fg: '#a6e22e' attr: 'b' }
shape_string: '#a6e22e'
shape_string_interpolation: { fg: '#a1efe4' attr: 'b' }
shape_table: { fg: '#66d9ef' attr: 'b' }
shape_variable: '#ae81ff'
background: '#272822'
foreground: '#f8f8f2'
cursor: '#f8f8f2'
}
}
export module activate {
export-env {
set color_config
update terminal
}
}
# Activate the theme when sourced
use activate