From d4fc0626f4a36b911188fb24a56e28e579c72c46 Mon Sep 17 00:00:00 2001 From: winston Date: Thu, 16 May 2024 01:26:47 +0200 Subject: [PATCH] feat: nu --- flake.lock | 84 ++++---- home/apps/cli.nix | 115 ++++++++++ home/apps/colorscheme-sync.nix | 54 ++++- home/apps/default.nix | 2 + home/apps/nu.nix | 59 ++++++ home/apps/nu/config.nu | 254 +++++++++++++++++++++++ home/apps/nu/config/keybindings.nu | 323 +++++++++++++++++++++++++++++ home/apps/starship/config.toml | 5 +- home/apps/vscode/settings.json | 12 ++ home/apps/wezterm/config/keys.lua | 8 +- home/apps/wezterm/wezterm.lua | 6 +- home/apps/zsh.nix | 284 ++++++++----------------- 12 files changed, 949 insertions(+), 257 deletions(-) create mode 100644 home/apps/cli.nix create mode 100644 home/apps/nu.nix create mode 100644 home/apps/nu/config.nu create mode 100644 home/apps/nu/config/keybindings.nu diff --git a/flake.lock b/flake.lock index 911ff2d..25f9090 100644 --- a/flake.lock +++ b/flake.lock @@ -17,11 +17,11 @@ ] }, "locked": { - "lastModified": 1714136352, - "narHash": "sha256-BtWQ2Th/jamO1SlD+2ASSW5Jaf7JhA/JLpQHk0Goqpg=", + "lastModified": 1715101957, + "narHash": "sha256-fs5uVQFTfgb4L9pnhldeyTHNcYwn1U4nKYoCBJ6W3W4=", "owner": "ryantm", "repo": "agenix", - "rev": "24a7ea390564ccd5b39b7884f597cfc8d7f6f44e", + "rev": "07479c2e7396acaaaac5925483498154034ea80a", "type": "github" }, "original": { @@ -37,11 +37,11 @@ ] }, "locked": { - "lastModified": 1713405367, - "narHash": "sha256-HZfBEaZM1KxHLJwGSuCwjDA+EWJpMZl0kUpltaM0ZeU=", + "lastModified": 1714962118, + "narHash": "sha256-WPdJ/MgA/lhCvpMX/VY2kuk/u4iIZL4r0UlmU+f7iwg=", "owner": "caarlos0", "repo": "nur", - "rev": "89b16b80f3f3a0944a86605e3a6ac4ecebff45b0", + "rev": "4c58f507b9f0a2167fdf6daa70848b5af8cc58dc", "type": "github" }, "original": { @@ -57,11 +57,11 @@ ] }, "locked": { - "lastModified": 1714216681, - "narHash": "sha256-DAr4pB6ztv3vJtfGEf9EMV81zZ8GVt/GM16VjnqjBiQ=", + "lastModified": 1714861119, + "narHash": "sha256-CBOLznZe7zYDeSo+CG5nqjTYPafs8zceuBBLMNVN6ho=", "owner": "catppuccin", "repo": "toolbox", - "rev": "7303828d5afe39457541ba9ef161d527bfed89c3", + "rev": "1589be5969f8d4b456d8ee6a329938885dc6c6af", "type": "github" }, "original": { @@ -77,11 +77,11 @@ ] }, "locked": { - "lastModified": 1713966850, - "narHash": "sha256-AHAkkTUjk86rED3pQh8i4OiSze+OHe697L0o3zhv89A=", + "lastModified": 1715012932, + "narHash": "sha256-7k52tSu8Y8U3Dlt7og4bdMBtE41looy8uxBxHvpvEWs=", "owner": "catppuccin", "repo": "vscode", - "rev": "75d96f3ae48b249f77124688a026ca5d7eeb5fb2", + "rev": "454290d104a3ea7f2cfceae114e9716b36e9b490", "type": "github" }, "original": { @@ -121,11 +121,11 @@ ] }, "locked": { - "lastModified": 1713680591, - "narHash": "sha256-3pbv7UgAgetwz9YdjzIT/lZ6Rgj6wj6MR4mphBLyDjU=", + "lastModified": 1714890282, + "narHash": "sha256-0dRK2ChvkhWrLM6H3d4r+rXP/UDxTJ6Vkdr22uGb1H0=", "owner": "nix-community", "repo": "fenix", - "rev": "19aaa94a73cc670a4d87e84f0909966cd8f8cd79", + "rev": "24d83329e95a3bc48cbe9f3cd23813c210a25ea6", "type": "github" }, "original": { @@ -141,11 +141,11 @@ ] }, "locked": { - "lastModified": 1712014858, - "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "lastModified": 1714641030, + "narHash": "sha256-yzcRNDoyVP7+SCNX0wmuDju1NUCt8Dz9+lyUXEI0dbI=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "rev": "e5d10a24b66c3ea8f150e47dfdb0416ab7c3390e", "type": "github" }, "original": { @@ -200,11 +200,11 @@ ] }, "locked": { - "lastModified": 1714515075, - "narHash": "sha256-azMK7aWH0eUc3IqU4Fg5rwZdB9WZBvimOGG3piqvtsY=", + "lastModified": 1715077503, + "narHash": "sha256-AfHQshzLQfUqk/efMtdebHaQHqVntCMjhymQzVFLes0=", "owner": "nix-community", "repo": "home-manager", - "rev": "6d3b6dc9222c12b951169becdf4b0592ee9576ef", + "rev": "6e277d9566de9976f47228dd8c580b97488734d4", "type": "github" }, "original": { @@ -219,11 +219,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1714434500, - "narHash": "sha256-SmmC9p8uvxRjnuDMm/8kRW0K2cWgdHozst/u0OOFKSY=", + "lastModified": 1715065392, + "narHash": "sha256-lu3OSBM9yl8VTQqbRjBgqKYgS4QnskRiN0QSQUKUiMo=", "owner": "nekowinston", "repo": "nur", - "rev": "4efb75611200530626aa08fa4302b0c994bfc85f", + "rev": "ce473a9bcf73d7d4d0189243d7f1ac8887ddf83d", "type": "github" }, "original": { @@ -239,11 +239,11 @@ ] }, "locked": { - "lastModified": 1714273701, - "narHash": "sha256-bmoeZ5zMSSO/e8P51yjrzaxA9uzA3SZAEFvih6S3LFo=", + "lastModified": 1714878592, + "narHash": "sha256-E68C03sYRsYFsK7wiGHUIJm8IsyPRALOrFoTL0glXnI=", "owner": "nix-community", "repo": "nix-index-database", - "rev": "941c4973c824509e0356be455d89613611f76c8a", + "rev": "a362555e9dbd4ecff3bb98969bbdb8f79fe87f10", "type": "github" }, "original": { @@ -263,11 +263,11 @@ ] }, "locked": { - "lastModified": 1714526701, - "narHash": "sha256-SO5QvTx6gEbEDqRJVzQGhwftmJICJM+h0cvql9z4kTg=", + "lastModified": 1715044893, + "narHash": "sha256-E5nf7cUIddz7jW20/imPD3ROUjIl5FFHSvGitNB1aWc=", "owner": "nix-community", "repo": "nix-vscode-extensions", - "rev": "24c85bf514f34dc679f0cfd35c66065975cb635e", + "rev": "f3aeab3207826319519f1c7d05c856b3039515aa", "type": "github" }, "original": { @@ -278,11 +278,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1713537308, - "narHash": "sha256-XtTSSIB2DA6tOv+l0FhvfDMiyCmhoRbNB+0SeInZkbk=", + "lastModified": 1714763106, + "narHash": "sha256-DrDHo74uTycfpAF+/qxZAMlP/Cpe04BVioJb6fdI0YY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5c24cf2f0a12ad855f444c30b2421d044120c66f", + "rev": "e9be42459999a253a9f92559b1f5b72e1b44c13d", "type": "github" }, "original": { @@ -294,11 +294,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1714253743, - "narHash": "sha256-mdTQw2XlariysyScCv2tTE45QSU9v/ezLcHJ22f0Nxc=", + "lastModified": 1714906307, + "narHash": "sha256-UlRZtrCnhPFSJlDQE7M0eyhgvuuHBTe1eJ9N9AQlJQ0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "58a1abdbae3217ca6b702f03d3b35125d88a2994", + "rev": "25865a40d14b3f9cf19f19b924e2ab4069b09588", "type": "github" }, "original": { @@ -326,11 +326,11 @@ }, "nur": { "locked": { - "lastModified": 1714596740, - "narHash": "sha256-V3ZR38xu3JSUrg04wMTp0fzDSP+ogNJOOU5ckreCzLQ=", + "lastModified": 1715101703, + "narHash": "sha256-+e4s7BYYiTi3oPaZJ6TYJGr0V0xiPyKijgCb/Ax095s=", "owner": "nix-community", "repo": "nur", - "rev": "c8456769a0904ac761020a76bf0bb72a92c27c7c", + "rev": "4edb956cecd5141f30782ed388a1e2876011f1e4", "type": "github" }, "original": { @@ -476,11 +476,11 @@ ] }, "locked": { - "lastModified": 1714355896, - "narHash": "sha256-rtv+nJJ12V7w68j8vIcGacfS1yuK1/dBgglSKWzYMTM=", + "lastModified": 1715017675, + "narHash": "sha256-4bMsnv8KLzz8HWvYzeIjKqRF7IRCLSjo3EC862+L2Dk=", "owner": "nix-community", "repo": "nixos-wsl", - "rev": "acb893461a4bee4e77b1a27b1410d4995b52174c", + "rev": "1cb8f3c13dee0d40437a9b4b1cf943c06c0cddc4", "type": "github" }, "original": { diff --git a/home/apps/cli.nix b/home/apps/cli.nix new file mode 100644 index 0000000..48748ab --- /dev/null +++ b/home/apps/cli.nix @@ -0,0 +1,115 @@ +{ pkgs, ... }: +let + srcs = pkgs.callPackage ../../_sources/generated.nix { }; +in +{ + home = { + packages = [ pkgs.onefetch ]; + sessionVariables = { + LESS = "-R --use-color"; + LESSHISTFILE = "-"; + MANPAGER = "sh -c 'col -bx | bat -l man -p'"; + }; + }; + + programs = { + atuin = { + enable = true; + flags = [ "--disable-up-arrow" ]; + settings = { + inline_height = 30; + style = "compact"; + sync_address = "https://atuin.winston.sh"; + sync_frequency = "5m"; + }; + }; + bat = { + enable = true; + themes = { + "Catppuccin Latte" = { + src = "${srcs.catppuccin-bat.src}/themes"; + file = "Catppuccin Latte.tmTheme"; + }; + "Catppuccin Frappe" = { + src = "${srcs.catppuccin-bat.src}/themes"; + file = "Catppuccin Frappe.tmTheme"; + }; + "Catppuccin Macchiato" = { + src = "${srcs.catppuccin-bat.src}/themes"; + file = "Catppuccin Macchiato.tmTheme"; + }; + "Catppuccin Mocha" = { + src = "${srcs.catppuccin-bat.src}/themes"; + file = "Catppuccin Mocha.tmTheme"; + }; + }; + }; + btop = { + enable = true; + settings = { + theme_background = false; + vim_keys = true; + }; + }; + + direnv.enable = true; + direnv.nix-direnv.enable = true; + + eza = { + enable = true; + icons = true; + extraOptions = [ + "--group" + "--group-directories-first" + "--no-permissions" + "--octal-permissions" + ]; + }; + + fzf = { + enable = true; + colors = { + fg = "#cdd6f4"; + "fg+" = "#cdd6f4"; + hl = "#f38ba8"; + "hl+" = "#f38ba8"; + header = "#ff69b4"; + info = "#cba6f7"; + marker = "#f5e0dc"; + pointer = "#f5e0dc"; + prompt = "#cba6f7"; + spinner = "#f5e0dc"; + }; + defaultOptions = [ + "--height=30%" + "--layout=reverse" + "--info=inline" + ]; + }; + + less.enable = true; + + nix-index-database.comma.enable = true; + + starship = { + enable = true; + settings = builtins.fromTOML (builtins.readFile ./starship/config.toml); + }; + + tealdeer = { + enable = true; + settings = { + style = { + description.foreground = "white"; + command_name.foreground = "green"; + example_text.foreground = "blue"; + example_code.foreground = "white"; + example_variable.foreground = "yellow"; + }; + updates.auto_update = true; + }; + }; + + zoxide.enable = true; + }; +} diff --git a/home/apps/colorscheme-sync.nix b/home/apps/colorscheme-sync.nix index 3e63430..e3ee821 100644 --- a/home/apps/colorscheme-sync.nix +++ b/home/apps/colorscheme-sync.nix @@ -67,19 +67,51 @@ in }; }; - programs.zsh = { - initExtra = '' - zadm_sync() { - BAT_THEME="Catppuccin $(dark-mode-ternary Mocha Latte)" - LS_COLORS="$(cat $(dark-mode-ternary ${vividMocha} ${vividLatte}))" - STARSHIP_CONFIG__PALETTE="catppuccin_$(dark-mode-ternary mocha latte)" + programs.zsh.initExtra = '' + zadm_sync() { + BAT_THEME="Catppuccin $(dark-mode-ternary Mocha Latte)" + LS_COLORS="$(cat $(dark-mode-ternary ${vividMocha} ${vividLatte}))" + STARSHIP_CONFIG__PALETTE="catppuccin_$(dark-mode-ternary mocha latte)" - export BAT_THEME LS_COLORS STARSHIP_CONFIG__PALETTE + export BAT_THEME LS_COLORS STARSHIP_CONFIG__PALETTE - fast-theme "XDG:catppuccin-$(dark-mode-ternary mocha latte)" >/dev/null + fast-theme "XDG:catppuccin-$(dark-mode-ternary mocha latte)" >/dev/null + } + add-zsh-hook precmd zadm_sync + ''; + programs.nushell.extraConfig = '' + def dark-mode-ternary [dark: string, light: string] { + let system = (uname | get operating-system); + + if ($system == "Darwin") { + if ((defaults read -g AppleInterfaceStyle e> /dev/null =) == "Dark") { + $dark + } else { + $light + } + } else if ($system == "Linux") { + if ((dbus-send --session --print-reply=literal --reply-timeout=5 --dest=org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read string:'org.freedesktop.appearance' string:'color-scheme' e> /dev/null | str contains "uint32 1")) { + $dark + } else { + $light + } + } else { + $light } - add-zsh-hook precmd zadm_sync - ''; - }; + } + + $env.config = ($env.config? | default {}) + $env.config.hooks = ($env.config.hooks? | default {}) + $env.config.hooks.pre_prompt = ( + $env.config.hooks.pre_prompt? + | default [] + | append [ + { $env.config.color_config = (catppuccin (dark-mode-ternary mocha latte)) } + { $env.BAT_THEME = $"Catppuccin (dark-mode-ternary Mocha Latte)" } + { $env.STARSHIP_CONFIG__PALETTE = $"catppuccin_(dark-mode-ternary mocha latte)" } + { $env.LS_COLORS = (cat (dark-mode-ternary ${vividMocha} ${vividLatte})) } + ] + ) + ''; }; } diff --git a/home/apps/default.nix b/home/apps/default.nix index e7b9d50..a646cdf 100644 --- a/home/apps/default.nix +++ b/home/apps/default.nix @@ -1,6 +1,7 @@ { imports = [ ./browsers.nix + ./cli.nix ./colorscheme-sync.nix ./discord.nix ./fonts.nix @@ -15,6 +16,7 @@ ./media.nix ./neovim.nix ./newsboat.nix + ./nu.nix ./rice.nix ./sway.nix ./tmux.nix diff --git a/home/apps/nu.nix b/home/apps/nu.nix new file mode 100644 index 0000000..387efc9 --- /dev/null +++ b/home/apps/nu.nix @@ -0,0 +1,59 @@ +{ lib, pkgs, ... }: +let + plugins = "${pkgs.nu_scripts}/share/nu_scripts"; + + mkCompletions = + completions: + lib.concatStringsSep "\n" ( + builtins.map ( + el: + let + name = el.name or el; + filename = el.filename or el; + in + "source ${plugins}/custom-completions/${name}/${filename}-completions.nu" + ) completions + ); + + completions = [ + "cargo" + "composer" + "gh" + "git" + "just" + "man" + "nix" + "npm" + "pnpm" + "poetry" + "rg" + "tar" + { + name = "tealdeer"; + filename = "tldr"; + } + { + name = "yarn"; + filename = "yarn-v4"; + } + ]; +in +{ + home.packages = [ pkgs.carapace ]; + programs.nushell = { + enable = true; + + configFile.source = ./nu/config.nu; + + extraConfig = + '' + source ${plugins}/aliases/git/git-aliases.nu + '' + + mkCompletions completions; + }; + + xdg.configFile."nushell/config" = { + source = ./nu/config; + recursive = true; + }; +} diff --git a/home/apps/nu/config.nu b/home/apps/nu/config.nu new file mode 100644 index 0000000..14c47e1 --- /dev/null +++ b/home/apps/nu/config.nu @@ -0,0 +1,254 @@ +use ($nu.default-config-dir | path join 'config/keybindings.nu') +use ($nu.default-config-dir | path join 'catppuccin.nu') + +let carapace_completer = {|spans| + carapace $spans.0 nushell ...$spans | from json +} + +$env.PROMPT_INDICATOR = {|| "λ " } +$env.PROMPT_INDICATOR_VI_INSERT = {|| "λ " } +$env.PROMPT_INDICATOR_VI_NORMAL = {|| "$ " } +$env.PROMPT_MULTILINE_INDICATOR = {|| "::: " } + +$env.config = { + show_banner: false + + ls: { + # use the LS_COLORS environment variable to colorize output + use_ls_colors: true + # enable or disable clickable links. Your terminal has to support links. + clickable_links: true + } + + rm: { + # always act as if -t was given. Can be overridden with -p + always_trash: false + } + + table: { + # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other + mode: thin + # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column + index_mode: auto + # show 'empty list' and 'empty record' placeholders for command output + show_empty: true + # a left right padding of each column in a table + padding: { left: 1, right: 1 } + trim: { + # `wrapping` or `truncating` + methodology: truncating + # A strategy used by the 'wrapping' methodology + wrapping_try_keep_words: true + # A suffix used by the 'truncating' methodology + truncating_suffix: "…" + } + # show header text on separator/border line + header_on_separator: false + + # limit data rows from top and bottom after reaching a set point + # abbreviated_row_count: 10 + } + + error_style: "fancy" # "fancy" or "plain" for screen reader-friendly error messages + + # datetime_format determines what a datetime rendered in the shell would look like. + # Behavior without this configuration point will be to "humanize" the datetime display, + # showing something like "a day ago." + datetime_format: { + # shows up in displays of variables or other datetime's outside of tables + # normal: '%a, %d %b %Y %H:%M:%S %z' + + # generally shows up in tabular outputs such as ls. commenting this out will change it to the default human readable datetime format + table: '%Y-%m-%d %I:%M:%S%p' + } + + explore: { + status_bar_background: { fg: "#1D1F21", bg: "#C4C9C6" }, + command_bar_text: { fg: "#C4C9C6" }, + highlight: { fg: "black", bg: "yellow" }, + status: { + error: { fg: "white", bg: "red" }, + warn: {} + info: {} + }, + table: { + split_line: { fg: "#404040" }, + selected_cell: { bg: light_blue }, + selected_row: {}, + selected_column: {}, + }, + } + + history: { + # Session has to be reloaded for this to take effect + max_size: 100_000 + # Enable to share history between multiple sessions, else you have to close the session to write history to file + sync_on_enter: true + # "sqlite" or "plaintext" + file_format: "plaintext" + # only available with sqlite file_format. true enables history isolation, false disables it. true will allow the history to be isolated to the current session using up/down arrows. false will allow the history to be shared across all sessions. + isolation: false + } + + completions: { + # set to true to enable case-sensitive completions + case_sensitive: false + # set this to false to prevent auto-selecting completions when only one remains + quick: true + # set this to false to prevent partial filling of the prompt + partial: true + # prefix or fuzzy + algorithm: "prefix" + external: { + # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up may be very slow + enable: true + # setting it lower can improve completion performance at the cost of omitting some options + max_results: 100 + # check 'carapace_completer' above as an example + completer: $carapace_completer + } + use_ls_colors: true # set this to true to enable file/path/directory completions using LS_COLORS + } + + filesize: { + metric: false # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard) + format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, auto + } + + cursor_shape: { + # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (line is the default) + emacs: inherit + # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (block is the default) + vi_insert: inherit + # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (underscore is the default) + vi_normal: inherit + } + + color_config: (catppuccin "mocha") + use_grid_icons: true + # always, never, number_of_rows, auto + footer_mode: 20 + # the precision for displaying floats in tables + float_precision: 2 + # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.EDITOR and $env.VISUAL + # buffer_editor: "" + use_ansi_coloring: true + # enable bracketed paste, currently useless on windows + bracketed_paste: true + # emacs, vi + edit_mode: vi + # enables terminal shell integration. Off by default, as some terminals have issues with this. + shell_integration: ($env.TERM_PROGRAM == "WezTerm") + # true or false to enable or disable right prompt to be rendered on last line of the prompt. + render_right_prompt_on_last_line: false + # enables keyboard enhancement protocol implemented by kitty console, only if your terminal support this. + use_kitty_protocol: ($env.TERM_PROGRAM == "WezTerm") + # true enables highlighting of external commands in the repl resolved by which. + highlight_resolved_externals: false + # the maximum number of times nushell allows recursion before stopping it + recursion_limit: 50 + + hooks: { + env_change: { + PWD: [ + {if (".git" | path exists) { + onefetch --no-merges --no-bots --no-color-palette --text-colors 1 1 3 4 4 + }} + ] + } + # run to display the output of a pipeline + display_output: "if (term size).columns >= 100 { table -e } else { table }" + # return an error message when a command is not found + command_not_found: { null } + } + + menus: [ + # Configuration for default nushell menus + # Note the lack of source parameter + { + name: completion_menu + only_buffer_difference: false + marker: "| " + type: { + layout: columnar + columns: 4 + # Optional value. If missing all the screen width is used to calculate column width + col_width: 20 + col_padding: 2 + } + style: { + text: green + selected_text: { attr: r } + description_text: yellow + match_text: { attr: u } + selected_match_text: { attr: ur } + } + } + { + name: ide_completion_menu + only_buffer_difference: false + marker: "| " + type: { + layout: ide + min_completion_width: 0, + max_completion_width: 50, + max_completion_height: 10, # will be limited by the available lines in the terminal + padding: 0, + border: true, + cursor_offset: 0, + description_mode: "prefer_right" + min_description_width: 0 + max_description_width: 50 + max_description_height: 10 + description_offset: 1 + # If true, the cursor pos will be corrected, so the suggestions match up with the typed text + # + # C:\> str + # str join + # str trim + # str split + correct_cursor_pos: false + } + style: { + text: green + selected_text: { attr: r } + description_text: yellow + match_text: { attr: u } + selected_match_text: { attr: ur } + } + } + { + name: history_menu + only_buffer_difference: true + marker: "? " + type: { + layout: list + page_size: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + { + name: help_menu + only_buffer_difference: true + marker: "? " + type: { + layout: description + columns: 4 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width + col_padding: 2 + selection_rows: 4 + description_rows: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + ] + keybindings: (keybindings) +} diff --git a/home/apps/nu/config/keybindings.nu b/home/apps/nu/config/keybindings.nu new file mode 100644 index 0000000..e8b6089 --- /dev/null +++ b/home/apps/nu/config/keybindings.nu @@ -0,0 +1,323 @@ +export def main [] { + return [ + { + name: completion_menu + modifier: none + keycode: tab + mode: [vi_normal, vi_insert] + event: { + until: [ + { send: menu name: completion_menu } + { send: menunext } + { edit: complete } + ] + } + } + { + name: ide_completion_menu + modifier: control + keycode: char_n + mode: [vi_normal, vi_insert] + event: { + until: [ + { send: menu name: ide_completion_menu } + { send: menunext } + { edit: complete } + ] + } + } + # replaced by Atuin.sh + # { + # name: history_menu + # modifier: control + # keycode: char_r + # mode: [vi_insert, vi_normal] + # event: { send: menu name: history_menu } + # } + { + name: help_menu + modifier: none + keycode: f1 + mode: [vi_insert, vi_normal] + event: { send: menu name: help_menu } + } + { + name: completion_previous_menu + modifier: shift + keycode: backtab + mode: [vi_normal, vi_insert] + event: { send: menuprevious } + } + { + name: escape + modifier: none + keycode: escape + mode: [vi_normal, vi_insert] + # NOTE: does not appear to work + event: { send: esc } + } + { + name: cancel_command + modifier: control + keycode: char_c + mode: [vi_normal, vi_insert] + event: { send: ctrlc } + } + { + name: quit_shell + modifier: control + keycode: char_d + mode: [vi_normal, vi_insert] + event: { send: ctrld } + } + { + name: clear_screen + modifier: control + keycode: char_l + mode: [vi_normal, vi_insert] + event: { send: clearscreen } + } + { + name: search_history + modifier: control + keycode: char_q + mode: [vi_normal, vi_insert] + event: { send: searchhistory } + } + { + name: open_command_editor + modifier: control + keycode: char_o + mode: [vi_normal, vi_insert] + event: { send: openeditor } + } + { + name: move_up + modifier: none + keycode: up + mode: [vi_normal, vi_insert] + event: { + until: [ + { send: menuup } + { send: up } + ] + } + } + { + name: move_down + modifier: none + keycode: down + mode: [vi_normal, vi_insert] + event: { + until: [ + { send: menudown } + { send: down } + ] + } + } + { + name: move_left + modifier: none + keycode: left + mode: [vi_normal, vi_insert] + event: { + until: [ + { send: menuleft } + { send: left } + ] + } + } + { + name: move_right_or_take_history_hint + modifier: none + keycode: right + mode: [vi_normal, vi_insert] + event: { + until: [ + { send: historyhintcomplete } + { send: menuright } + { send: right } + ] + } + } + { + name: move_one_word_left + modifier: control + keycode: left + mode: [vi_normal, vi_insert] + event: { edit: movewordleft } + } + { + name: move_one_word_right_or_take_history_hint + modifier: control + keycode: right + mode: [vi_normal, vi_insert] + event: { + until: [ + { send: historyhintwordcomplete } + { edit: movewordright } + ] + } + } + { + name: move_to_line_start + modifier: none + keycode: home + mode: [vi_normal, vi_insert] + event: { edit: movetolinestart } + } + { + name: move_to_line_start + modifier: control + keycode: char_a + mode: [vi_normal, vi_insert] + event: { edit: movetolinestart } + } + { + name: move_to_line_end_or_take_history_hint + modifier: none + keycode: end + mode: [vi_normal, vi_insert] + event: { + until: [ + { send: historyhintcomplete } + { edit: movetolineend } + ] + } + } + { + name: move_to_line_end_or_take_history_hint + modifier: control + keycode: char_e + mode: [vi_normal, vi_insert] + event: { + until: [ + { send: historyhintcomplete } + { edit: movetolineend } + ] + } + } + { + name: move_to_line_start + modifier: control + keycode: home + mode: [vi_normal, vi_insert] + event: { edit: movetolinestart } + } + { + name: move_to_line_end + modifier: control + keycode: end + mode: [vi_normal, vi_insert] + event: { edit: movetolineend } + } + { + name: move_up + modifier: control + keycode: char_p + mode: [vi_normal, vi_insert] + event: { + until: [ + { send: menuup } + { send: up } + ] + } + } + { + name: move_down + modifier: control + keycode: char_t + mode: [vi_normal, vi_insert] + event: { + until: [ + { send: menudown } + { send: down } + ] + } + } + { + name: delete_one_character_backward + modifier: none + keycode: backspace + mode: [vi_insert] + event: { edit: backspace } + } + { + name: delete_one_word_backward + modifier: control + keycode: backspace + mode: [vi_insert] + event: { edit: backspaceword } + } + { + name: delete_one_character_forward + modifier: none + keycode: delete + mode: [vi_insert] + event: { edit: delete } + } + { + name: delete_one_character_forward + modifier: control + keycode: delete + mode: [vi_insert] + event: { edit: delete } + } + { + name: delete_one_character_backward + modifier: control + keycode: char_h + mode: [vi_insert] + event: { edit: backspace } + } + { + name: delete_one_word_backward + modifier: control + keycode: char_w + mode: [vi_insert] + event: { edit: backspaceword } + } + { + name: move_left + modifier: none + keycode: backspace + mode: vi_normal + event: { edit: moveleft } + } + { + name: cut_line_from_start + modifier: control + keycode: char_u + mode: [vi_normal, vi_insert] + event: { edit: cutfromstart } + } + { + name: copy_selection + modifier: control_shift + keycode: char_c + mode: emacs + event: { edit: copyselectionsystem } + } + { + name: cut_selection + modifier: control_shift + keycode: char_x + mode: emacs + event: { edit: cutselectionsystem } + } + { + name: paste_system + modifier: control_shift + keycode: char_v + mode: emacs + event: { edit: pastesystem } + } + { + name: select_all + modifier: control_shift + keycode: char_a + mode: emacs + event: { edit: selectall } + } + ] +} diff --git a/home/apps/starship/config.toml b/home/apps/starship/config.toml index 8aadc5d..c53c0fb 100644 --- a/home/apps/starship/config.toml +++ b/home/apps/starship/config.toml @@ -1,7 +1,7 @@ '$schema' = 'https://starship.rs/config-schema.json' format = """ -[╭](surface2)\ +[┌](surface2)\ $directory\ $username\ $hostname\ @@ -71,8 +71,7 @@ $terraform)\ $line_break\ \ $shell\ -[╰](surface2)\ -$character""" +[└](surface2)""" add_newline = true continuation_prompt = '[>](bold subtext0) ' diff --git a/home/apps/vscode/settings.json b/home/apps/vscode/settings.json index 1893e34..f809549 100644 --- a/home/apps/vscode/settings.json +++ b/home/apps/vscode/settings.json @@ -291,5 +291,17 @@ "vs-kubernetes": { "vs-kubernetes.crd-code-completion": "enabled", "vs-kubernetes.minikube-show-information-expiration": "2024-06-09T06:56:22.175Z" + }, + "editor.tokenColorCustomizations": { + "[Catppuccin Mocha]": { + "textMateRules": [ + { + "scope": "storage.type.dhall", + "settings": { + "foreground": "#FF0000" + } + } + ] + } } } diff --git a/home/apps/wezterm/config/keys.lua b/home/apps/wezterm/config/keys.lua index 04c2444..d6978d3 100644 --- a/home/apps/wezterm/config/keys.lua +++ b/home/apps/wezterm/config/keys.lua @@ -4,6 +4,10 @@ local act = wezterm.action local shortcuts = {} +---@param key string +---@param mods string|string[] +---@param action wezterm.Action +---@return nil local map = function(key, mods, action) if type(mods) == "string" then table.insert(shortcuts, { key = key, mods = mods, action = action }) @@ -127,12 +131,12 @@ M.apply = function(c) { event = { Down = { streak = 1, button = { WheelUp = 1 } } }, mods = "NONE", - action = wezterm.action.ScrollByLine(5), + action = act.ScrollByLine(5), }, { event = { Down = { streak = 1, button = { WheelDown = 1 } } }, mods = "NONE", - action = wezterm.action.ScrollByLine(-5), + action = act.ScrollByLine(-5), }, } end diff --git a/home/apps/wezterm/wezterm.lua b/home/apps/wezterm/wezterm.lua index cf41d21..627e450 100644 --- a/home/apps/wezterm/wezterm.lua +++ b/home/apps/wezterm/wezterm.lua @@ -4,6 +4,8 @@ local utils = require("config.utils") require("config.keys").apply(c) +c.default_prog = { "nu" } + c.font = wezterm.font_with_fallback({ "Berkeley Mono", "Symbols Nerd Font", @@ -28,8 +30,6 @@ if utils.is_darwin() then require("bar.plugin").apply_to_config(c) end -require("catppuccin.plugin").apply_to_config(c, { - sync = true, -}) +require("catppuccin.plugin").apply_to_config(c, { sync = true }) return c diff --git a/home/apps/zsh.nix b/home/apps/zsh.nix index b03f2e2..8ed6090 100644 --- a/home/apps/zsh.nix +++ b/home/apps/zsh.nix @@ -15,209 +15,101 @@ let }) plugins); in { - home.sessionVariables = { - LESS = "-R --use-color"; - LESSHISTFILE = "-"; - MANPAGER = "sh -c 'col -bx | bat -l man -p'"; - }; - home.packages = [ pkgs.onefetch ]; + programs.zsh = { + enable = true; + autosuggestion.enable = true; + enableCompletion = true; - programs = { - atuin = { - enable = true; - flags = [ "--disable-up-arrow" ]; - settings = { - inline_height = 30; - style = "compact"; - sync_address = "https://atuin.winston.sh"; - sync_frequency = "5m"; - }; - }; - bat = { - enable = true; - themes = { - "Catppuccin Latte" = { - src = "${srcs.catppuccin-bat.src}/themes"; - file = "Catppuccin Latte.tmTheme"; - }; - "Catppuccin Frappe" = { - src = "${srcs.catppuccin-bat.src}/themes"; - file = "Catppuccin Frappe.tmTheme"; - }; - "Catppuccin Macchiato" = { - src = "${srcs.catppuccin-bat.src}/themes"; - file = "Catppuccin Macchiato.tmTheme"; - }; - "Catppuccin Mocha" = { - src = "${srcs.catppuccin-bat.src}/themes"; - file = "Catppuccin Mocha.tmTheme"; - }; - }; - }; - btop = { - enable = true; - settings = { - theme_background = false; - vim_keys = true; - }; - }; + initExtraFirst = '' + zvm_config() { + ZVM_INIT_MODE=sourcing + ZVM_CURSOR_STYLE_ENABLED=false + ZVM_VI_HIGHLIGHT_BACKGROUND=black + ZVM_VI_HIGHLIGHT_EXTRASTYLE=bold,underline + ZVM_VI_HIGHLIGHT_FOREGROUND=white + } + ''; + initExtra = + '' + function incognito() { + if [[ -n $ZSH_INCOGNITO ]]; then + add-zsh-hook precmd _atuin_precmd + add-zsh-hook preexec _atuin_preexec + unset ZSH_INCOGNITO + else + add-zsh-hook -d precmd _atuin_precmd + add-zsh-hook -d preexec _atuin_preexec + export ZSH_INCOGNITO=1 + fi + } - direnv.enable = true; - direnv.nix-direnv.enable = true; + onefetch_in_git_dir() { + if [[ -d '.git' ]]; then + ${pkgs.onefetch}/bin/onefetch --no-merges --no-bots --no-color-palette --text-colors 1 1 3 4 4 + fi + } - eza = { - enable = true; - icons = true; - extraOptions = [ - "--group" - "--group-directories-first" - "--no-permissions" - "--octal-permissions" - ]; - }; - - fzf = { - enable = true; - colors = { - fg = "#cdd6f4"; - "fg+" = "#cdd6f4"; - hl = "#f38ba8"; - "hl+" = "#f38ba8"; - header = "#ff69b4"; - info = "#cba6f7"; - marker = "#f5e0dc"; - pointer = "#f5e0dc"; - prompt = "#cba6f7"; - spinner = "#f5e0dc"; - }; - defaultOptions = [ - "--height=30%" - "--layout=reverse" - "--info=inline" - ]; - }; - - less.enable = true; - - nix-index-database.comma.enable = true; - - starship = { - enable = true; - settings = builtins.fromTOML (builtins.readFile ./starship/config.toml); - }; - - tealdeer = { - enable = true; - settings = { - style = { - description.foreground = "white"; - command_name.foreground = "green"; - example_text.foreground = "blue"; - example_code.foreground = "white"; - example_variable.foreground = "yellow"; - }; - updates.auto_update = true; - }; - }; - - zoxide.enable = true; - - zsh = { - enable = true; - autosuggestion.enable = true; - enableCompletion = true; - - initExtraFirst = '' - zvm_config() { - ZVM_INIT_MODE=sourcing - ZVM_CURSOR_STYLE_ENABLED=false - ZVM_VI_HIGHLIGHT_BACKGROUND=black - ZVM_VI_HIGHLIGHT_EXTRASTYLE=bold,underline - ZVM_VI_HIGHLIGHT_FOREGROUND=white + add-zsh-hook chpwd onefetch_in_git_dir + '' + + lib.optionalString isLinux '' + function open() { + nohup xdg-open "$*" > /dev/null 2>&1 } ''; - initExtra = - '' - function incognito() { - if [[ -n $ZSH_INCOGNITO ]]; then - add-zsh-hook precmd _atuin_precmd - add-zsh-hook preexec _atuin_preexec - unset ZSH_INCOGNITO - else - add-zsh-hook -d precmd _atuin_precmd - add-zsh-hook -d preexec _atuin_preexec - export ZSH_INCOGNITO=1 - fi - } - onefetch_in_git_dir() { - if [[ -d '.git' ]]; then - ${pkgs.onefetch}/bin/onefetch --no-merges --no-bots --no-color-palette --text-colors 1 1 3 4 4 - fi - } - - add-zsh-hook chpwd onefetch_in_git_dir - '' - + lib.optionalString isLinux '' - function open() { - nohup xdg-open "$*" > /dev/null 2>&1 - } - ''; - - dotDir = ".config/zsh"; - oh-my-zsh = { - enable = true; - plugins = - [ - "colored-man-pages" - "colorize" - "git" - "kubectl" - ] - ++ lib.optionals pkgs.stdenv.isDarwin [ - "dash" - "macos" - ]; - }; - plugins = zshPlugins [ - { - src = pkgs.zsh-vi-mode; - file = "share/zsh-vi-mode/zsh-vi-mode.plugin.zsh"; - } - { - src = pkgs.zsh-nix-shell; - file = "share/zsh-nix-shell/nix-shell.plugin.zsh"; - } - { - src = pkgs.zsh-fast-syntax-highlighting.overrideAttrs (_: { - src = srcs.zsh-fast-syntax-highlighting.src; - }); - file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh"; - } - ]; - shellAliases = { - cat = "bat"; - - ls = "eza"; - ll = "eza -l"; - la = "eza -a"; - lt = "eza -T"; - lla = "eza -la"; - llt = "eza -lT"; - - cp = "cp -i"; - mv = "mv -i"; - rm = "rm -i"; - - # switch between yubikeys for the same GPG key - switch_yubikeys = ''gpg-connect-agent "scd serialno" "learn --force" "/bye"''; - - # podman - docker = "podman"; - docker-compose = "podman-compose"; - }; - history.path = "${config.xdg.configHome}/zsh/history"; + dotDir = ".config/zsh"; + oh-my-zsh = { + enable = true; + plugins = + [ + "colored-man-pages" + "colorize" + "git" + "kubectl" + ] + ++ lib.optionals pkgs.stdenv.isDarwin [ + "dash" + "macos" + ]; }; + plugins = zshPlugins [ + { + src = pkgs.zsh-vi-mode; + file = "share/zsh-vi-mode/zsh-vi-mode.plugin.zsh"; + } + { + src = pkgs.zsh-nix-shell; + file = "share/zsh-nix-shell/nix-shell.plugin.zsh"; + } + { + src = pkgs.zsh-fast-syntax-highlighting.overrideAttrs (_: { + src = srcs.zsh-fast-syntax-highlighting.src; + }); + file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh"; + } + ]; + shellAliases = { + cat = "bat"; + + ls = "eza"; + ll = "eza -l"; + la = "eza -a"; + lt = "eza -T"; + lla = "eza -la"; + llt = "eza -lT"; + + cp = "cp -i"; + mv = "mv -i"; + rm = "rm -i"; + + # switch between yubikeys for the same GPG key + switch_yubikeys = ''gpg-connect-agent "scd serialno" "learn --force" "/bye"''; + + # podman + docker = "podman"; + docker-compose = "podman-compose"; + }; + history.path = "${config.xdg.configHome}/zsh/history"; }; xdg.configFile."fsh".source = "${srcs.catppuccin-zsh-fsh.src}/themes";