Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recover non-lemnos themes #902

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
108 changes: 71 additions & 37 deletions themes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,114 @@

Credit to @lemnos and [all contributors](https://github.com/lemnos/theme.sh/blob/master/CREDITS.md).

## Use a colorscheme
### Without Nupm
Note:

To list all the themes, from the root of the repository run:
* If using Nupm, or the `<package_root>/themes` directory of this package/repository is in your `$env.NU_LIB_DIRS`, then most of the commands below can be run from anywhere on your system.
* Otherwise, all examples assume they are run from the `<package_root>/themes` directory.

```rust
ls ./themes/nu-themes
## Basic usage
### Activate a colorscheme

```nu
source nu-themes/<theme>.nu
```

To use the `dracula` theme for instance, please run:
For example, to use the `dracula` theme:

```rust
source ./themes/nu-themes/dracula.nu
```nu
source nu-themes/dracula.nu
```

The theme should be activated!

### Using Nupm
Note that these settings are for the current shell only.

1. Install [Nupm] by following the [Nupm instructions]
2. Download the `nu_scripts` repository
### Making changes permanent

```shell
git clone https://github.com/nushell/nu_scripts
```
Add the command above to your `config.nu` file as shown in [the Configuration chapter of The Book](https://www.nushell.sh/book/configuration.html).

3. Activate the `nupm` module with `use nupm`
4. Install the `nu-scripts` package
Note that, if not using Nupm or a `NU_LIB_DIR` path, you should use the fully qualified path to the themes directory on your system. For example:

```nushell
nupm install --path --force nu_scripts
```
```nu
source ~/nu_scripts/themes/nu-themes/dracula.nu
```

> **Note**
> installing the `nu-scripts` package will install `nu-themes` and other modules
### List all themes

5. Add the following in your config, substituting the `theme_name` as desired:
Currently, this is done by simply manually listing the contents of the `nu-themes` directory:

```nushell
source nu-themes/<theme_name>.nu
```
```nu
ls <package_root>/themes/nu-themes
```

## Advanced

## Loading a theme's color_config
Themes are composed of two parts:

When sourcing the theme, as above, the theme will:
* A Nushell `color_config` record which is used to set `$env.config.color_config`
* A command to update your terminal's foreground, background, and cursor colors. While this assumes that your terminal supports the appropriate OSC codes, the codes need are very basic and should be supported by most any terminal.

* Set Nushell's `$env.config.color_config` to the appropriate theme colors
* If supported, set your terminal's foreground, background, and cursor colors to match the theme
You may wish to set the Nushell `color_config` without changing your terminal's colors, or vice-versa. These themes provide additional commands that allow you to accomplish this.

If you would like to do *just* one or the other, you can load a theme's color definition and terminal settings separately.
**Important:** Notice that while the "Basic usage" above uses `source` to activate the theme, the following examples *import* the theme module with a `use` statement.

### Load a color_config

For example, to load and use the `tokyo-night` theme's colors:
For example, to load and use the `tokyo-night` theme's colors without changing the terminal settings:

```nushell
> use nu-themes/tokyo-night.nu *
# Display the values
#### Display a theme's `color_config` settings

```nu
> use nu-themes/tokyo-night.nu
> tokyo-night
# Set the color_config to that scheme
```

#### Activate a Nushell `color_config`

```nu
> use nu-themes/tokyo-night.nu
> tokyo-night set color_config
# Or
```

or

```nu
> use nu-themes/tokyo-night.nu
> $env.config.color_config = (tokyo-night)
```

### Set terminal colors

Or you can change the terminal settings to use the theme's foreground/background/cursor colors without changing the Nushell `color_config`.

Again, using the `tokyo-night` theme as an example:

```nushell
> use nu-themes/tokyo-night.nu *
> use nu-themes/tokyo-night.nu
> tokyo-night update terminal
```

## Using Nupm

The parent `nu_scripts` package can be installed and updated using [Nupm].

1. Install [Nupm] by following the [Nupm instructions]
2. Download the `nu_scripts` repository

```shell
git clone https://github.com/nushell/nu_scripts
```

3. Activate the `nupm` module with `use nupm`
4. Install the `nu-scripts` package

```nushell
nupm install --path --force nu_scripts
```

> **Note**
> installing the `nu-scripts` package will install `nu-themes` and other modules

## Screenshots

Here are [screenshots](./screenshots/README.md) of our themes.
Expand Down
177 changes: 0 additions & 177 deletions themes/make.nu

This file was deleted.

52 changes: 26 additions & 26 deletions themes/nu-themes/3024-day.nu
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
# Update terminal colors
export def "update terminal" [] {
let theme = (main)

# 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
}

# Update the Nushell configuration
export def --env "set color_config" [] {
$env.config.color_config = (main)
}

# Retrieve the theme settings
export def main [] {
return {
Expand Down Expand Up @@ -110,6 +84,32 @@ export def main [] {
}
}

# Update the Nushell configuration
export def --env "set color_config" [] {
$env.config.color_config = (main)
}

# Update terminal colors
export def "update terminal" [] {
let theme = (main)

# 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
}

export module activate {
export-env {
set color_config
Expand Down
Loading
Loading