···11+alias l = ls
22+alias ll = ls -l
33+alias la = ls -a
44+55+alias cat = bat
66+alias c = bat
77+88+alias g = git
99+alias gs = git status
1010+alias ga = git add
1111+1212+alias n = nix
1313+alias nfu = nix flake update
1414+alias nfs = nix flake show
1515+alias nb = nix build
1616+alias nd = nix develop
1717+alias ns = nix shell
1818+1919+def mem [] { sys mem }
2020+def df [] { sys disks }
+82
modules/nushell/default.nix
···11+{ lib, pkgs, ... }:
22+{
33+ environment.shells = [pkgs.nushell];
44+ users.users.root.shell = pkgs.nushell;
55+66+ home-manager.users.root = {
77+ programs.nushell = {
88+ enable = true;
99+ package = pkgs.nushell;
1010+ shellAliases = {
1111+ myip = lib.mkForce "echo";
1212+ };
1313+ extraEnv = ''
1414+ source-env ${./prompt.nu}
1515+ '';
1616+ extraConfig = ''
1717+ let carapace_completer = {|spans: list<string>|
1818+ carapace $spans.0 nushell ...$spans
1919+ | from json
2020+ | if ($in | default [] | where value == $"($spans | last)ERR" | is-empty) { $in } else { null }
2121+ }
2222+ $env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense'
2323+2424+ let fish_completer = {|spans|
2525+ ${lib.getExe pkgs.fish} --command $'complete "--do-complete=($spans | str join " ")"'
2626+ | $"value(char tab)description(char newline)" + $in
2727+ | from tsv --flexible --no-infer
2828+ }
2929+3030+ let zoxide_completer = {|spans|
3131+ $spans | skip 1 | zoxide query -l ...$in | lines | where {|x| $x != $env.PWD}
3232+ }
3333+3434+ let multiple_completers = {|spans|
3535+ ## alias fixer start https://www.nushell.sh/cookbook/external_completers.html#alias-completions
3636+ let expanded_alias = scope aliases
3737+ | where name == $spans.0
3838+ | get -i 0.expansion
3939+4040+ let spans = if $expanded_alias != null {
4141+ $spans
4242+ | skip 1
4343+ | prepend ($expanded_alias | split row ' ' | take 1)
4444+ } else {
4545+ $spans
4646+ }
4747+ ## alias fixer end
4848+4949+ match $spans.0 {
5050+ __zoxide_z | __zoxide_zi => $zoxide_completer
5151+ _ => $carapace_completer
5252+ } | do $in $spans
5353+ }
5454+5555+ $env.config = {
5656+ show_banner: false,
5757+ completions: {
5858+ case_sensitive: false # case-sensitive completions
5959+ quick: true # set to false to prevent auto-selecting completions
6060+ partial: true # set to false to prevent partial filling of the prompt
6161+ algorithm: "fuzzy" # prefix or fuzzy
6262+ external: {
6363+ # set to false to prevent nushell looking into $env.PATH to find more suggestions
6464+ enable: true
6565+ # set to lower can improve completion performance at the cost of omitting some options
6666+ max_results: 100
6767+ completer: $multiple_completers
6868+ }
6969+ }
7070+ }
7171+ $env.PATH = ($env.PATH |
7272+ split row (char esep) |
7373+ append /usr/bin/env
7474+ )
7575+7676+ source ${./aliases.nu}
7777+ '';
7878+ };
7979+ programs.carapace.enable = true;
8080+ programs.carapace.enableNushellIntegration = true;
8181+ };
8282+}
+44
modules/nushell/prompt.nu
···11+let host_colors = {
22+ higashi: {start: "0xEC5228", end: "0xEF9651"},
33+ wolumonde: {start: "0x603F26", end: "0x6C4E31"},
44+}
55+let user_colors = {
66+ kirara: {start: "0xFF407D", end: "0xEE99C2"},
77+ root: {start: "0xC5172E", end: "0xBF3131"},
88+}
99+1010+def create_left_prompt [] {
1111+ let hostname = sys host | get hostname
1212+ let username = ^whoami
1313+1414+ let c = $host_colors | get $hostname
1515+ let hostname_fmt = $hostname | ansi gradient --fgstart $c.start --fgend $c.end
1616+ let c = $user_colors | get $username
1717+ let username_fmt = $username | ansi gradient --fgstart $c.start --fgend $c.end
1818+1919+ let dir = match (do -i { $env.PWD | path relative-to $nu.home-path }) {
2020+ null => $env.PWD
2121+ '' => '~'
2222+ $relative_pwd => ([~ $relative_pwd] | path join)
2323+ }
2424+2525+ let separator_color = ansi light_cyan
2626+ let string_color = ansi light_yellow
2727+ $"($separator_color)//($hostname_fmt)($separator_color)/($username_fmt)($separator_color)/($string_color)cwd=\"($dir)\""
2828+}
2929+3030+def create_right_prompt [] {
3131+ ()
3232+}
3333+3434+# Use nushell functions to define your right and left prompt
3535+$env.PROMPT_COMMAND = {|| create_left_prompt }
3636+# FIXME: This default is not implemented in rust code as of 2023-09-08.
3737+$env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt }
3838+3939+# The prompt indicators are environmental variables that represent
4040+# the state of the prompt
4141+$env.PROMPT_INDICATOR = {|| "/ " }
4242+$env.PROMPT_INDICATOR_VI_INSERT = {|| "/: " }
4343+$env.PROMPT_INDICATOR_VI_NORMAL = {|| "/ " }
4444+$env.PROMPT_MULTILINE_INDICATOR = {|| "/::: " }