nushell/poimandres.nu 4.2 K raw
1
# Retrieve the theme settings
2
export def main [] {
3
    return {
4
        binary: '#89DDFF'
5
        block: '#506477'
6
        cell-path: '#E4F0FB'
7
        closure: '#ADD7FF'
8
        custom: '#E4F0FB'
9
        duration: '#FFFAC2'
10
        float: '#5DE4C7'
11
        glob: '#E4F0FB'
12
        int: '#89DDFF'
13
        list: '#ADD7FF'
14
        nothing: '#5DE4C7'
15
        range: '#FFFAC2'
16
        record: '#ADD7FF'
17
        string: '#FCC5E9'
18
19
        bool: {|| if $in { '#ADD7FF' } else { '#FFFAC2' } }
20
21
        date: {|| (date now) - $in |
22
            if $in < 1hr {
23
                { fg: '#5DE4C7' attr: 'b' }
24
            } else if $in < 6hr {
25
                '#5DE4C7'
26
            } else if $in < 1day {
27
                '#FFFAC2'
28
            } else if $in < 3day {
29
                '#FCC5E9'
30
            } else if $in < 1wk {
31
                { fg: '#FCC5E9' attr: 'b' }
32
            } else if $in < 6wk {
33
                '#ADD7FF'
34
            } else if $in < 52wk {
35
                '#506477'
36
            } else { 'dark_gray' }
37
        }
38
39
        filesize: {|e|
40
            if $e == 0b {
41
                '#E4F0FB'
42
            } else if $e < 1mb {
43
                '#ADD7FF'
44
            } else {{ fg: '#506477' }}
45
        }
46
47
        shape_and: { fg: '#89DDFF' attr: 'b' }
48
        shape_binary: { fg: '#89DDFF' attr: 'b' }
49
        shape_block: { fg: '#506477' attr: 'b' }
50
        shape_bool: '#ADD7FF'
51
        shape_closure: { fg: '#ADD7FF' attr: 'b' }
52
        shape_custom: '#FCC5E9'
53
        shape_datetime: { fg: '#ADD7FF' attr: 'b' }
54
        shape_directory: '#ADD7FF'
55
        shape_external: '#ADD7FF'
56
        shape_external_resolved: '#ADD7FF'
57
        shape_externalarg: { fg: '#FCC5E9' attr: 'b' }
58
        shape_filepath: '#ADD7FF'
59
        shape_flag: { fg: '#506477' attr: 'b' }
60
        shape_float: { fg: '#5DE4C7' attr: 'b' }
61
        shape_garbage: { fg: '#FFFFFF' bg: '#D0679D' attr: 'b' }
62
        shape_glob_interpolation: { fg: '#ADD7FF' attr: 'b' }
63
        shape_globpattern: { fg: '#ADD7FF' attr: 'b' }
64
        shape_int: { fg: '#89DDFF' attr: 'b' }
65
        shape_internalcall: { fg: '#ADD7FF' attr: 'b' }
66
        shape_keyword: { fg: '#89DDFF' attr: 'b' }
67
        shape_list: { fg: '#ADD7FF' attr: 'b' }
68
        shape_literal: '#506477'
69
        shape_match_pattern: '#FCC5E9'
70
        shape_matching_brackets: { attr: 'u' }
71
        shape_nothing: '#5DE4C7'
72
        shape_operator: '#FFFAC2'
73
        shape_or: { fg: '#89DDFF' attr: 'b' }
74
        shape_pipe: { fg: '#89DDFF' attr: 'b' }
75
        shape_range: { fg: '#FFFAC2' attr: 'b' }
76
        shape_raw_string: { fg: '#E4F0FB' attr: 'b' }
77
        shape_record: { fg: '#ADD7FF' attr: 'b' }
78
        shape_redirection: { fg: '#89DDFF' attr: 'b' }
79
        shape_signature: { fg: '#FCC5E9' attr: 'b' }
80
        shape_string: '#FCC5E9'
81
        shape_string_interpolation: { fg: '#ADD7FF' attr: 'b' }
82
        shape_table: { fg: '#506477' attr: 'b' }
83
        shape_vardecl: { fg: '#506477' attr: 'u' }
84
        shape_variable: '#89DDFF'
85
86
        foreground: '#E4F0FB'
87
        background: '#1B1E28'
88
        cursor: '#A6ACCD'
89
90
        empty: '#506477'
91
        header: { fg: '#FCC5E9' attr: 'b' }
92
        hints: '#171922'
93
        leading_trailing_space_bg: { attr: 'n' }
94
        row_index: { fg: '#FCC5E9' attr: 'b' }
95
        search_result: { fg: '#5DE4C7' bg: '#E4F0FB' }
96
        separator: '#E4F0FB'
97
    }
98
}
99
100
# Update the Nushell configuration
101
export def --env "set color_config" [] {
102
    $env.config.color_config = (main)
103
}
104
105
# Update terminal colors
106
export def "update terminal" [] {
107
    let theme = (main)
108
109
    # Set terminal colors
110
    let osc_screen_foreground_color = '10;'
111
    let osc_screen_background_color = '11;'
112
    let osc_cursor_color = '12;'
113
        
114
    $"
115
    (ansi -o $osc_screen_foreground_color)($theme.foreground)(char bel)
116
    (ansi -o $osc_screen_background_color)($theme.background)(char bel)
117
    (ansi -o $osc_cursor_color)($theme.cursor)(char bel)
118
    "
119
    # Line breaks above are just for source readability
120
    # but create extra whitespace when activating. Collapse
121
    # to one line and print with no-newline
122
    | str replace --all "\n" ''
123
    | print -n $"($in)\r"
124
}
125
126
export module activate {
127
    export-env {
128
        set color_config
129
        update terminal
130
    }
131
}
132
133
# Activate the theme when sourced
134
use activate