mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-13 12:13:36 +01:00
refactor(shells): let nushell own PATH and aliases (#342)
This commit is contained in:
1 parent
a4206c17a9
commit
c913813ac6
2 files changed
+18
-26
No files matched your search
@@ -193,7 +193,19 @@ const NU_PLUGIN_DIRS = [
|
||||
# a convenience method for prepending to the path:
|
||||
use std/util "path add"
|
||||
path add "~/.local/bin"
|
||||
# Tools installed outside Nix (go install / cargo install / npm -g).
|
||||
path add "~/go/bin"
|
||||
path add "~/.cargo/bin"
|
||||
path add "~/.npm/bin"
|
||||
|
||||
# You can remove duplicate directories from the path using:
|
||||
$env.PATH = ($env.PATH | uniq)
|
||||
|
||||
# ----------------------
|
||||
# Aliases
|
||||
# ----------------------
|
||||
|
||||
# programs.kubecolor.enableAlias only covers bash/zsh, so wire it for nushell too.
|
||||
alias kubectl = kubecolor
|
||||
alias k = kubecolor
|
||||
|
||||
@@ -1,33 +1,13 @@
|
||||
{ config, ... }:
|
||||
let
|
||||
shellAliases = {
|
||||
k = "kubectl";
|
||||
|
||||
urldecode = "python3 -c 'import sys, urllib.parse as ul; print(ul.unquote_plus(sys.stdin.read()))'";
|
||||
urlencode = "python3 -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.stdin.read()))'";
|
||||
};
|
||||
|
||||
localBin = "${config.home.homeDirectory}/.local/bin";
|
||||
goBin = "${config.home.homeDirectory}/go/bin";
|
||||
rustBin = "${config.home.homeDirectory}/.cargo/bin";
|
||||
npmBin = "${config.home.homeDirectory}/.npm/bin";
|
||||
in
|
||||
{ ... }:
|
||||
{
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
bashrcExtra = ''
|
||||
export PATH="$PATH:${localBin}:${goBin}:${rustBin}:${npmBin}"
|
||||
'';
|
||||
};
|
||||
# Kept only for the `~/.profile` it generates: that file sources `hm-session-vars.sh`,
|
||||
# and the terminals launch `bash --login -c 'nu ...'`, so it is how `home.sessionVariables`
|
||||
# reach nushell. Bash itself needs no env/alias setup here — nushell owns those, and a bash
|
||||
# spawned from within nushell inherits the environment.
|
||||
programs.bash.enable = true;
|
||||
|
||||
# NOTE: only works in bash/zsh, not nushell
|
||||
home.shellAliases = shellAliases;
|
||||
|
||||
# NOTE: nushell will be launched in bash, so it can inherit all the eenvironment variables.
|
||||
programs.nushell = {
|
||||
enable = true;
|
||||
configFile.source = ./config.nu;
|
||||
inherit shellAliases;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user