1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-02 23:27:45 +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: "#eeeeee"
leading_trailing_space_bg: { attr: "n" }
header: { fg: "#c9d05c" attr: "b" }
empty: "#b3deef"
bool: {|| if $in { "#73cef4" } else { "light_gray" } }
int: "#eeeeee"
filesize: {|e|
if $e == 0b {
"#eeeeee"
} else if $e < 1mb {
"#73cef4"
} else {{ fg: "#b3deef" }}
}
duration: "#eeeeee"
date: {|| (date now) - $in |
if $in < 1hr {
{ fg: "#f43753" attr: "b" }
} else if $in < 6hr {
"#f43753"
} else if $in < 1day {
"#ffc24b"
} else if $in < 3day {
"#c9d05c"
} else if $in < 1wk {
{ fg: "#c9d05c" attr: "b" }
} else if $in < 6wk {
"#73cef4"
} else if $in < 52wk {
"#b3deef"
} else { "dark_gray" }
}
range: "#eeeeee"
float: "#eeeeee"
string: "#eeeeee"
nothing: "#eeeeee"
binary: "#eeeeee"
cellpath: "#eeeeee"
row_index: { fg: "#c9d05c" attr: "b" }
record: "#eeeeee"
list: "#eeeeee"
block: "#eeeeee"
hints: "dark_gray"
search_result: { fg: "#f43753" bg: "#eeeeee" }
# Update terminal colors
export def "update terminal" [] {
let theme = (main)
shape_and: { fg: "#d3b987" attr: "b" }
shape_binary: { fg: "#d3b987" attr: "b" }
shape_block: { fg: "#b3deef" attr: "b" }
shape_bool: "#73cef4"
shape_custom: "#c9d05c"
shape_datetime: { fg: "#73cef4" attr: "b" }
shape_directory: "#73cef4"
shape_external: "#73cef4"
shape_externalarg: { fg: "#c9d05c" attr: "b" }
shape_filepath: "#73cef4"
shape_flag: { fg: "#b3deef" attr: "b" }
shape_float: { fg: "#d3b987" attr: "b" }
shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: "b" }
shape_globpattern: { fg: "#73cef4" attr: "b" }
shape_int: { fg: "#d3b987" attr: "b" }
shape_internalcall: { fg: "#73cef4" attr: "b" }
shape_list: { fg: "#73cef4" attr: "b" }
shape_literal: "#b3deef"
shape_match_pattern: "#c9d05c"
shape_matching_brackets: { attr: "u" }
shape_nothing: "#73cef4"
shape_operator: "#ffc24b"
shape_or: { fg: "#d3b987" attr: "b" }
shape_pipe: { fg: "#d3b987" attr: "b" }
shape_range: { fg: "#ffc24b" attr: "b" }
shape_record: { fg: "#73cef4" attr: "b" }
shape_redirection: { fg: "#d3b987" attr: "b" }
shape_signature: { fg: "#c9d05c" attr: "b" }
shape_string: "#c9d05c"
shape_string_interpolation: { fg: "#73cef4" attr: "b" }
shape_table: { fg: "#b3deef" attr: "b" }
shape_variable: "#d3b987"
# 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: "#282828"
foreground: "#eeeeee"
cursor: "#eeeeee"
}}
# Update the Nushell configuration
export def --env "set color_config" [] {
$env.config.color_config = (main)
}
# Retrieve the theme settings
export def main [] {
return {
separator: '#eeeeee'
leading_trailing_space_bg: { attr: 'n' }
header: { fg: '#c9d05c' attr: 'b' }
empty: '#b3deef'
bool: {|| if $in { '#73cef4' } else { 'light_gray' } }
int: '#eeeeee'
filesize: {|e|
if $e == 0b {
'#eeeeee'
} else if $e < 1mb {
'#73cef4'
} else {{ fg: '#b3deef' }}
}
duration: '#eeeeee'
date: {|| (date now) - $in |
if $in < 1hr {
{ fg: '#f43753' attr: 'b' }
} else if $in < 6hr {
'#f43753'
} else if $in < 1day {
'#ffc24b'
} else if $in < 3day {
'#c9d05c'
} else if $in < 1wk {
{ fg: '#c9d05c' attr: 'b' }
} else if $in < 6wk {
'#73cef4'
} else if $in < 52wk {
'#b3deef'
} else { 'dark_gray' }
}
range: '#eeeeee'
float: '#eeeeee'
string: '#eeeeee'
nothing: '#eeeeee'
binary: '#eeeeee'
cellpath: '#eeeeee'
row_index: { fg: '#c9d05c' attr: 'b' }
record: '#eeeeee'
list: '#eeeeee'
block: '#eeeeee'
hints: 'dark_gray'
search_result: { fg: '#f43753' bg: '#eeeeee' }
shape_and: { fg: '#d3b987' attr: 'b' }
shape_binary: { fg: '#d3b987' attr: 'b' }
shape_block: { fg: '#b3deef' attr: 'b' }
shape_bool: '#73cef4'
shape_custom: '#c9d05c'
shape_datetime: { fg: '#73cef4' attr: 'b' }
shape_directory: '#73cef4'
shape_external: '#73cef4'
shape_externalarg: { fg: '#c9d05c' attr: 'b' }
shape_filepath: '#73cef4'
shape_flag: { fg: '#b3deef' attr: 'b' }
shape_float: { fg: '#d3b987' attr: 'b' }
shape_garbage: { fg: '#FFFFFF' bg: '#FF0000' attr: 'b' }
shape_globpattern: { fg: '#73cef4' attr: 'b' }
shape_int: { fg: '#d3b987' attr: 'b' }
shape_internalcall: { fg: '#73cef4' attr: 'b' }
shape_list: { fg: '#73cef4' attr: 'b' }
shape_literal: '#b3deef'
shape_match_pattern: '#c9d05c'
shape_matching_brackets: { attr: 'u' }
shape_nothing: '#73cef4'
shape_operator: '#ffc24b'
shape_or: { fg: '#d3b987' attr: 'b' }
shape_pipe: { fg: '#d3b987' attr: 'b' }
shape_range: { fg: '#ffc24b' attr: 'b' }
shape_record: { fg: '#73cef4' attr: 'b' }
shape_redirection: { fg: '#d3b987' attr: 'b' }
shape_signature: { fg: '#c9d05c' attr: 'b' }
shape_string: '#c9d05c'
shape_string_interpolation: { fg: '#73cef4' attr: 'b' }
shape_table: { fg: '#b3deef' attr: 'b' }
shape_variable: '#d3b987'
background: '#282828'
foreground: '#eeeeee'
cursor: '#eeeeee'
}
}
export module activate {
export-env {
set color_config
update terminal
}
}
# Activate the theme when sourced
use activate