Nushell: Difference between revisions

From NixOS Wiki
imported>Vieta
First Nushell entry. Please feel free to change
 
m carapace_completer errors out because of API changes. This is the new way from the docs
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[https://www.nushell.sh/ Nushell] is a powerfull [[Command Shell|shell]] written in Rust. Its goal it is to be a user friendly shell with many buildin features where the user has fun to use it.  
[https://www.nushell.sh/ Nushell] is a powerfull [[Command Shell|shell]] written in Rust.  


== Installation ==
== Installation ==
See [[Command Shell]]
See [[Command Shell]]
Example if you want Nushell as your default shell.
example if you want Nushell as your default shell.
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
<code>users.users.myuser= {
users.users.myuser= {
   ...   
   ...   
         shell = pkgs.nushell;
         shell = pkgs.nushell;
Line 14: Line 14:
Nushell can be configured with [[Home Manager]].
Nushell can be configured with [[Home Manager]].


====Example====  
====Examples====  
Configuration with [https://starship.rs/ Startship] font.
Configuration with [https://starship.rs/ Starship] prompt and autosuggestion  support with [https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=carapace carapace]
{{file|~/.config/nixpkgs/home.nix|nix|<nowiki>
{{file|~/.config/nixpkgs/home.nix|nix|<nowiki>
programs = {
programs = {
     nushell = {  
     nushell = { enable = true;
                enable = true;
      # The config.nu can be anywhere you want if you like to edit your Nushell with Nu
  };
      configFile.source = ./.../config.nu;
   starship = {  
      # for editing directly to config.nu
                enable = true;
      extraConfig = ''
      let carapace_completer = {|spans|
          carapace $spans.0 nushell ...$spans | from json
      }
      $env.config = {
        show_banner: false,
        completions: {
        case_sensitive: false # case-sensitive completions
        quick: true    # set to false to prevent auto-selecting completions
        partial: true    # set to false to prevent partial filling of the prompt
        algorithm: "fuzzy"    # prefix or fuzzy
        external: {
        # set to false to prevent nushell looking into $env.PATH to find more suggestions
            enable: true
        # set to lower can improve completion performance at the cost of omitting some options
            max_results: 100
            completer: $carapace_completer # check 'carapace_completer'
          }
        }
      }
      $env.PATH = ($env.PATH |
      split row (char esep) |
      prepend /home/myuser/.apps |
      append /usr/bin/env
      )
      '';
      shellAliases = {
      vi = "hx";
      vim = "hx";
      nano = "hx";
      };
  }; 
  carapace.enable = true;
  carapace.enableNushellIntegration = true;
 
   starship = { enable = true;
       settings = {
       settings = {
      add_newline = true;
        add_newline = true;
      character = {  
        character = {  
         success_symbol = "[➜](bold green)";
         success_symbol = "[➜](bold green)";
         error_symbol = "[➜](bold red)";
         error_symbol = "[➜](bold red)";
Line 36: Line 71:
==See also==
==See also==
* [[Command Shell]]
* [[Command Shell]]
[[Category:Shell]]

Latest revision as of 16:40, 17 April 2024

Nushell is a powerfull shell written in Rust.

Installation

See Command Shell example if you want Nushell as your default shell.

/etc/nixos/configuration.nix
users.users.myuser= {
   ...  
        shell = pkgs.nushell;
};

Configuration

Nushell can be configured with Home Manager.

Examples

Configuration with Starship prompt and autosuggestion support with carapace

~/.config/nixpkgs/home.nix
programs = {
    nushell = { enable = true;
      # The config.nu can be anywhere you want if you like to edit your Nushell with Nu
      configFile.source = ./.../config.nu;
      # for editing directly to config.nu 
      extraConfig = ''
       let carapace_completer = {|spans|
           carapace $spans.0 nushell ...$spans | from json
       }
       $env.config = {
        show_banner: false,
        completions: {
        case_sensitive: false # case-sensitive completions
        quick: true    # set to false to prevent auto-selecting completions
        partial: true    # set to false to prevent partial filling of the prompt
        algorithm: "fuzzy"    # prefix or fuzzy
        external: {
        # set to false to prevent nushell looking into $env.PATH to find more suggestions
            enable: true 
        # set to lower can improve completion performance at the cost of omitting some options
            max_results: 100 
            completer: $carapace_completer # check 'carapace_completer' 
          }
        }
       } 
       $env.PATH = ($env.PATH | 
       split row (char esep) |
       prepend /home/myuser/.apps |
       append /usr/bin/env
       )
       '';
       shellAliases = {
       vi = "hx";
       vim = "hx";
       nano = "hx";
       };
   };  
   carapace.enable = true;
   carapace.enableNushellIntegration = true;

   starship = { enable = true;
       settings = {
         add_newline = true;
         character = { 
         success_symbol = "[➜](bold green)";
         error_symbol = "[➜](bold red)";
       };
    };
  };
};

See also