diff --git a/.chezmoiexternal.toml b/.chezmoiexternal.toml new file mode 100644 index 0000000..824c78d --- /dev/null +++ b/.chezmoiexternal.toml @@ -0,0 +1,6 @@ +[".cache/nu_scripts"] + type = "archive" + url = "https://github.com/nushell/nu_scripts/archive/refs/heads/main.tar.gz" + exact = true + stripComponents = 1 + refreshPeriod = "168h" \ No newline at end of file diff --git a/dot_config/kitty/kitty.conf b/dot_config/kitty/kitty.conf index 7d1c13b..2c04efb 100644 --- a/dot_config/kitty/kitty.conf +++ b/dot_config/kitty/kitty.conf @@ -9,7 +9,7 @@ font_size 16.0 confirm_os_window_close 0 -shell xonsh +shell nu # BEGIN_KITTY_THEME # Catppuccin-Latte diff --git a/private_Library/private_Application Support/nushell/config.nu b/private_Library/private_Application Support/nushell/config.nu new file mode 100644 index 0000000..bda2040 --- /dev/null +++ b/private_Library/private_Application Support/nushell/config.nu @@ -0,0 +1,6 @@ +let-env config = ($env.config | upsert show_banner false) +let-env config = ($env.config | upsert rm.always_trash true) +let-env config = ($env.config | upsert edit_mode vi) +let-env config = ($env.config | upsert history.max_size 100000) +let-env config = ($env.config | upsert footer_mode auto) +let-env config = ($env.config | upsert history.file_format "sqlite") \ No newline at end of file diff --git a/private_Library/private_Application Support/nushell/env.nu b/private_Library/private_Application Support/nushell/env.nu new file mode 100644 index 0000000..5dd6d4d --- /dev/null +++ b/private_Library/private_Application Support/nushell/env.nu @@ -0,0 +1,84 @@ +# Nushell Environment Config File + +### Load standardised prompt "starship" +# TEMP: Custom vi prompt indicators +let-env PROMPT_INDICATOR_VI_INSERT = "" +let-env PROMPT_INDICATOR_VI_NORMAL = "" +source ~/.cache/starship/init.nu + +# Specifies how environment variables are: +# - converted from a string to a value on Nushell startup (from_string) +# - converted from a value back to a string when running external commands (to_string) +# Note: The conversions happen *after* config.nu is loaded +let-env ENV_CONVERSIONS = { + "PATH": { + from_string: { |s| $s | split row (char esep) | path expand --no-symlink } + to_string: { |v| $v | path expand --no-symlink | str join (char esep) } + } +} + +# Directories to search for scripts when calling source or use +# +# By default, /scripts is added +let-env NU_LIB_DIRS = [ ($nu.default-config-dir | path join 'scripts') ] + +# Directories to search for plugin binaries when calling register +# +# By default, /plugins is added +let-env NU_PLUGIN_DIRS = [ ($nu.default-config-dir | path join 'plugins') ] + + +# Add entries to PATH: +# From MacOS helper (/usr/libexec/path_helper) +let-env PATH = ($env.PATH | split row (char esep) | append "/Library/TeX/texbin") +let-env PATH = ($env.PATH | split row (char esep) | append "/Library/Apple/usr/bin") +let-env PATH = ($env.PATH | split row (char esep) | append "/opt/homebrew/bin") +let-env PATH = ($env.PATH | split row (char esep) | append "/opt/homebrew/sbin") +let-env PATH = ($env.PATH | split row (char esep) | append "/usr/local/bin") +# Optional Homebrew packages +let-env PATH = ($env.PATH | split row (char esep) | prepend $"(brew --prefix | str trim)/opt/bison/bin") +let-env PATH = ($env.PATH | split row (char esep) | prepend $"(brew --prefix | str trim)/opt/flex/bin") +let-env PATH = ($env.PATH | split row (char esep) | prepend $"(brew --prefix | str trim)/opt/llvm/bin") +let-env PATH = ($env.PATH | split row (char esep) | prepend $"(brew --prefix | str trim)/opt/openjdk/bin") +# Other package managers +let-env PATH = ($env.PATH | split row (char esep) | prepend $"($env.HOME)/.local/bin") +let-env PATH = ($env.PATH | split row (char esep) | prepend $"($env.HOME)/.cargo/bin") + +# --- user custom --- +# Set default editor +let-env EDITOR = "nvim" +let-env VISUAL = "codium" +# Alias for Monash compute cluster +let-env OPTCLUSTER = "compute.optimisation-2020.cloud.edu.au" +# CMake settings +let-env CMAKE_EXPORT_COMPILE_COMMANDS = "1" # output compile-commands.json for clangd +let-env CMAKE_GENERATOR = "Ninja Multi-Config" # use Ninja generator by default +let-env CMAKE_C_COMPILER_LAUNCHER = "ccache" +let-env CMAKE_CXX_COMPILER_LAUNCHER = "ccache" +# Homebrew shell setup (brew shellenv) +let-env HOMEBREW_PREFIX = "/opt/homebrew" +let-env HOMEBREW_CELLAR = "/opt/homebrew/Cellar" +let-env HOMEBREW_REPOSITORY = "/opt/homebrew" +let-env INFOPATH = "/opt/homebrew/share/info" +# Set MANPATH +let-env MANPATH = "/usr/share/man:/usr/local/share/man:/Library/TeX/Distributions/.DefaultTeX/Contents/Man:/opt/homebrew/share/man" + +### Setup aliases +alias edit = ^($env.VISUAL) +alias start = ^open +alias less = bat +alias set-light-theme = kitty +kitten themes Catppuccin-Latte +alias set-dark-theme = kitty +kitten themes Catppuccin-Macchiato +alias brew-backup = brew bundle dump --global --no-lock --cask --mas --tap --force +alias brew-cleanup = brew bundle cleanup --global --no-lock --force --zap +alias brew-restore = brew bundle install --global --no-lock + +# Load autojump plugin "zoxide" +source ~/.cache/zoxide/zoxide.nu + +# Load completions +source ~/.cache/nu_scripts/custom-completions/cargo/cargo-completions.nu +source ~/.cache/nu_scripts/custom-completions/git/git-completions.nu +source ~/.cache/nu_scripts/custom-completions/make/make-completions.nu +source ~/.cache/nu_scripts/custom-completions/npm/npm-completions.nu +source ~/.cache/nu_scripts/custom-completions/typst/typst-completions.nu diff --git a/run_nushell_generation.nu b/run_nushell_generation.nu new file mode 100644 index 0000000..d59f030 --- /dev/null +++ b/run_nushell_generation.nu @@ -0,0 +1,12 @@ +#!/usr/bin/env nu + +# Generate zoxide configuration +if (which zoxide | is-empty) == false { + mkdir ~/.cache/zoxide/ + zoxide init nushell --hook prompt | save --force ~/.cache/zoxide/zoxide.nu +} + +if (which starship | is-empty) == false { + mkdir ~/.cache/starship/ + starship init nu | save --force ~/.cache/starship/init.nu +}