-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnu.nix
93 lines (83 loc) · 3.47 KB
/
nu.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# download all exercises for an exercism track
# track=$TRACK_NAME; curl "https://exercism.org/api/v2/tracks/$track/exercises" | \ ~/exercism/rust
# jq -r '.exercises[].slug' | \
# xargs -I {} -n1 sh -c "exercism download --track=$track --exercise {} || true"
{ pkgs, lib, ... }:
{
# zoxide is sourced AFTER extraConfig, which is problematic since my `t` alias does not work. So I source it myself and disable the default source to not source the same file twice
programs.zoxide.enableNushellIntegration = false;
# Shell completions for all kinds of commands, all commands are at https://github.com/carapace-sh/carapace-bin
programs.carapace.enable = true;
programs.nushell =
let
vivid = lib.getExe pkgs.vivid;
# we could run this command directly in the configuration file however that command would run everytime nushell starts
# This way, we run the command just once when we build the system. In the actual configuration file we then have just the string, withoutn needing to spawn a new child process
colored = builtins.readFile (
pkgs.runCommand "generate LS_COLORS value" { } "${vivid} generate catppuccin-mocha >$out"
);
catppuccin-mocha = builtins.readFile (
builtins.fetchurl {
url = "https://raw.githubusercontent.com/NikitaRevenco/catppuccin-nushell/10a429db05e74787b12766652dc2f5478da43b6f/themes/catppuccin_mocha.nu";
sha256 = "1pww5kpmcvgp8f8gwb8q8gl0q5jcav069njpa78f3bxlscf48ffn";
}
);
ls-command = "^ls --classify --color=always";
dir-changes = builtins.concatStringsSep "\n" (
map (count: ''
def --env ${lib.concatStrings (lib.replicate count "o")} [] {
cd ${builtins.concatStringsSep "/" (lib.replicate count "..")}
${ls-command}
}
'') (lib.range 1 5)
);
in
{
enable = true;
shellAliases = {
"md" = "mkdir";
"rd" = "rmdir";
"n" = "hx";
"no" = "hx .";
"sn" = "sudo -E hx";
"e" = ls-command;
"g" = "git";
"nrs" = "sudo nixos-rebuild switch";
"cat" = "bat --style=plain";
"icat" = "wezterm imgcat";
"copy" = "xclip -selection clipboard";
"icopy" = "xclip -selection clipboard -target image/png";
};
extraConfig = ''
source /home/e/.cache/zoxide/init.nu
# pass all args to zoxide then list contents of the new directory
def --env --wrapped t [ ...args: string ] {
z ...$args
^ls --classify --color=always
}
$env.path = ($env.path | append $"($env.home)/.cache/npm/global/bin")
$env.path = ($env.path | append $"($env.home)/.cargo/bin")
$env.PROMPT_COMMAND_RIGHT = {||
let dir = match (do -i { $env.PWD | path relative-to $nu.home-path }) {
null => $env.PWD
'\' => '~'
$relative_pwd => ([~ $relative_pwd] | path join)
}
let path_segment = $"(ansi blue)($dir)(ansi reset)"
$path_segment | str replace --all (char path_sep) $"(ansi white)(char path_sep) (ansi blue)"
}
$env.PROMPT_COMMAND = ""
$env.config.show_banner = false
# catppuccin compatible colors
$env.LS_COLORS = r#'${colored}'#
${dir-changes}
${catppuccin-mocha}
'';
extraLogin = ''
# auto start i3 when logging in
if (tty) == "dev/tty1" {
startx (which i3 | first | get path)
}
'';
};
}