refactor(repo): change a bunch of everything

This commit is contained in:
Artur Manuel 2025-02-17 04:40:13 +00:00
commit 81bee82c34
Signed by: amadaluzia
SSH key fingerprint: SHA256:Zwg7gBuZyaG48ucAZneJwltiXu0+tJb7c3lYt9AYlLg
26 changed files with 352 additions and 127 deletions

View file

@ -0,0 +1,42 @@
From 8c96feb6397d4a5756dbeab1aedb7d2266c9218f Mon Sep 17 00:00:00 2001
From: Artur Manuel <balkenix@outlook.com>
Date: Tue, 11 Feb 2025 23:22:35 +0000
Subject: [PATCH] feat(config): add NUSHELL_CONFIG_DIR env var
---
crates/nu-path/src/helpers.rs | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/crates/nu-path/src/helpers.rs b/crates/nu-path/src/helpers.rs
index 931b3f9d0..cd3c07d95 100644
--- a/crates/nu-path/src/helpers.rs
+++ b/crates/nu-path/src/helpers.rs
@@ -1,4 +1,5 @@
use std::path::PathBuf;
+use std::env;
use crate::AbsolutePathBuf;
@@ -18,10 +19,15 @@ pub fn cache_dir() -> Option<AbsolutePathBuf> {
/// Return the nushell config directory.
pub fn nu_config_dir() -> Option<AbsolutePathBuf> {
- configurable_dir_path("XDG_CONFIG_HOME", dirs::config_dir).map(|mut p| {
- p.push("nushell");
- p
- })
+ let NUSHELL_CONFIG_DIR: Result<String, env::VarError> = env::var("NUSHELL_CONFIG_DIR");
+
+ match NUSHELL_CONFIG_DIR {
+ Ok(val) => Some(AbsolutePathBuf::try_from(val).unwrap()),
+ Err(_) => configurable_dir_path("XDG_CONFIG_HOME", dirs::config_dir).map(|mut p| {
+ p.push("nushell");
+ p
+ })
+ }
}
fn configurable_dir_path(
--
2.47.2

View file

@ -0,0 +1,54 @@
# config.nu
#
# Installed by:
# version = "0.101.0"
#
# This file is used to override default Nushell settings, define
# (or import) custom commands, or run any other startup tasks.
# See https://www.nushell.sh/book/configuration.html
#
# This file is loaded after env.nu and before login.nu
#
# You can open this file in your default editor using:
# config nu
#
# See `help config nu` for more options
#
# You can remove these comments if you want or leave
# them for future reference.
# Alias the built-in ls command to `ls!`, I like to pretend it's like the Nix/Haskell prime.
alias ls! = ls
# List the filenames, sizes, and modification times of items in a directory.
def ls [
--all (-a), # Show hidden files
--long (-l), # Get all available columns for each entry (slower; columns are platform-dependent)
--short-names (-s), # Only print the file names, and not the path
--full-paths (-f), # display paths as absolute paths
--du (-d), # Display the apparent directory size ("disk usage") in place of the directory metadata size
--directory (-D), # List the specified directory itself instead of its contents
--mime-type (-m), # Show mime-type in type column instead of 'file' (based on filenames only; files' contents are not examined)
--threads (-t), # Use multiple threads to list contents. Output will be non-deterministic.
...pattern: glob, # The glob pattern to use.
]: [ nothing -> table ] {
let pattern = if ($pattern | is-empty) { [ '.' ] } else { $pattern }
(ls!
--all=$all
--long=$long
--short-names=$short_names
--full-paths=$full_paths
--du=$du
--directory=$directory
--mime-type=$mime_type
--threads=$threads
...$pattern
) | sort-by type name -i
}
alias nos = nh os
alias e = ^$env.EDITOR
mkdir ($nu.data-dir | path join "vendor/autoload")
starship init nu | save -f ($nu.data-dir | path join "vendor/autoload/starship.nu")
zoxide init nushell --cmd j | save -f ($nu.data-dir | path join "vendor/autoload/zoxide.nu")

View file

@ -0,0 +1,37 @@
# env.nu
#
# Installed by:
# version = "0.101.0"
#
# Previously, environment variables were typically configured in `env.nu`.
# In general, most configuration can and should be performed in `config.nu`
# or one of the autoload directories.
#
# This file is generated for backwards compatibility for now.
# It is loaded before config.nu and login.nu
#
# See https://www.nushell.sh/book/configuration.html
#
# Also see `help config env` for more options.
#
# You can remove these comments if you want or leave
# them for future reference.
$env.config = {
hooks: {
pre_prompt: [{ ||
if (which direnv | is-empty) {
return
}
direnv export json | from json | default {} | load-env
if 'ENV_CONVERSIONS' in $env and 'PATH' in $env.ENV_CONVERSIONS {
$env.PATH = do $env.ENV_CONVERSIONS.PATH.from_string $env.PATH
}
}]
}
table: {
mode: "heavy"
}
show_banner: false
}

View file

@ -0,0 +1,38 @@
{
symlinkJoin,
nushell,
zoxide,
makeWrapper,
system,
inputs,
}:
symlinkJoin {
name = "nu";
paths = [
nushell
inputs.self.packages.${system}.amadaluzian-starship
zoxide
];
nativeBuildInputs = [
makeWrapper
];
passthru = {
inherit (nushell.passthru) shellPath;
};
meta = {
inherit (nushell.meta) mainProgram;
};
postBuild = ''
wrapProgram $out/bin/nu \
--set NUSHELL_CONFIG_DIR "${./cfg}" \
--add-flags "--env-config" \
--add-flags "${./cfg/env.nu}" \
--add-flags "--config" \
--add-flags "${./cfg/config.nu}" \
'';
}