Watch
1
0
Fork
You've already forked nuprm
0
mirror of https://github.com/Sennoma-Nn/nuprm.git synced 2026-08-01 19:07:36 +00:00
Nushell Prompt Manager
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-07-31 23:47:38 +08:00
images refactor: major architecture overhaul with module-based theme system 2026-02-10 04:50:57 +08:00
themes fix violet-line theme get-transient-prompt-indicator space 2026-07-30 19:10:41 +08:00
utils fixed make-power-line-block icon_with_space some bug 2026-07-31 23:47:38 +08:00
.gitignore create .gitignore 2026-02-10 13:29:02 +08:00
LICENSE Update LICENSE year 2026-03-15 21:19:56 +08:00
nuprm-module.nu remove temporary debug comments, update nuprm-version file 2026-07-30 12:17:44 +08:00
nuprm-version.txt remove temporary debug comments, update nuprm-version file 2026-07-30 12:17:44 +08:00
nuprm.nu nuprm to module 2026-07-27 11:19:02 +08:00
README-CN.md update readme 2026-07-30 17:38:40 +08:00
README.md update readme 2026-07-30 17:38:40 +08:00
theme-list.nu add bubble theme, and fixed some bug 2026-07-30 01:37:00 +08:00

icon Nushell Prompt Manager

Introduction

NuPrm is a Nushell theme framework and theme management script that allows you to easily switch between different prompt themes, customize the appearance of your Nushell prompt, and manage prompt configurations through environment variables. It is written using Nushell scripts and integrates with Nushell functionality, while providing common interfaces to make it easier to build prompts

Installation

You can change ~/.config/nuprm to any directory you prefer, as long as the $nuprm_path constant correctly points to where you cloned the repository

  • Clone this repository into your .config directory:

    git clone -b stable https://github.com/Sennoma-Nn/nuprm.git ~/.config/nuprm
    
  • Add the following to your Nushell configuration file (config nu):

    const nuprm_path = "~/.config/nuprm"
    const nuprm_theme = $"($nuprm_path)/themes/simple-minimal.nu"
    use $"($nuprm_path)/nuprm-module.nu" nuprm
    nuprm load
    
  • Restart your Nushell session:

    exec $nu.current-exe
    

Configuration

Add the following to your Nushell environment variables file (config env):

$env.NUPRMCONFIG = {
    enabled: true,
    use_full_name: true,
    directory_abbreviation: {
        enabled: true,
        start_from_end: 3,
        display_chars: 2,
        abbreviate_home: true,
        custom_abbreviate_mappings: {}
    },
    display_elements: {
        system_icon: false,
        hostname: true,
        git: true,
        shells: true,
        startup_time: true,
        execution_time: true,
        exit: true
    },
    compatibility: {
        path_url: true,
        true_color: true,
        with_space: true
    },
    git: {
        dirty: true,
        staged: true
    }
}
(Click here for detailed configuration)

Enable nuprm

  • enabled: true - Enable nuprm
  • enabled: false - Disable nuprm

Display full name

  • use_full_name: true - Display user's full name
  • use_full_name: false - Display username

True color support

  • compatibility.true_color: true - Enable true color support
  • compatibility.true_color: false - Disable true color support

Path URL support

  • compatibility.enable_path_url: true - Enable path URL support
  • compatibility.enable_path_url: false - Disable path URL support

Power Line icon space

  • compatibility.icon_with_space: true - Add space after the Power Line icon
  • compatibility.icon_with_space: false - Do not add space after the Power Line icon

    compatibility.icon_with_space is needed because the display width of Powerline icons isn't always 1 character, even though the actual space the icon occupies is 1 character. Without it, this could cause visual overlapping. If you are using the Mono variant of a Nerd Font, where the display width of each icon is exactly 1, this option is not needed

Directory abbreviation configuration nuprm supports intelligent directory abbreviation to make long paths more readable.

  • directory_abbreviation.enabled: true - Enable directory abbreviation

  • directory_abbreviation.enabled: false - Disable directory abbreviation

  • directory_abbreviation.start_from_end: 3 - Start abbreviation from the Nth directory from the end

    • Set to 0 to disable abbreviation from the end, showing full path
    • Example: ~/.test/aaa/bbb/ccc/ddd/eee/fff/ggg display effects with different settings:
      • 0: ~/.test/aaa/bbb/ccc/ddd/eee/fff/ggg
      • 1: ~/.t/a/b/c/d/e/f/g
      • 2: ~/.t/a/b/c/d/e/f/ggg
      • 3: ~/.t/a/b/c/d/e/fff/ggg
      • 4: ~/.t/a/b/c/d/eee/fff/ggg
      • 5: ~/.t/a/b/c/ddd/eee/fff/ggg
  • directory_abbreviation.display_chars: 2 - Number of characters to display after abbreviation

    • For example, set to 3: /home/username/.test/123456/demo/path will display as ~/.tes/123/demo/path
  • directory_abbreviation.abbreviate_home: true - Enable home directory abbreviation to ~

  • directory_abbreviation.abbreviate_home: false - Disable home directory abbreviation

  • directory_abbreviation.specific_mappings: {} - Custom special directory abbreviations

    • You can add custom directory abbreviations, for example set ~/Documents to 📄, set home directory to 🏠

    If you want to customize the home directory abbreviation display, you must disable directory_abbreviation.abbreviate_home

