I'm wanting to customise NuShell. I want to remove the information on the right, I don't…
- User
I'm wanting to customise NuShell. I want to remove the information on the right, I don't like that, however I do like having an execution time for how long the previous command took to run over there if that's possible. I also want a transient prompt because I don't like too much information on the line I am working on. Finally I want to have the prompt on two separate lines, with the file path above and then the command I am inputting on the second line.
Assistant
Okay, let's break down how to achieve this custom NuShell prompt setup. You'll need to modify your NuShell configuration files, primarily
env.nuand potentiallyconfig.nu.Here's how you can do it:
-
Find your NuShell config directory:
- Open NuShell and run
config path. This will show you the directory where yourconfig.nuandenv.nufiles are located. It's typically something like~/.config/nushell/on Linux/macOS or$env.APPDATA\nushell\on Windows.
- Open NuShell and run
-
Edit
env.nu:- This file is where you define environment variables and functions, including your prompt functions.
- You'll define two functions: one for the main prompt (
PROMPT_COMMAND) and one for the right-hand prompt (PROMPT_COMMAND_RIGHT).
# ~/.config/nushell/env.nu # --- Define your custom main prompt function --- # This function will display the current path on the first line # and the prompt indicator (like > or λ) on the second line. def create_custom_prompt [] { # Get the current working directory, expanded to full path let current_path = (path expand $env.PWD) # Define your desired prompt indicator for the second line let prompt_indicator = "> " # You can change this to "λ ", "$ ", etc. # Combine path, newline, and indicator # The $"" syntax is for interpolation $"\($current_path)\n\(prompt_indicator)" } # --- Define your custom right-hand prompt function --- # This function will display the execution time of the previous command. def create_right_prompt [] { # $env.LAST_COMMAND_DURATION holds the time in milliseconds # Check if it exists (it won't for the very first prompt) if (($env.LAST_COMMAND_DURATION | default -1) >= 0) { # Format the duration nicely. Add a space for separation. # Example: " (123ms)" $" ($($env.LAST_COMMAND_DURATION)ms)" } else { # If no duration is available, return an empty string "" } } # --- Set the environment variables to use your custom functions --- # Note: We set them to closures { ... } that call the functions $env.PROMPT_COMMAND = { create_custom_prompt } $env.PROMPT_COMMAND_RIGHT = { create_right_prompt } # --- (Optional) Set prompt indicators for when commands are running --- # This prevents the prompt from looking weird while waiting for input # after sending a multi-line command or background process. $env.PROMPT_INDICATOR = "> " # Or "λ ", matching your prompt_indicator above $env.PROMPT_MULTILINE_INDICATOR = "| " # Or ">> ", etc. # --- Rest of your env.nu file follows --- # e.g., $env.PATH, aliases, etc. -
Edit
config.nu:-
This file contains global configuration settings.
-
You need to enable the transient prompt behavior here. This setting is part of the
$env.configstructure under thepromptkey. -
Find the section where
$env.configis defined (it's usually alet env.config = { ... }block). -
Ensure the
prompttable inside it includestransient: true. If there isn't aprompttable, add it.
# ~/.config/nushell/config.nu let env.config = { # ... other config settings (aliases, keybindings, history, etc.) ... # --- Prompt Configuration --- prompt: { # Enable transient prompt: Clears the previous prompt line transient: true # You can also configure the prompt indicators here if you prefer, # though setting PROMPT_INDICATOR and PROMPT_MULTILINE_INDICATOR in env.nu # like shown above is also common and works for this case. # indicator: '> ' # multiline_indicator: '| ' # Set the right-hand side transient behavior (optional but good practice) # Controls if the RHS prompt disappears after command execution # Set to false to keep the duration visible until the *next* prompt line appears. # Set to true to make it disappear as soon as output starts. # Keeping it false usually works well with a transient main prompt. transient_right: false } # ... rest of your config settings ... }Make sure you merge this
prompt: { ... }section into your existinglet env.config = { ... }block if you already have one. Don't just paste the whole block if you have other custom settings. -
-
Apply the changes:
- Close and restart NuShell.
- Alternatively, you can use the
sourcecommand to reload your config files in the current session:source $nu.config-path source $nu.env-path
Now, when you use NuShell:
- The previous command line (prompt + command) should disappear after execution, leaving only the output and the new prompt line.
- Your prompt should display the full path on the first line.
- The command input area (
>orλ) should be on the second line below the path. - After a command finishes, its execution time will appear on the right side of the path line (the first line of the new prompt).
Let me know if you have any issues or want to tweak it further!
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.