nushell/darkmatter.nu 4.2 K raw
1
# Retrieve the theme settings
2
export def main [] {
3
    return {
4
        binary: '#999999'
5
        block: '#888888'
6
        cell-path: '#c1c1c1'
7
        closure: '#aaaaaa'
8
        custom: '#c1c1c1'
9
        duration: '#e78a53'
10
        float: '#5f8787'
11
        glob: '#c1c1c1'
12
        int: '#999999'
13
        list: '#aaaaaa'
14
        nothing: '#5f8787'
15
        range: '#e78a53'
16
        record: '#aaaaaa'
17
        string: '#fbcb97'
18
19
        bool: {|| if $in { '#aaaaaa' } else { '#e78a53' } }
20
21
        date: {|| (date now) - $in |
22
            if $in < 1hr {
23
                { fg: '#5f8787' attr: 'b' }
24
            } else if $in < 6hr {
25
                '#5f8787'
26
            } else if $in < 1day {
27
                '#e78a53'
28
            } else if $in < 3day {
29
                '#fbcb97'
30
            } else if $in < 1wk {
31
                { fg: '#fbcb97' attr: 'b' }
32
            } else if $in < 6wk {
33
                '#aaaaaa'
34
            } else if $in < 52wk {
35
                '#888888'
36
            } else { 'dark_gray' }
37
        }
38
39
        filesize: {|e|
40
            if $e == 0b {
41
                '#c1c1c1'
42
            } else if $e < 1mb {
43
                '#aaaaaa'
44
            } else {{ fg: '#888888' }}
45
        }
46
47
        shape_and: { fg: '#999999' attr: 'b' }
48
        shape_binary: { fg: '#999999' attr: 'b' }
49
        shape_block: { fg: '#888888' attr: 'b' }
50
        shape_bool: '#aaaaaa'
51
        shape_closure: { fg: '#aaaaaa' attr: 'b' }
52
        shape_custom: '#fbcb97'
53
        shape_datetime: { fg: '#aaaaaa' attr: 'b' }
54
        shape_directory: '#aaaaaa'
55
        shape_external: '#aaaaaa'
56
        shape_external_resolved: '#aaaaaa'
57
        shape_externalarg: { fg: '#fbcb97' attr: 'b' }
58
        shape_filepath: '#aaaaaa'
59
        shape_flag: { fg: '#888888' attr: 'b' }
60
        shape_float: { fg: '#5f8787' attr: 'b' }
61
        shape_garbage: { fg: '#FFFFFF' bg: '#FF0000' attr: 'b' }
62
        shape_glob_interpolation: { fg: '#aaaaaa' attr: 'b' }
63
        shape_globpattern: { fg: '#aaaaaa' attr: 'b' }
64
        shape_int: { fg: '#999999' attr: 'b' }
65
        shape_internalcall: { fg: '#aaaaaa' attr: 'b' }
66
        shape_keyword: { fg: '#999999' attr: 'b' }
67
        shape_list: { fg: '#aaaaaa' attr: 'b' }
68
        shape_literal: '#888888'
69
        shape_match_pattern: '#fbcb97'
70
        shape_matching_brackets: { attr: 'u' }
71
        shape_nothing: '#5f8787'
72
        shape_operator: '#e78a53'
73
        shape_or: { fg: '#999999' attr: 'b' }
74
        shape_pipe: { fg: '#999999' attr: 'b' }
75
        shape_range: { fg: '#e78a53' attr: 'b' }
76
        shape_raw_string: { fg: '#c1c1c1' attr: 'b' }
77
        shape_record: { fg: '#aaaaaa' attr: 'b' }
78
        shape_redirection: { fg: '#999999' attr: 'b' }
79
        shape_signature: { fg: '#fbcb97' attr: 'b' }
80
        shape_string: '#fbcb97'
81
        shape_string_interpolation: { fg: '#aaaaaa' attr: 'b' }
82
        shape_table: { fg: '#888888' attr: 'b' }
83
        shape_vardecl: { fg: '#888888' attr: 'u' }
84
        shape_variable: '#999999'
85
86
        foreground: '#c1c1c1'
87
        background: '#121113'
88
        cursor: '#c1c1c1'
89
90
        empty: '#888888'
91
        header: { fg: '#fbcb97' attr: 'b' }
92
        hints: '#333333'
93
        leading_trailing_space_bg: { attr: 'n' }
94
        row_index: { fg: '#fbcb97' attr: 'b' }
95
        search_result: { fg: '#5f8787' bg: '#c1c1c1' }
96
        separator: '#c1c1c1'
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