Display elements configuration

  • display_elements.system_icon: true - Display system icon

  • display_elements.system_icon: false - Do not display system icon

  • display_elements.hostname: true - Display hostname

  • display_elements.hostname: false - Do not display hostname

  • display_elements.git: true - Display Git repository information

  • display_elements.git: false - Do not display Git repository information

  • display_elements.shells: true - Display Shells information

  • display_elements.shells: false - Do not display Shells information

  • display_elements.startup_time: true - Display startup time (on execution time information)

  • display_elements.startup_time: false - Do not display startup time (on execution time information)

  • display_elements.execution_time: true - Display execution time information

  • display_elements.execution_time: false - Do not display execution time information

  • display_elements.exit: true - Display exit code information

  • display_elements.exit: false - Do not display exit code information

  • git.dirty: true - Appends the * indicator after the Git branch name if unstaged changes are detected.

  • git.dirty: false - Does not append the * indicator after the Git branch name, even if unstaged changes are detected.

  • git.staged: true - Appends the + indicator after the branch name if staged changes are detected.

  • git.staged: false - Does not append the + indicator after the branch name, even if staged changes are detected.

Theme Management

You can use the nuprm theme list command to view available themes:

Using nuprm theme list --preview allows you to preview the prompt

 nuprm theme list
# => ╭────┬───────────────────╮
# => │ #  │       name        │
# => ├────┼───────────────────┤
# => │ 0  │ azure.nu          │
# => │ 1  │ bubble.nu         │
# => │ 2  │ circuit.nu        │
# => │ 3  │ galaxy-dream.nu   │
# => │ 4  │ gxy.nu            │
# => │ 5  │ neon-night.nu     │
# => │ 6  │ power-blocks.nu   │
# => │ 7  │ retro-console.nu  │
# => │ 8  │ simple-minimal.nu │
# => │ 9  │ sunset-ocean.nu   │
# => │ 10 │ violet-line.nu    │
# => ╰────┴───────────────────╯

To set a theme, configure the nuprm_theme constant in your environment file:

# Set theme
const nuprm_theme = "~/.config/nuprm/themes/theme-name.nu"

After modifying the configuration, restart your Nushell session or re-enter to apply changes:

exec $nu.current-exe

Script Errors?

(Click here if you encounter script errors)
# => Error: nu::parser::unknown_flag
# => 
# =>   × The get command doesn't have flag -o.
# =>    ╭─[/home/username/.config/nuprm/utils/config-utils.nu:8:39]
# =>  7 │     let user_config = $env.NUPRMCONFIG
# =>  8 │     return ($user_config | get $item -o | default $default)
# =>    ·                                       ┬
# =>    ·                                       ╰── unknown flag
# =>  9 │ }
# =>    ╰────
# =>   help: Available flags: --help(-h), --ignore-errors(-i),
# =>         --sensitive(-s). Use --help for more information.

If you get the error
The `get` command doesn't have flag `-o`.
then your Nushell version is below 0.105.0


# => Error: nu::parser::variable_not_found
# => 
# =>   × Variable not found.
# =>     ╭─[/home/username/.config/nuprm/nuprm.nu:14:17]
# =>  13 │         if $is_enable {
# =>  14 │             use $nuprm_theme nuprm-theme
# =>     ·                 ──────┬─────
# =>     ·                       ╰── variable not found. 
# =>  15 │ 
# =>     ╰────

If you get the error
Variable not found.
then you haven't set the nuprm_theme constant


# => Error: nu::parser::error
# => 
# =>   × Error: nu::shell::not_a_constant
# =>   │ 
# =>   │   × Not a constant.
# =>   │     ╭─[/home/username/.config/nuprm/nuprm.nu:14:17]
# =>   │  13 │         if $is_enable {
# =>   │  14 │             use $nuprm_theme nuprm-theme
# =>   │     ·                 ──────┬─────
# =>   │     ·                       ╰── Value is not a parse-time constant
# =>   │  15 │
# =>   │     ╰────
# =>   │   help: Only a subset of expressions are allowed constants during parsing.
# =>   │ Try
# =>   │         using the 'const' command or typing the value literally.
# =>   │ 
# =>     ╭─[/home/username/.config/nuprm/nuprm.nu:14:17]
# =>  13 │         if $is_enable {
# =>  14 │             use $nuprm_theme nuprm-theme
# =>     ·                 ────────────┬───────────
# =>     ·                             ╰── Encountered error during parse-time evaluation
# =>  15 │ 
# =>     ╰────

If you get the error
Encountered error during parse-time evaluation
then you set the nuprm_theme constant as a variable


# => Error: nu::parser::module_not_found
# => 
# =>   × Module not found.
# =>     ╭─[/home/username/.config/nuprm/nuprm.nu:14:17]
# =>  13 │         if $is_enable {
# =>  14 │             use $nuprm_theme nuprm-theme
# =>     ·                 ──────┬─────
# =>     ·                       ╰── module ~/.config/nuprm/themes/never-gonna-give-you-up.nu not found
# =>  15 │ 
# =>     ╰────
# =>   help: module files and their paths must be available before your script is
# =>         run as parsing occurs before anything is evaluated

If you get the error
module ... not found
then the file pointed to by your nuprm_theme constant doesn't exist