- Nushell 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| images | ||
| themes | ||
| utils | ||
| .gitignore | ||
| LICENSE | ||
| nuprm-module.nu | ||
| nuprm-version.txt | ||
| nuprm.nu | ||
| README-CN.md | ||
| README.md | ||
| theme-list.nu | ||
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/nuprmto any directory you prefer, as long as the$nuprm_pathconstant correctly points to where you cloned the repository
-
Clone this repository into your
.configdirectory: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 nuprmenabled: false- Disable nuprm
Display full name
use_full_name: true- Display user's full nameuse_full_name: false- Display username
True color support
compatibility.true_color: true- Enable true color supportcompatibility.true_color: false- Disable true color support
Path URL support
compatibility.enable_path_url: true- Enable path URL supportcompatibility.enable_path_url: false- Disable path URL support
Power Line icon space
compatibility.icon_with_space: true- Add space after the Power Line iconcompatibility.icon_with_space: false- Do not add space after the Power Line iconcompatibility.icon_with_spaceis 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
0to disable abbreviation from the end, showing full path - Example:
~/.test/aaa/bbb/ccc/ddd/eee/fff/gggdisplay 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
- 0:
- Set to
-
directory_abbreviation.display_chars: 2- Number of characters to display after abbreviation- For example, set to 3:
/home/username/.test/123456/demo/pathwill display as~/.tes/123/demo/path
- For example, set to 3:
-
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
~/Documentsto📄, set home directory to🏠
If you want to customize the home directory abbreviation display, you must disable
directory_abbreviation.abbreviate_home - You can add custom directory abbreviations, for example set
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 --previewallows 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 errorThe `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 errorVariable 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 errorEncountered 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 errormodule ... not found
then the file pointed to by your nuprm_theme constant doesn't exist