summaryrefslogtreecommitdiff
path: root/features/user/cli/shells/nushell
diff options
context:
space:
mode:
authortriethyl <triethylammonium@pm.me>2025-09-02 10:48:21 -0400
committertriethyl <triethylammonium@pm.me>2025-09-02 10:48:21 -0400
commit31c316d19cd974bb81a5d6de62142ff24db1c78e (patch)
treecb941422c76cb8953830a8d58c8e14dca1a10319 /features/user/cli/shells/nushell
parent1c21018347aa277caba74e554cb8d1b1e7fc6bed (diff)
reorganized directory structure
Diffstat (limited to 'features/user/cli/shells/nushell')
-rw-r--r--features/user/cli/shells/nushell/completion.nu17
-rw-r--r--features/user/cli/shells/nushell/default.nix109
-rw-r--r--features/user/cli/shells/nushell/direnv-project-template/.envrc1
-rw-r--r--features/user/cli/shells/nushell/direnv-project-template/.gitignore1
-rw-r--r--features/user/cli/shells/nushell/direnv-project-template/flake.nix29
-rw-r--r--features/user/cli/shells/nushell/prompt.nu97
6 files changed, 0 insertions, 254 deletions
diff --git a/features/user/cli/shells/nushell/completion.nu b/features/user/cli/shells/nushell/completion.nu
deleted file mode 100644
index b25d387..0000000
--- a/features/user/cli/shells/nushell/completion.nu
+++ /dev/null
@@ -1,17 +0,0 @@
-# Carapace Autocomplete
-let carapace_completer = {|spans|
- carapace $spans.0 nushell ...$spans | from json
-}
-$env.config = {
- completions: {
- case_sensitive: false
- quick: true
- partial: true
- algorithm: fuzzy
- external: {
- enable: true
- max_results: 100
- completer: $carapace_completer
- }
- }
-}
diff --git a/features/user/cli/shells/nushell/default.nix b/features/user/cli/shells/nushell/default.nix
deleted file mode 100644
index 7561fb1..0000000
--- a/features/user/cli/shells/nushell/default.nix
+++ /dev/null
@@ -1,109 +0,0 @@
-{
- config,
- pkgs,
- lib,
- ...
-}: let
- cfg = config.features.cli.shells.nushell;
-in {
- options.features.cli.shells.nushell.enable = lib.mkEnableOption "nushell";
- config = lib.mkIf cfg.enable {
- home.packages = with pkgs; [
- television
- gitprompt-rs
- ];
- programs.nushell = {
- enable = true;
- plugins = with pkgs.nushellPlugins; [
- gstat
- ];
- shellAliases = {
- "nix-shell" = "nix-shell --command 'SHELL=nu nu'";
- "cd" = "z";
- "ze" = "zellij";
- "lg" = "lazygit";
- "bk" = "cd $env.OLDPWD";
- "fg" = "job unfreeze";
- };
- configFile.text =
- /*
- nu
- */
- ''
- # Source modularized configs.
- source ${./prompt.nu}
- source ${./completion.nu}
-
- # General Config
- $env.config = {
- show_banner: false
- edit_mode: 'emacs'
-
- history: {
- isolation: true # Isolate the history of each nushell session
- file_format: sqlite # Required for isolation
- }
- }
- $env.editor = "hx"
-
- # go should use a hidden directory
- $env.gopath = "${config.home.homeDirectory}/.go"
-
- # Use direnv if present.
- { ||
- if (which direnv | is-empty) {
- return
- }
- direnv export json | from json | default {} | load-env
-
- }
-
- # define a function to initialize a direnv project
- def projinit [path?: string] { # this code sucks but I'm tired of working on it
- mut path = $path
- if ($path == null) {
- $path = "./"
- }
- let path = $path | path expand
- let template_path = "${./direnv-project-template}" | path expand
- let template_files = ls -a $template_path | get name
- $template_files | each {|item| cp $item $path}
- ls -a $path | get name | where {|name| $template_files | str contains ($name | path basename) | any {}} | each {|name| chmod +w $name}
- if (try {git rev-parse --is-inside-work-tree e> /dev/null}) != null {
- direnv allow
- } else {
- # git init
- direnv allow
- }
- # git add $"($path)/."
- # git commit -m "initialized"
- }
-
- # Quickly create a nix shell.
- def qs [...packages] {
- if $packages == [] {
- print "Please use a package name."
- return
- }
- let packages_string = $packages
- | each {|package| return $"nixpkgs#($package) "}
- | str join
- | str trim
- nu -c $"nix shell ($packages_string)"
- }
-
- # Quickly run a nix package.
- def qr --wrapped [package: string ...arguments] {
- nix run $"nixpkgs#($package)" -- ($arguments | str join " ")
- }
- '';
- };
- programs.zoxide.enable = true;
- programs.carapace.enable = true;
- programs.direnv = {
- enable = true;
- nix-direnv.enable = true;
- silent = true;
- };
- };
-}
diff --git a/features/user/cli/shells/nushell/direnv-project-template/.envrc b/features/user/cli/shells/nushell/direnv-project-template/.envrc
deleted file mode 100644
index 3550a30..0000000
--- a/features/user/cli/shells/nushell/direnv-project-template/.envrc
+++ /dev/null
@@ -1 +0,0 @@
-use flake
diff --git a/features/user/cli/shells/nushell/direnv-project-template/.gitignore b/features/user/cli/shells/nushell/direnv-project-template/.gitignore
deleted file mode 100644
index 92b2793..0000000
--- a/features/user/cli/shells/nushell/direnv-project-template/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-.direnv
diff --git a/features/user/cli/shells/nushell/direnv-project-template/flake.nix b/features/user/cli/shells/nushell/direnv-project-template/flake.nix
deleted file mode 100644
index 4bab14a..0000000
--- a/features/user/cli/shells/nushell/direnv-project-template/flake.nix
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- description = "Project flake";
-
- inputs = {
- nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
- systems.url = "github:nix-systems/default";
- flake-utils = {
- url = "github:numtide/flake-utils";
- inputs.systems.follows = "systems";
- };
- };
-
- outputs = {
- nixpkgs,
- flake-utils,
- ...
- }:
- flake-utils.lib.eachDefaultSystem (
- system: let
- pkgs = nixpkgs.legacyPackages.${system};
- in {
- devShells.default = pkgs.mkShell {
- packages = with pkgs; [
- hello
- ];
- };
- }
- );
-}
diff --git a/features/user/cli/shells/nushell/prompt.nu b/features/user/cli/shells/nushell/prompt.nu
deleted file mode 100644
index cfdd478..0000000
--- a/features/user/cli/shells/nushell/prompt.nu
+++ /dev/null
@@ -1,97 +0,0 @@
-# +---------------+
-# | Prompt Config |
-# +---------------+
-
-# define segmants
-def path_segment [] {
- let current_dir = pwd
- let truncated_current_dir = $current_dir
- return (pwd | str replace $env.home '~')
-}
-def git_segment [] {
- return (gitprompt-rs)
-}
-let do_newline = false # whether to do the newline thing
-$env.PROMPT_COMMAND = {||
- # add a newline at the beginning if it isn't the first prompt
- mut newline = ""
- if ($env.CMD_DURATION_MS != '0823') and $do_newline {
- $newline = "\n"
- }
- # define the prompt
- return $"($newline)(ansi white) ╭ (ansi green_bold)(path_segment)(ansi reset) (git_segment)\n "
-}
-
-# remove right prompt section
-$env.PROMPT_COMMAND_RIGHT = { "" }
-
-# set default prompt indicator
-$env.PROMPT_INDICATOR = $'(ansi white)╰ (ansi red_bold)> '
-# $env.TRANSIENT_PROMPT_INDICATOR = $' (ansi red_bold)> '
-$env.PROMPT_MULTILINE_INDICATOR = " : "
-
-# change prompt to a lambda if in a nix shell
-let in_nix_shell = $env.path | str contains "/nix/store" | any {|el| $el}
-if $in_nix_shell {
- $env.PROMPT_INDICATOR = $'(ansi white)╰ (ansi red_bold)λ '
-}
-
-# replace vi insert and normal mode prompt indicators with cursor changes
-$env.PROMPT_INDICATOR_VI_NORMAL = $env.PROMPT_INDICATOR
-$env.PROMPT_INDICATOR_VI_INSERT = $env.PROMPT_INDICATOR
-$env.config.cursor_shape.vi_insert = "line"
-$env.config.cursor_shape.vi_normal = "block"
-
-$env.config.cursor_shape.emacs = "line"
-
-# customize menus to match
-$env.config.menus = [
- {
- name: help_menu
- only_buffer_difference: true # Search is done on the text written after activating the menu
- marker: $env.PROMPT_INDICATOR # Indicator that appears with the menu is active
- type: {
- layout: description # Type of menu
- columns: 4 # Number of columns where the options are displayed
- col_width: 20 # Optional value. If missing all the screen width is used to calculate column width
- col_padding: 2 # Padding between columns
- selection_rows: 4 # Number of rows allowed to display found options
- description_rows: 10 # Number of rows allowed to display command description
- }
- style: {
- text: green # Text style
- selected_text: green_reverse # Text style for selected option
- description_text: yellow # Text style for description
- }
- }
- {
- name: completion_menu
- only_buffer_difference: false # Search is done on the text written after activating the menu
- marker: $env.PROMPT_INDICATOR # Indicator that appears with the menu is active
- type: {
- layout: columnar # Type of menu
- columns: 4 # Number of columns where the options are displayed
- col_width: 20 # Optional value. If missing all the screen width is used to calculate column width
- col_padding: 2 # Padding between columns
- }
- style: {
- text: green # Text style
- selected_text: green_reverse # Text style for selected option
- description_text: yellow # Text style for description
- }
- }
- {
- name: history_menu
- only_buffer_difference: true # Search is done on the text written after activating the menu
- marker: $env.PROMPT_INDICATOR # Indicator that appears with the menu is active
- type: {
- layout: list # Type of menu
- page_size: 10 # Number of entries that will presented when activating the menu
- }
- style: {
- text: green # Text style
- selected_text: green_reverse # Text style for selected option
- description_text: yellow # Text style for description
- }
- }
-]