this repo has no description
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(wolumonde): use nushell

dusk 7b8f5393 6384f20d

+147
+1
hosts/wolumonde/modules/nushell.nix
··· 1 + ../../../modules/nushell/default.nix
+20
modules/nushell/aliases.nu
··· 1 + alias l = ls 2 + alias ll = ls -l 3 + alias la = ls -a 4 + 5 + alias cat = bat 6 + alias c = bat 7 + 8 + alias g = git 9 + alias gs = git status 10 + alias ga = git add 11 + 12 + alias n = nix 13 + alias nfu = nix flake update 14 + alias nfs = nix flake show 15 + alias nb = nix build 16 + alias nd = nix develop 17 + alias ns = nix shell 18 + 19 + def mem [] { sys mem } 20 + def df [] { sys disks }
+82
modules/nushell/default.nix
··· 1 + { lib, pkgs, ... }: 2 + { 3 + environment.shells = [pkgs.nushell]; 4 + users.users.root.shell = pkgs.nushell; 5 + 6 + home-manager.users.root = { 7 + programs.nushell = { 8 + enable = true; 9 + package = pkgs.nushell; 10 + shellAliases = { 11 + myip = lib.mkForce "echo"; 12 + }; 13 + extraEnv = '' 14 + source-env ${./prompt.nu} 15 + ''; 16 + extraConfig = '' 17 + let carapace_completer = {|spans: list<string>| 18 + carapace $spans.0 nushell ...$spans 19 + | from json 20 + | if ($in | default [] | where value == $"($spans | last)ERR" | is-empty) { $in } else { null } 21 + } 22 + $env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense' 23 + 24 + let fish_completer = {|spans| 25 + ${lib.getExe pkgs.fish} --command $'complete "--do-complete=($spans | str join " ")"' 26 + | $"value(char tab)description(char newline)" + $in 27 + | from tsv --flexible --no-infer 28 + } 29 + 30 + let zoxide_completer = {|spans| 31 + $spans | skip 1 | zoxide query -l ...$in | lines | where {|x| $x != $env.PWD} 32 + } 33 + 34 + let multiple_completers = {|spans| 35 + ## alias fixer start https://www.nushell.sh/cookbook/external_completers.html#alias-completions 36 + let expanded_alias = scope aliases 37 + | where name == $spans.0 38 + | get -i 0.expansion 39 + 40 + let spans = if $expanded_alias != null { 41 + $spans 42 + | skip 1 43 + | prepend ($expanded_alias | split row ' ' | take 1) 44 + } else { 45 + $spans 46 + } 47 + ## alias fixer end 48 + 49 + match $spans.0 { 50 + __zoxide_z | __zoxide_zi => $zoxide_completer 51 + _ => $carapace_completer 52 + } | do $in $spans 53 + } 54 + 55 + $env.config = { 56 + show_banner: false, 57 + completions: { 58 + case_sensitive: false # case-sensitive completions 59 + quick: true # set to false to prevent auto-selecting completions 60 + partial: true # set to false to prevent partial filling of the prompt 61 + algorithm: "fuzzy" # prefix or fuzzy 62 + external: { 63 + # set to false to prevent nushell looking into $env.PATH to find more suggestions 64 + enable: true 65 + # set to lower can improve completion performance at the cost of omitting some options 66 + max_results: 100 67 + completer: $multiple_completers 68 + } 69 + } 70 + } 71 + $env.PATH = ($env.PATH | 72 + split row (char esep) | 73 + append /usr/bin/env 74 + ) 75 + 76 + source ${./aliases.nu} 77 + ''; 78 + }; 79 + programs.carapace.enable = true; 80 + programs.carapace.enableNushellIntegration = true; 81 + }; 82 + }
+44
modules/nushell/prompt.nu
··· 1 + let host_colors = { 2 + higashi: {start: "0xEC5228", end: "0xEF9651"}, 3 + wolumonde: {start: "0x603F26", end: "0x6C4E31"}, 4 + } 5 + let user_colors = { 6 + kirara: {start: "0xFF407D", end: "0xEE99C2"}, 7 + root: {start: "0xC5172E", end: "0xBF3131"}, 8 + } 9 + 10 + def create_left_prompt [] { 11 + let hostname = sys host | get hostname 12 + let username = ^whoami 13 + 14 + let c = $host_colors | get $hostname 15 + let hostname_fmt = $hostname | ansi gradient --fgstart $c.start --fgend $c.end 16 + let c = $user_colors | get $username 17 + let username_fmt = $username | ansi gradient --fgstart $c.start --fgend $c.end 18 + 19 + let dir = match (do -i { $env.PWD | path relative-to $nu.home-path }) { 20 + null => $env.PWD 21 + '' => '~' 22 + $relative_pwd => ([~ $relative_pwd] | path join) 23 + } 24 + 25 + let separator_color = ansi light_cyan 26 + let string_color = ansi light_yellow 27 + $"($separator_color)//($hostname_fmt)($separator_color)/($username_fmt)($separator_color)/($string_color)cwd=\"($dir)\"" 28 + } 29 + 30 + def create_right_prompt [] { 31 + () 32 + } 33 + 34 + # Use nushell functions to define your right and left prompt 35 + $env.PROMPT_COMMAND = {|| create_left_prompt } 36 + # FIXME: This default is not implemented in rust code as of 2023-09-08. 37 + $env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt } 38 + 39 + # The prompt indicators are environmental variables that represent 40 + # the state of the prompt 41 + $env.PROMPT_INDICATOR = {|| "/ " } 42 + $env.PROMPT_INDICATOR_VI_INSERT = {|| "/: " } 43 + $env.PROMPT_INDICATOR_VI_NORMAL = {|| "/ " } 44 + $env.PROMPT_MULTILINE_INDICATOR = {|| "/::: " }