start of a nix home-manager configuration.

This commit is contained in:
Gabe Venberg 2024-03-18 17:37:20 -05:00
parent 1e3208699b
commit 2b11da0b62
15 changed files with 2784 additions and 1 deletions

View file

@ -1,5 +1,12 @@
all of my dotfiles, managed with (https://www.gnu.org/software/stow/manual/stow.html)[stow] all of my dotfiles, managed with (https://www.gnu.org/software/stow/manual/stow.html)[stow]
## Nix
I am working on migrating my dotfiles to nix, to allow configuration and installation in a single step.
In order to use the nix setup, you need to install nix and enable flakes,
then run `nix run --no-write-lock-file github:nix-community/home-manager/ -- --impure --flake . switch`, while in the nix directory.
from then on, you can update your configuration after making a change with `home-manager --impure --flake . switch`
## Dependencies: ## Dependencies:
This does not list the package manager dependencies of the programs the dotfiles are for, but any extra dependencies that are needed for the specific configuration. This does not list the package manager dependencies of the programs the dotfiles are for, but any extra dependencies that are needed for the specific configuration.

48
nix/flake.lock Normal file
View file

@ -0,0 +1,48 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1710714957,
"narHash": "sha256-eZCxuF58YWgaJMMRrn8oRkwRhxooe5kBS/s2wRVr9PA=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "7b3fca5adcf6c709874a8f2e0c364fe9c58db989",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1710631334,
"narHash": "sha256-rL5LSYd85kplL5othxK5lmAtjyMOBg390sGBTb3LRMM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "c75037bbf9093a2acb617804ee46320d6d1fea5a",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

33
nix/flake.nix Normal file
View file

@ -0,0 +1,33 @@
{
description = "Home Manager configuration";
inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
nixpkgs,
home-manager,
...
}: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
formatter.x86_64-linux = pkgs.alejandra;
homeConfigurations."gabe" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [./home.nix];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
};
};
}

261
nix/home.nix Normal file
View file

@ -0,0 +1,261 @@
{
config,
pkgs,
lib,
...
}: let
dotfilesDirectory = ~/dotfiles/nix;
in {
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = "gabe";
home.homeDirectory = "/home/gabe";
home.stateVersion = "23.11"; # Please read the comment before changing.
home.packages = [
pkgs.zellij
];
# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
home.file = {
".config/zellij/config.kdl".source = lib.path.append dotfilesDirectory "zellij/config.kdl";
".config/nushell/scripts".source = lib.path.append dotfilesDirectory "nushell/scripts";
};
home.sessionVariables = {
# EDITOR = "emacs";
EDITOR = "nvim";
VISUAL = "nvim";
};
home.sessionPath = [
"$HOME/.local/bin/"
"$HOME/.cargo/bin/"
"/opt/"
"$HOME/.nix-profile/bin/"
];
home.shellAliases = {
say = "espeak -p 10 -s 150 -a 200";
tmux = "tmux -u";
pdfmk = "latexmk -lualatex -pvc";
doc2pdf = "loffice --convert-to-pdf --headless *.docx";
sshmnt = "sshfs -o idmap=user,compression=no,reconnect,follow_symlinks,dir_cache=yes,ServerAliveInterval=15";
};
programs.git = {
enable = true;
aliases = {
hist = "log --graph --date-order --date=short --pretty=format:'%C(auto)%h%d %C(reset)%s %C(bold blue)%ce %C(reset)%C(green)%cr (%cd)'";
graph = "log --graph --topo-order --all --pretty=format:'%C(auto)%h %C(cyan)%an %C(blue)%ar %C(auto)%d %s'";
recent = "branch --sort=-committerdate --format='%(committerdate:relative)%09%(refname:short)'";
};
delta.enable = true;
# difftastic.enable=true;
# difftastic.background="dark";
userEmail = "gabevenberg@gmail.com";
userName = "Gabe Venberg";
extraConfig = {
init = {
defaultBranch = "main";
};
push = {
autoSetupRemote = true;
default = "current";
};
pull = {
ff = true;
};
merge = {
conflictstyle = "zdiff3";
};
rebase = {
autosquash = true;
};
help = {
autocorrect = "prompt";
};
branch = {
sort = "-committerdate";
};
status = {
submodulesummary = true;
};
};
includes = [
{
condition = "gitdir:~/work/";
contents = {
user = {
email = "venberggabe@johndeere.com";
};
};
}
];
};
programs.lazygit.enable = true;
programs.yazi = {
enable = true;
enableNushellIntegration = true;
enableZshIntegration = true;
};
programs.zoxide = {
enable = true;
enableNushellIntegration = true;
enableZshIntegration = true;
};
programs.fzf = {
enable = true;
enableZshIntegration = true;
};
programs.starship = {
enable = true;
enableNushellIntegration = true;
enableZshIntegration = true;
settings = {
format = lib.concatStrings [
"[](color_orange)"
"$shell"
"$hostname"
"[@](bg:color_orange)"
"$username"
"[ ](bg:color_orange)"
"[](bg:color_yellow fg:color_orange)"
"$directory"
"[](fg:color_yellow bg:color_aqua)"
"$git_branch"
"$git_status"
"[](fg:color_aqua bg:color_blue)"
"$git_metrics"
"[](fg:color_blue bg:color_bg3)"
"$git_commit"
"$fill"
"[](fg:color_bg1 bg:color_bg3)"
"$time"
"[ ](fg:color_bg1)"
"$line_break"
"$character"
];
add_newline = false;
palette = "gruvbox_dark";
palettes.gruvbox_dark = {
color_fg0 = "#fbf1c7";
color_bg1 = "#3c3836";
color_bg3 = "#665c54";
color_blue = "#458588";
color_aqua = "#689d6a";
color_green = "#98971a";
color_orange = "#d65d0e";
color_purple = "#b16286";
color_red = "#cc241d";
color_yellow = "#d79921";
};
hostname = {
ssh_only = false;
format = "[$ssh_symbol$hostname]($style)";
style = "bg:color_orange";
};
shell = {
disabled = false;
bash_indicator = "$";
fish_indicator = "<><";
zsh_indicator = "%";
nu_indicator = ">";
format = "[$indicator ]($style)";
style = "bg:color_orange";
};
fill = {
symbol = " ";
style = "bg:color_bg3";
};
username = {
show_always = true;
style_user = "bg:color_orange fg:color_fg0";
style_root = "bg:color_orange fg:color_fg0";
format = "[$user]($style)";
};
directory = {
style = "fg:color_fg0 bg:color_yellow";
format = "[ $path ]($style)";
fish_style_pwd_dir_length = 3;
truncation_length = 4;
truncation_symbol = "/";
};
git_branch = {
symbol = "";
style = "bg:color_aqua";
format = "[[ $symbol $branch ](fg:color_fg0 bg:color_aqua)]($style)";
};
git_status = {
style = "bg:color_aqua";
format = "[[($all_status$ahead_behind )](fg:color_fg0 bg:color_aqua)]($style)";
};
git_metrics = {
disabled = false;
added_style = "bg:color_blue fg:bold green";
deleted_style = "bg:color_blue fg:bold red";
format = "([ +$added ]($added_style))([-$deleted ]($deleted_style))";
};
git_commit = {
only_detached = false;
tag_disabled = false;
format = "[($hash$tag)]($style)";
style = "bg:color_bg3";
};
time = {
disabled = false;
time_format = "%R";
style = "bg:color_bg1";
format = "[[ $time ](fg:color_fg0 bg:color_bg1)]($style)";
};
line_break.disabled = false;
character.disabled = false;
};
};
programs.nushell = {
enable = true;
configFile.source = lib.path.append dotfilesDirectory "nushell/config.nu";
envFile.source = lib.path.append dotfilesDirectory "nushell/env.nu";
};
programs.zsh = {
enable = true;
enableCompletion = true;
autocd = true;
history = {
ignoreAllDups = true;
extended = true;
};
shellAliases = {
ll = "ls -lh";
la = "-lha";
please = "sudo $(fc -ln -1)";
slideshow = "feh --full-screen --randomize --auto-zoom --recursive --slideshow-delay";
pyactivate = "source ./.venv/bin/activate";
};
syntaxHighlighting = {
enable = true;
highlighters = [
"main"
"brackets"
"pattern"
"regexp"
"cursor"
"root"
"line"
];
};
};
services.ssh-agent.enable = true;
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}

762
nix/nushell/config.nu Normal file
View file

@ -0,0 +1,762 @@
# Nushell Config File
#
# version = "0.91.0"
let fish_completer = {|spans|
fish --command $'complete "--do-complete=($spans | str join " ")"'
| $"value(char tab)description(char newline)" + $in
| from tsv --flexible --no-infer
}
let carapace_completer = {|spans: list<string>|
carapace $spans.0 nushell ...$spans
| from json
| if ($in | default [] | where value =~ '^-.*ERR$' | is-empty) { $in } else { null }
}
let zoxide_completer = {|spans|
$spans | skip 1 | zoxide query -l $in | lines | where {|x| $x != $env.PWD}
}
# This completer will use carapace by default
let external_completer = $fish_completer
# The default config record. This is where much of your global configuration is setup.
$env.config = {
show_banner: true # true or false to enable or disable the welcome banner at startup
ls: {
use_ls_colors: true # use the LS_COLORS environment variable to colorize output
clickable_links: true # enable or disable clickable links. Your terminal has to support links.
}
rm: {
always_trash: false # always act as if -t was given. Can be overridden with -p
}
table: {
mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other
index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column
show_empty: true # show 'empty list' and 'empty record' placeholders for command output
padding: { left: 1, right: 1 } # a left right padding of each column in a table
trim: {
methodology: wrapping # wrapping or truncating
wrapping_try_keep_words: true # A strategy used by the 'wrapping' methodology
truncating_suffix: "..." # A suffix used by the 'truncating' methodology
}
header_on_separator: false # show header text on separator/border line
# abbreviated_row_count: 10 # limit data rows from top and bottom after reaching a set point
}
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: {
# normal: '%a, %d %b %Y %H:%M:%S %z' # shows up in displays of variables or other datetime's outside of tables
# table: '%m/%d/%y %I:%M:%S%p' # generally shows up in tabular outputs such as ls. commenting this out will change it to the default human readable datetime format
}
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: {
max_size: 100_000 # Session has to be reloaded for this to take effect
sync_on_enter: true # Enable to share history between multiple sessions, else you have to close the session to write history to file
file_format: "sqlite" # "sqlite" or "plaintext"
isolation: false # 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.
}
completions: {
case_sensitive: false # set to true to enable case-sensitive completions
quick: true # set this to false to prevent auto-selecting completions when only one remains
partial: true # set this to false to prevent partial filling of the prompt
algorithm: "fuzzy" # prefix or fuzzy
external: {
enable: true # 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
max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options
completer: $external_completer # check 'carapace_completer' above as an example
}
}
filesize: {
metric: true # 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: {
emacs: line # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (line is the default)
vi_insert: line # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (block is the default)
vi_normal: blink_block # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (underscore is the default)
}
color_config: $dark_theme # if you want a more interesting theme, you can replace the empty record with `$dark_theme`, `$light_theme` or another custom record
use_grid_icons: true
footer_mode: "25" # always, never, number_of_rows, auto
float_precision: 2 # the precision for displaying floats in tables
buffer_editor: "" # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.EDITOR and $env.VISUAL
use_ansi_coloring: true
bracketed_paste: true # enable bracketed paste, currently useless on windows
edit_mode: vi # emacs, vi
shell_integration: true # enables terminal shell integration. Off by default, as some terminals have issues with this.
render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt.
# enables keyboard enhancement protocol implemented by kitty console, only if your terminal support this.
# Zellij does not modify the term var, so we have to special-case it.
use_kitty_protocol: ($env.TERM == 'xterm-kitty' and $env.ZELLIJ? == null)
highlight_resolved_externals: true # true enables highlighting of external commands in the repl resolved by which.
plugins: {} # Per-plugin configuration. See https://www.nushell.sh/contributor-book/plugins.html#configuration.
hooks: {
pre_prompt: [{ null }] # run before the prompt is shown
pre_execution: [{ null }] # run before the repl input is run
env_change: {
PWD: [{|before, after| null }] # run if the PWD environment is different since the last repl input
}
display_output: "if (term size).columns >= 100 { table -e } else { table }" # run to display the output of a pipeline
command_not_found: { null } # return an error message when a command is not found
}
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
col_width: 20 # Optional value. If missing all the screen width is used to calculate column width
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: [
{
name: completion_menu
modifier: none
keycode: tab
mode: [emacs 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: [emacs vi_normal vi_insert]
event: {
until: [
{ send: menu name: ide_completion_menu }
{ send: menunext }
{ edit: complete }
]
}
}
{
name: history_menu
modifier: control
keycode: char_r
mode: [emacs, vi_insert, vi_normal]
event: { send: menu name: history_menu }
}
{
name: help_menu
modifier: none
keycode: f1
mode: [emacs, vi_insert, vi_normal]
event: { send: menu name: help_menu }
}
{
name: completion_previous_menu
modifier: shift
keycode: backtab
mode: [emacs, vi_normal, vi_insert]
event: { send: menuprevious }
}
{
name: next_page_menu
modifier: control
keycode: char_x
mode: emacs
event: { send: menupagenext }
}
{
name: undo_or_previous_page_menu
modifier: control
keycode: char_z
mode: emacs
event: {
until: [
{ send: menupageprevious }
{ edit: undo }
]
}
}
{
name: escape
modifier: none
keycode: escape
mode: [emacs, vi_normal, vi_insert]
event: { send: esc } # NOTE: does not appear to work
}
{
name: cancel_command
modifier: control
keycode: char_c
mode: [emacs, vi_normal, vi_insert]
event: { send: ctrlc }
}
{
name: quit_shell
modifier: control
keycode: char_d
mode: [emacs, vi_normal, vi_insert]
event: { send: ctrld }
}
{
name: clear_screen
modifier: control
keycode: char_l
mode: [emacs, vi_normal, vi_insert]
event: { send: clearscreen }
}
{
name: search_history
modifier: control
keycode: char_q
mode: [emacs, vi_normal, vi_insert]
event: { send: searchhistory }
}
{
name: open_command_editor
modifier: control
keycode: char_o
mode: [emacs, vi_normal, vi_insert]
event: { send: openeditor }
}
{
name: move_up
modifier: none
keycode: up
mode: [emacs, vi_normal, vi_insert]
event: {
until: [
{send: menuup}
{send: up}
]
}
}
{
name: move_down
modifier: none
keycode: down
mode: [emacs, vi_normal, vi_insert]
event: {
until: [
{send: menudown}
{send: down}
]
}
}
{
name: move_left
modifier: none
keycode: left
mode: [emacs, vi_normal, vi_insert]
event: {
until: [
{send: menuleft}
{send: left}
]
}
}
{
name: move_right_or_take_history_hint
modifier: none
keycode: right
mode: [emacs, vi_normal, vi_insert]
event: {
until: [
{send: historyhintcomplete}
{send: menuright}
{send: right}
]
}
}
{
name: move_one_word_left
modifier: control
keycode: left
mode: [emacs, vi_normal, vi_insert]
event: {edit: movewordleft}
}
{
name: move_one_word_right_or_take_history_hint
modifier: control
keycode: right
mode: [emacs, vi_normal, vi_insert]
event: {
until: [
{send: historyhintwordcomplete}
{edit: movewordright}
]
}
}
{
name: move_to_line_start
modifier: none
keycode: home
mode: [emacs, vi_normal, vi_insert]
event: {edit: movetolinestart}
}
{
name: move_to_line_start
modifier: control
keycode: char_a
mode: [emacs, vi_normal, vi_insert]
event: {edit: movetolinestart}
}
{
name: move_to_line_end_or_take_history_hint
modifier: none
keycode: end
mode: [emacs, 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: [emacs, vi_normal, vi_insert]
event: {
until: [
{send: historyhintcomplete}
{edit: movetolineend}
]
}
}
{
name: move_to_line_start
modifier: control
keycode: home
mode: [emacs, vi_normal, vi_insert]
event: {edit: movetolinestart}
}
{
name: move_to_line_end
modifier: control
keycode: end
mode: [emacs, vi_normal, vi_insert]
event: {edit: movetolineend}
}
{
name: move_up
modifier: control
keycode: char_p
mode: [emacs, vi_normal, vi_insert]
event: {
until: [
{send: menuup}
{send: up}
]
}
}
{
name: move_down
modifier: control
keycode: char_t
mode: [emacs, vi_normal, vi_insert]
event: {
until: [
{send: menudown}
{send: down}
]
}
}
{
name: delete_one_character_backward
modifier: none
keycode: backspace
mode: [emacs, vi_insert]
event: {edit: backspace}
}
{
name: delete_one_word_backward
modifier: control
keycode: backspace
mode: [emacs, vi_insert]
event: {edit: backspaceword}
}
{
name: delete_one_character_forward
modifier: none
keycode: delete
mode: [emacs, vi_insert]
event: {edit: delete}
}
{
name: delete_one_character_forward
modifier: control
keycode: delete
mode: [emacs, vi_insert]
event: {edit: delete}
}
{
name: delete_one_character_forward
modifier: control
keycode: char_h
mode: [emacs, vi_insert]
event: {edit: backspace}
}
{
name: delete_one_word_backward
modifier: control
keycode: char_w
mode: [emacs, vi_insert]
event: {edit: backspaceword}
}
{
name: move_left
modifier: none
keycode: backspace
mode: vi_normal
event: {edit: moveleft}
}
{
name: newline_or_run_command
modifier: none
keycode: enter
mode: emacs
event: {send: enter}
}
{
name: move_left
modifier: control
keycode: char_b
mode: emacs
event: {
until: [
{send: menuleft}
{send: left}
]
}
}
{
name: move_right_or_take_history_hint
modifier: control
keycode: char_f
mode: emacs
event: {
until: [
{send: historyhintcomplete}
{send: menuright}
{send: right}
]
}
}
{
name: redo_change
modifier: control
keycode: char_g
mode: emacs
event: {edit: redo}
}
{
name: undo_change
modifier: control
keycode: char_z
mode: emacs
event: {edit: undo}
}
{
name: paste_before
modifier: control
keycode: char_y
mode: emacs
event: {edit: pastecutbufferbefore}
}
{
name: cut_word_left
modifier: control
keycode: char_w
mode: emacs
event: {edit: cutwordleft}
}
{
name: cut_line_to_end
modifier: control
keycode: char_k
mode: emacs
event: {edit: cuttoend}
}
{
name: cut_line_from_start
modifier: control
keycode: char_u
mode: emacs
event: {edit: cutfromstart}
}
{
name: swap_graphemes
modifier: control
keycode: char_t
mode: emacs
event: {edit: swapgraphemes}
}
{
name: move_one_word_left
modifier: alt
keycode: left
mode: emacs
event: {edit: movewordleft}
}
{
name: move_one_word_right_or_take_history_hint
modifier: alt
keycode: right
mode: emacs
event: {
until: [
{send: historyhintwordcomplete}
{edit: movewordright}
]
}
}
{
name: move_one_word_left
modifier: alt
keycode: char_b
mode: emacs
event: {edit: movewordleft}
}
{
name: move_one_word_right_or_take_history_hint
modifier: alt
keycode: char_f
mode: emacs
event: {
until: [
{send: historyhintwordcomplete}
{edit: movewordright}
]
}
}
{
name: delete_one_word_forward
modifier: alt
keycode: delete
mode: emacs
event: {edit: deleteword}
}
{
name: delete_one_word_backward
modifier: alt
keycode: backspace
mode: emacs
event: {edit: backspaceword}
}
{
name: delete_one_word_backward
modifier: alt
keycode: char_m
mode: emacs
event: {edit: backspaceword}
}
{
name: cut_word_to_right
modifier: alt
keycode: char_d
mode: emacs
event: {edit: cutwordright}
}
{
name: upper_case_word
modifier: alt
keycode: char_u
mode: emacs
event: {edit: uppercaseword}
}
{
name: lower_case_word
modifier: alt
keycode: char_l
mode: emacs
event: {edit: lowercaseword}
}
{
name: capitalize_char
modifier: alt
keycode: char_c
mode: emacs
event: {edit: capitalizechar}
}
{
name: copy_selection
modifier: control_shift
keycode: char_c
mode: emacs
event: { edit: copyselection }
}
{
name: cut_selection
modifier: control_shift
keycode: char_x
mode: emacs
event: { edit: cutselection }
}
{
name: select_all
modifier: control_shift
keycode: char_a
mode: emacs
event: { edit: selectall }
}
{
name: paste
modifier: control_shift
keycode: char_v
mode: emacs
event: { edit: pastecutbufferbefore }
}
]
}
alias please = sudo (history | last | get command)
alias la = ls -a
alias ll = ls -l
alias lla = ls -la
alias pyactivate = overlay use ./.venv/bin/activate
# display a slideshow of all pics in a directory, recursively
def slideshow [delay: int = 10] {
feh --full-screen --randomize --auto-zoom --recursive --slideshow-delay $delay
}
#look up something on cheat.sh
def cheat [query: string] {
curl $"cheat.sh/($query)"
}
#look up the weather
def wttr [
location?: string
--format (-f): string
] {
http get $"https://wttr.in/($location)?format=($format)"
}
# parses git log into a nushell table.
def --wrapped git-log [...rest] {
git log --pretty=%h»¦«%H»¦«%s»¦«%aN»¦«%aE»¦«%aD ...$rest | lines | split column "»¦«" commit full-commit subject name email date | upsert date {|d| $d.date | into datetime}
}
# lists all the authors and how many commits they made in a histogram
def git-authors [] {
git-log --all | select name date | histogram name
}
# source the conditional config file that contains
# all the definitions, aliases, and env vars we want to set conditionally.
const conditional_config = ($nu.temp-path | path join 'conditional-config.nu')
# open $conditional_config | print
source $conditional_config
rm $conditional_config

103
nix/nushell/env.nu Normal file
View file

@ -0,0 +1,103 @@
# Nushell Environment Config File
#
# version = "0.91.0"
def create_left_prompt [] {
let dir = match (do --ignore-shell-errors { $env.PWD | path relative-to $nu.home-path }) {
null => $env.PWD
'' => '~'
$relative_pwd => ([~ $relative_pwd] | path join)
}
let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold })
let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold })
let path_segment = $"($path_color)($dir)"
$path_segment | str replace --all (char path_sep) $"($separator_color)(char path_sep)($path_color)"
}
def create_right_prompt [] {
# create a right prompt in magenta with green separators and am/pm underlined
let time_segment = ([
(ansi reset)
(ansi magenta)
(date now | format date '%x %X') # try to respect user's locale
] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" |
str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}")
let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([
(ansi rb)
($env.LAST_EXIT_CODE)
] | str join)
} else { "" }
([$last_exit_code, (char space), $time_segment] | str join)
}
# Use nushell functions to define your right and left prompt
$env.PROMPT_COMMAND = {|| create_left_prompt }
# FIXME: This default is not implemented in rust code as of 2023-09-08.
$env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt }
# The prompt indicators are environmental variables that represent
# the state of the prompt
$env.PROMPT_INDICATOR = {|| "> " }
$env.PROMPT_INDICATOR_VI_INSERT = {|| "> " }
$env.PROMPT_INDICATOR_VI_NORMAL = {|| ": " }
$env.PROMPT_MULTILINE_INDICATOR = {|| "::: " }
# If you want previously entered commands to have a different prompt from the usual one,
# you can uncomment one or more of the following lines.
# This can be useful if you have a 2-line prompt and it's taking up a lot of space
# because every command entered takes up 2 lines instead of 1. You can then uncomment
# the line below so that previously entered commands show with a single `🚀`.
# $env.TRANSIENT_PROMPT_COMMAND = {||""}
# $env.TRANSIENT_PROMPT_INDICATOR = {|| "" }
# $env.TRANSIENT_PROMPT_INDICATOR_VI_INSERT = {|| "" }
# $env.TRANSIENT_PROMPT_INDICATOR_VI_NORMAL = {|| "" }
# $env.TRANSIENT_PROMPT_MULTILINE_INDICATOR = {|| "" }
# $env.TRANSIENT_PROMPT_COMMAND_RIGHT = {|| "" }
# 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
$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) }
}
"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
# The default for this is $nu.default-config-dir/scripts
$env.NU_LIB_DIRS = [
($nu.default-config-dir | path join 'scripts') # add <nushell-config-dir>/scripts
]
# Directories to search for plugin binaries when calling register
# The default for this is $nu.default-config-dir/plugins
$env.NU_PLUGIN_DIRS = [
($nu.default-config-dir | path join 'plugins') # add <nushell-config-dir>/plugins
]
def is-installed [ app: string ] {
((which $app | length) > 0)
}
# To add entries to PATH (on Windows you might use Path), you can use the following pattern:
# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path')
# $env.PATH = ($env.PATH | split row (char esep) | append ($nu.home-path | path join ".local/bin/"))
# $env.PATH = ($env.PATH | split row (char esep) | append ($nu.home-path | path join ".cargo/bin/"))
# $env.PATH = ($env.PATH | split row (char esep) | append ($nu.home-path | path join "opt"))
# An alternate way to add entries to $env.PATH is to use the custom command `path add`
# which is built into the nushell stdlib:
# use std "path add"
# $env.PATH = ($env.PATH | split row (char esep))
ls (($nu.default-config-dir | path join ('scripts/**/*.nu')) | into glob) |
each { |it| $"source ($it.name)\n" | save --append $conditional_config} | ignore

View file

@ -0,0 +1,586 @@
## Written by lukexor, Improved by @Dan-Gamin
def "nu-complete cargo targets" [type: string] {
^cargo metadata --format-version=1 --offline --no-deps | from json | get packages.targets | flatten | where ($type in $it.kind) | get name
}
def "nu-complete cargo bins" [] { nu-complete cargo targets bin }
def "nu-complete cargo examples" [] { nu-complete cargo targets example }
def "nu-complete cargo packages" [] {
let metadata = (^cargo metadata --format-version=1 --offline --no-deps)
if $metadata == '' {
[]
} else {
$metadata | from json | get workspace_members | split column ' ' | get column1
}
}
def "nu-complete cargo color" [] {
['auto', 'always', 'never']
}
def "nu-complete cargo profiles" [] {
open Cargo.toml | get profile | transpose | get column0
}
def "nu-complete cargo features" [] {
open Cargo.toml | get features | transpose | get column0
}
# `cargo --list` is slow, `open` is faster.
# TODO: Add caching.
def "nu-complete cargo subcommands" [] {
^cargo --list | lines | skip 1 | str join "\n" | from ssv --noheaders | get column1
}
def "nu-complete cargo vcs" [] {
[
'git',
'hg',
'pijul',
'fossil',
'none'
]
}
#*> Core <*#
# Disabled due to messing with undefined cargo-subcommands
# # Rust's package manager
# export extern "cargo" [
# --version(-V) # Print version info and exit
# --list # List installed commands
# --explain: number # Run `rustc --explain CODE`
# --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
# --quiet(-q) # Do not print cargo log messages
# --color: string@"nu-complete cargo color" # Control when colored output is used
# --frozen # Require Cargo.lock and cache are up to date
# --locked # Require Cargo.lock is up to date
# --offline # Run without accessing the network
# --config: string # Override a configuration value
# -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
# -h, --help # Print help information
# ...args: any
# ]
#*> Common Commands (Sorted by order shown by running the `cargo` command) <*#
# Compile the current package
export extern "cargo build" [
--package(-p): string@"nu-complete cargo packages" # Build only the specified packages
--workspace # Build all members in the workspace
--exclude: string@"nu-complete cargo packages" # Exclude the specified packages
--lib # Build the package's library
--bin: string@"nu-complete cargo bins" # Build the specified binary
--bins # Build all binary targets
--example: string@"nu-complete cargo examples" # Build the specified example
--examples # Build all example targets
--test: string # Build the specified integration test
--tests # Build all targets in test mode that have the test = true manifest flag set
--bench: string # Build the specified benchmark
--benches # Build all targets in benchmark mode that have the bench = true manifest flag set
--all-targets # Build all targets
--features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate
--all-features # Activate all available features of all selected packages
--no-default-features # Do not activate the default feature of the selected packages
--target: string # Build for the given architecture.
--release(-r) # Build optimized artifacts with the release profile
--profile: string@"nu-complete cargo profiles" # Build with the given profile
--ignore-rust-version # Ignore `rust-version` specification in packages
--timings: string # Output information how long each compilation takes
--target-dir: path # Directory for all generated artifacts and intermediate files
--out-dir: path # Copy final artifacts to this directory
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
--message-format: string # The output format for diagnostic messages
--build-plan # Outputs a series of JSON messages to stdout that indicate the commands to run the build
--manifest-path: path # Path to the Cargo.toml file
--frozen # Require Cargo.lock and cache are up to date
--locked # Require Cargo.lock is up to date
--offline # Run without accessing the network
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help # Print help information
--jobs(-j): number # Number of parallel jobs to run
--future-incompat-report # Displays a future-incompat report for any future-incompatible warnings
]
# Check the current package
export extern "cargo check" [
--package(-p): string@"nu-complete cargo packages" #Check only the specified packages
--workspace # Check all members in the workspace
--all # Alias for --workspace (deprecated)
--exclude: string@"nu-complete cargo packages" # Exclude the specified packages
--lib # Check the package's library
--bin: string@"nu-complete cargo bins" # Check the specified binary
--example: string@"nu-complete cargo examples" # Check the specified example
--examples # Check all example targets
--test: string # Check the specified integration test
--tests # Check all targets in test mode that have the test = true manifest flag set
--bench: string # Check the specified benchmark
--benches # Check all targets in benchmark mode that have the bench = true manifest flag set
--all-targets # Check all targets
--features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate
--all-features # Activate all available features
--no-default-features # Do not activate the `default` feature
--target: string # Check for the given architecture
--release(-r) # Check optimized artifacts with the release profile
--profile: string@"nu-complete cargo profiles" # Check with the given profile
--ignore-rust-version # Ignore `rust-version` specification in packages
--timings: string # Output information how long each compilation takes
--target-dir: path # Directory for all generated artifacts and intermediate files
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
--message-format: string # The output format for diagnostic messages
--manifest-path: path # Path to the Cargo.toml file
--frozen # Require Cargo.lock and cache are up to date
--locked # Require Cargo.lock is up to date
--offline # Run without accessing the network
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help # Print help information
--jobs(-j): number # Number of parallel jobs to run
--keep-going # Build as many crates in the dependency graph as possible
--future-incompat-report # Displays a future-incompat report for any future-incompatible warnings
]
# Remove the target directory
export extern "cargo clean" [
--package(-p): string@"nu-complete cargo packages" # Clean only the specified packages
--doc # Remove only the doc directory in the target directory
--release # Remove all artifacts in the release directory
--profile # Remove all artifacts in the directory with the given profile name
--target-dir: path # Directory for all generated artifacts and intermediate files
--target: string # Clean for the given architecture
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
--message-format: string # The output format for diagnostic messages
--manifest-path: path # Path to the Cargo.toml file
--frozen # Require Cargo.lock and cache are up to date
--locked # Require Cargo.lock is up to date
--offline # Run without accessing the network
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help # Print help information
]
# Build a package's documentation
export extern "cargo doc" [
--open # Open the docs in a browser after building them
--no-deps # Do not build documentation for dependencie
--document-private-items # Include non-public items in the documentation
--package(-p): string@"nu-complete cargo packages" # Document only the specified packages
--workspace # Document all members in the workspace
--exclude: string@"nu-complete cargo packages" # Exclude the specified packages
--lib: string # Document the package's library
--bin: string@"nu-complete cargo bins" # Document the specified binary
--bins # Document all binary targets
--example: string@"nu-complete cargo examples" # Document the specified example
--examples # Document all example targets
--features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate
--all-features # Activate all available features of all selected packages
--no-default-features # Do not activate the default feature of the selected packages
--target: string # Document for the given architecture
--release(-r) # Document optimized artifacts with the release profile
--profile: string@"nu-complete cargo profiles" # Document with the given profile
--ignore-rust-version # Ignore `rust-version` specification in packages
--timings: string # Output information how long each compilation takes
--target-dir: path # Directory for all generated artifacts and intermediate files
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
--message-format: string # The output format for diagnostic messages
--manifest-path: path # Path to the Cargo.toml file
--frozen # Require Cargo.lock and cache are up to date
--locked # Require Cargo.lock is up to date
--offline # Run without accessing the network
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help # Print help information
--jobs(-j): number # Number of parallel jobs to run
--keep-going # Build as many crates in the dependency graph as possible
]
# Create a new cargo package
export extern "cargo new" [
path: path # The directory that will contain the project
--bin # Create a package with a binary target (src/main.rs) (default)
--lib # Create a package with a library target (src/lib.rs)
--edition: number # Specify the Rust edition to use (default: 2021)
--name: string # Set the package name. Defaults to the directory name.
--vcs: string@"nu-complete cargo vcs" # Initialize a new VCS repository for the given version control system
--registry: string # Name of the registry to use
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help # Print help information
]
# Create a new cargo package in an existing directory
export extern "cargo init" [
path: path # The directory that will contain the project
--bin # Create a package with a binary target (src/main.rs) (default)
--lib # Create a package with a library target (src/lib.rs)
--edition: number # Specify the Rust edition to use (default: 2021)
--name: string # Set the package name. Defaults to the directory name.
--vcs: string@"nu-complete cargo vcs" # Initialize a new VCS repository for the given version control system
--registry: string # Name of the registry to use
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help # Print help information
]
# Run the current cargo package
export extern "cargo run" [
...args: any # Arguments to be passed to your program
--bin: string@"nu-complete cargo bins" # Name of the bin target to run
--example: string@"nu-complete cargo examples" # Name of the example target to run
--quiet(-q) # Do not print cargo log messages
--package(-p): string@"nu-complete cargo packages" # Package with the target to run
--jobs(-j): number # Number of parallel jobs, defaults to # of CPUs
--release # Build artifacts in release mode, with optimizations
--profile: string@"nu-complete cargo profiles" # Build artifacts with the specified profile
--features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate
--all-features # Activate all available features
--no-default-features # Do not activate the `default` feature
--target: string # Build for the target triple
--target-dir: path # Directory for all generated artifacts
--manifest-path: path # Path to Cargo.toml
--message-format: string # Error format
--unit-graph # Output build graph in JSON (unstable)
--ignore-rust-version # Ignore `rust-version` specification in packages
--verbose(-v) # Use verbose output (-vv very verbose/build.rs output)
--color: string@"nu-complete cargo color" # Control when colored output is used
--frozen # Require Cargo.lock and cache are up to date
--locked # Require Cargo.lock is up to date
--offline # Run without accessing the network
--config: string # Override a configuration value (unstable)
-Z: string # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
--help(-h) # Prints help information
]
# Run the tests
export extern "cargo test" [
test_arg_separator?: string
...args: any # Arguments to be passed to the tests
--no-run # Compile, but don't run tests
--no-fail-fast # Run all tests regardless of failure
--package(-p): string@"nu-complete cargo packages" # Test only the specified packages
--workspace # Test all members in the workspace
--exclude: string@"nu-complete cargo packages" # Exclude the specified packages
--lib # Test the package's library
--bin: string@"nu-complete cargo bins" # Test only the specified binary
--bins # Test all binaries
--example: string@"nu-complete cargo examples" # Test only the specified example
--examples # Test all examples
--test: string # Test the specified integration test
--tests # Test all targets in test mode that have the test = true manifest flag set
--bench: string # Test the specified benchmark
--benches # Test all targets in benchmark mode that have the bench = true manifest flag set
--all-targets # Test all targets
--doc # Test ONLY the library's documentation
--features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate
--all-features # Activate all available features of all selected packages
--no-default-features # Do not activate the default feature of the selected packages
--target: string # Test for the given architecture
--release(-r) # Test optimized artifacts with the release profile
--profile: string@"nu-complete cargo profiles" # Test with the given profile
--ignore-rust-version # Ignore `rust-version` specification in packages
--timings: string # Output information how long each compilation takes
--target-dir: path # Directory for all generated artifacts and intermediate files
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
--message-format: string # The output format for diagnostic messages
--manifest-path: path # Path to the Cargo.toml file
--frozen # Require Cargo.lock and cache are up to date
--locked # Require Cargo.lock is up to date
--offline # Run without accessing the network
--help(-h) # Prints help information
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
--jobs(-j): number # Number of parallel jobs to run
--keep-going # Build as many crates in the dependency graph as possible
--future-incompat-report # Displays a future-incompat report for any future-incompatible warnings
]
# Execute benchmarks of a package
export extern "cargo bench" [
bench_option_seperator?: string
...options: any # Options to be passed to the benchmarks
--no-run # Compile, but don't run benchmarks
--no-fail-fast # Run all benchmarks regardless of failure
--package(-p): string@"nu-complete cargo packages" # Benchmark only the specified packages
--workspace # Benchmark all members in the workspace
--exclude: string@"nu-complete cargo packages" # Exclude the specified packages
--lib # Benchmark the package's library
--bin: string@"nu-complete cargo bins" # Benchmark only the specified binary
--bins # Benchmark all binary targets
--example: string@"nu-complete cargo examples" # Benchmark only the specified example
--examples # Benchmark all example targets
--test: string # Benchmark the specified integration test
--tests # Benchmark all targets in test mode that have the test = true
--bench: string # Benchmark the specified benchmark
--benches # Benchmark all targets in benchmark mode that have the bench = true manifest flag set
--all-targets # Benchmark all targets
--features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate
--all-features # Activate all available features of all selected packages
--no-default-features # Do not activate the default feature of the selected packages
--target: string # Benchmark for the given architecture
--profile: string@"nu-complete cargo profiles" # Build artifacts with the specified profile
--ignore-rust-version # Ignore `rust-version` specification in packages
--timings: string # Output information how long each compilation takes
--target-dir: path # Directory for all generated artifacts and intermediate files
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
--message-format: string # The output format for diagnostic messages
--build-plan # Outputs a series of JSON messages to stdout that indicate the commands to run the build
--manifest-path: path # Path to the Cargo.toml file
--frozen # Require Cargo.lock and cache are up to date
--locked # Require Cargo.lock is up to date
--offline # Run without accessing the network
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help # Print help information
--jobs(-j): number # Number of parallel jobs to run
--keep-going # Build as many crates in the dependency graph as possible
]
# Update dependencies listed in Cargo.lock
export extern "cargo update" [
--package(-p): string@"nu-complete cargo packages" # Update only the specified packages
--aggressive # Dependencies of the specified packages are forced to update as well
--precise: any # Allows you to specify a specific version number to set the package to
--workspace(-w) # Attempt to update only packages defined in the workspace
--dry-run # Displays what would be updated but doesn't write the lockfile
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
--manifest-path: path # Path to the Cargo.toml file
--frozen # Require Cargo.lock and cache are up to date
--locked # Require Cargo.lock is up to date
--offline # Run without accessing the network
--help(-h) # Prints help information
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
]
# Search packages in crates.io
export extern "cargo search" [
query: string # The thing to search
--limit: number # Limit the number of results. (default: 10, max: 100)
--index: string # The URL of the registry index to use
--registry: string # Name of the registry to use
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
--help(-h) # Prints help information
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
]
# Package and upload a package to the registry
export extern "cargo publish" [
--dry-run # Perform all checks without uploading
--token: any # API token to use when authenticating
--no-verify # Don't verify the contents by building them
--allow-dirty # Allow working directories with uncommitted VCS changes to be packaged
--index: string # The URL of the registry index to use
--registry: string # Name of the registry to publish to
--package(-p): string@"nu-complete cargo packages" # The package to publish
--target: string # Publish for the given architecture
--target-dir: path # Directory for all generated artifacts and intermediate files
--features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate
--all-features # Activate all available features of all selected packages
--no-default-features # Do not activate the default feature of the selected packages
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
--manifest-path: path # Path to the Cargo.toml file
--frozen # Require Cargo.lock and cache are up to date
--locked # Require Cargo.lock is up to date
--offline # Run without accessing the network
--help(-h) # Prints help information
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
--jobs(-j): number # Number of parallel jobs to run
--keep-going # Build as many crates in the dependency graph as possible
]
# Build and install a Rust binary
export extern "cargo install" [
crate?: string # The crate to install
--version: string # Specify a version to install
--vers: string # Specify a version to install
--git: string # Git URL to install the specified crate from
--branch: string # Branch to use when installing from git
--tag: string # Tag to use when installing from git
--rev: string # Specific commit to use when installing from git
--path: path # Filesystem path to local crate to install
--list # List all installed packages and their versions
--force(-f) # Force overwriting existing crates or binaries
--no-track # Don't keep track of this package
--bin: string@"nu-complete cargo bins" # Install only the specified binary
--bins # Install all binaries
--example: string@"nu-complete cargo examples" # Install only the specified example
--examples # Install all examples
--root: path # Directory to install packages into
--registry: string # Name of the registry to use
--index: string # The URL of the registry index to use
--features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate
--all-features # Activate all available features of all selected packages
--no-default-features # Do not activate the default feature of the selected packages
--target: string # Install for the given architecture
--target-dir: path # Directory for all generated artifacts and intermediate files
--debug # Build with the dev profile instead the release profile
--profile: string@"nu-complete cargo profiles" # Build artifacts with the specified profile
--timings: string # Output information how long each compilation takes
--frozen # Require Cargo.lock and cache are up to date
--locked # Require Cargo.lock is up to date
--offline # Run without accessing the network
--jobs(-j): number # Number of parallel jobs to run
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
--message-format: string # The output format for diagnostic messages
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help # Print help information
]
# Remove a Rust binary
export extern "cargo uninstall" [
package?: string@"nu-complete cargo packages" # Package to uninstall
--package(-p): string@"nu-complete cargo packages" # Package to uninstall
--bin: string@"nu-complete cargo bins" # Only uninstall the binary name
--root: path # Directory to uninstall packages from
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help # Print help information
]
#*> Other Commands <*#
# Output the resolved dependencies of a package in machine-readable format
export extern "cargo metadata" [
--no-deps # Output information only about the workspace members and don't fetch dependencies
--format-version: number # Specify the version of the output format to use. Currently 1 is the only possible value
--filter-platform: string # This filters the resolve output to only include dependencies for the iven target triple
--features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate
--all-features # Activate all available features of all selected packages
--no-default-features # Do not activate the default feature of the selected packages
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
--manifest-path: path # Path to the Cargo.toml file
--frozen # Require Cargo.lock and cache are up to date
--locked # Require Cargo.lock is up to date
--offline # Run without accessing the network
--help(-h) # Prints help information
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
]
# Get the help of the given cargo subcommand
export extern "cargo help" [
subcommand: string@"nu-complete cargo subcommands"
--color: string@"nu-complete cargo color" # Control when colored output is used
--config: string # Override a configuration value
--frozen # Require Cargo.lock and cache are up to date
--locked # Require Cargo.lock is up to date
--offline # Run without accessing the network
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
]
# A bunch of lints to catch common mistakes and improve your Rust code
export extern "cargo clippy" [
--no-deps # Run Clippy only on the given crate, without linting the dependencies
--fix # Automatically apply lint suggestions. This flag implies `--no-deps
--version(-V) # Prints version information
--help(-h) # Prints help information
--warn(-W) # Set lint warnings
--allow(-A) # Set lint allowed
--deny(-D) # Set lint denied
--forbid(-F) # Set lint forbidden
--package(-p): string@"nu-complete cargo packages" #Check only the specified packages
--workspace # Check all members in the workspace
--all # Alias for --workspace (deprecated)
--exclude: string@"nu-complete cargo packages" # Exclude the specified packages
--lib # Check the package's library
--bin: string@"nu-complete cargo bins" # Check the specified binary
--example: string@"nu-complete cargo examples" # Check the specified example
--examples # Check all example targets
--test: string # Check the specified integration test
--tests # Check all targets in test mode that have the test = true manifest flag set
--bench: string # Check the specified benchmark
--benches # Check all targets in benchmark mode that have the bench = true manifest flag set
--all-targets # Check all targets
--features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate
--all-features # Activate all available features
--no-default-features # Do not activate the `default` feature
--target: string # Check for the given architecture
--release(-r) # Check optimized artifacts with the release profile
--profile: string@"nu-complete cargo profiles" # Check with the given profile
--ignore-rust-version # Ignore `rust-version` specification in packages
--timings: string # Output information how long each compilation takes
--target-dir: path # Directory for all generated artifacts and intermediate files
--verbose(-v) # Use verbose output. May be specified twice for "very verbose" output
--quiet(-q) # Do not print cargo log messages
--color: string@"nu-complete cargo color" # Control when colored output is used
--message-format: string # The output format for diagnostic messages
--manifest-path: path # Path to the Cargo.toml file
--frozen # Require Cargo.lock and cache are up to date
--locked # Require Cargo.lock is up to date
--offline # Run without accessing the network
-Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help # Print help information
--jobs(-j): number # Number of parallel jobs to run
--keep-going # Build as many crates in the dependency graph as possible
--future-incompat-report # Displays a future-incompat report for any future-incompatible warnings
-Z: any
]
# Parameters from cargo update
export extern "cargo install-update" [
--all(-a) # Update all packages
--allow-no-update(-i) # Allow for fresh-installing packages
--downdate(-d) # Downdate packages to match latest unyanked registry version
--force(-f) # Update all packages regardless if they need updating
--git(-g) # Also update git packages
--help(-h) # Prints help information
--list(-l) # Don't update packages, only list and check if they need an update (all packages by default)
--quiet(-q) # No output printed to stdout
--version(-V) # Prints version information
--cargo-dir(-c) # The cargo home directory. Default: $CARGO_HOME or $HOME/.cargo
--filter(-s) # Specify a filter a package must match to be considered
--install-cargo(-r) # Specify an alternative cargo to run for installations
--temp-dir(-t) # The temporary directory. Default: $TEMP/cargo-update
]
# Parameters from cargo add
export extern "cargo add" [
--no-default-features # Disable the default features
--default-features # Re-enable the default features
--features(-F) # Space or comma separated list of features to activate
--optional # Mark the dependency as optional
--verbose(-v) # Use verbose output (-vv very verbose/build.rs output)
--no-optional # Mark the dependency as required
--color: string@"nu-complete cargo color" # Coloring: auto, always, never
--rename # Rename the dependency
--locked # Require Cargo.lock is up to date
--package(-p) # Package to modify
--offline # Run without accessing the network
--quiet(-q) # Do not print cargo log messages
--config # Override a configuration value
--dry-run # Don't actually write the manifest
--help(-h) # Print help information
--path # Filesystem path to local crate to add
--git # Git repository location
--branch # Git branch to download the crate from
--tag # Git tag to download the crate from
--rev # Git reference to download the crate from
--registry # Package registry for this dependency
--dev # Add as development dependency
--build # Add as build dependency
--target # Add as dependency to the given target platform
...args
]

View file

@ -0,0 +1,493 @@
def "nu-complete git available upstream" [] {
^git branch -a | lines | each { |line| $line | str replace '\* ' "" | str trim }
}
def "nu-complete git remotes" [] {
^git remote | lines | each { |line| $line | str trim }
}
def "nu-complete git log" [] {
^git log --pretty=%h | lines | each { |line| $line | str trim }
}
# Yield all existing commits in descending chronological order.
def "nu-complete git commits all" [] {
^git rev-list --all --remotes --pretty=oneline | lines | parse "{value} {description}"
}
# Yield commits of current branch only. This is useful for e.g. cut points in
# `git rebase`.
def "nu-complete git commits current branch" [] {
^git log --pretty="%h %s" | lines | parse "{value} {description}"
}
# Yield local branches like `main`, `feature/typo_fix`
def "nu-complete git local branches" [] {
^git branch | lines | each { |line| $line | str replace '* ' "" | str trim }
}
# Yield remote branches like `origin/main`, `upstream/feature-a`
def "nu-complete git remote branches with prefix" [] {
^git branch -r | lines | parse -r '^\*?(\s*|\s*\S* -> )(?P<branch>\S*$)' | get branch | uniq
}
# Yield remote branches *without* prefix which do not have a local counterpart.
# E.g. `upstream/feature-a` as `feature-a` to checkout and track in one command
# with `git checkout` or `git switch`.
def "nu-complete git remote branches nonlocal without prefix" [] {
# Get regex to strip remotes prefixes. It will look like `(origin|upstream)`
# for the two remotes `origin` and `upstream`.
let remotes_regex = (["(", ((nu-complete git remotes | each {|r| [$r, '/'] | str join}) | str join "|"), ")"] | str join)
let local_branches = (nu-complete git local branches)
^git branch -r | lines | parse -r (['^[\* ]+', $remotes_regex, '?(?P<branch>\S+)'] | flatten | str join) | get branch | uniq | where {|branch| $branch != "HEAD"} | where {|branch| $branch not-in $local_branches }
}
def "nu-complete git switch" [] {
(nu-complete git local branches)
| parse "{value}"
| insert description "local branch"
| append (nu-complete git remote branches nonlocal without prefix
| parse "{value}"
| insert description "remote branch")
}
def "nu-complete git checkout" [] {
(nu-complete git local branches)
| parse "{value}"
| insert description "local branch"
| append (nu-complete git remote branches nonlocal without prefix
| parse "{value}"
| insert description "remote branch")
| append (nu-complete git remote branches with prefix
| parse "{value}"
| insert description "remote branch")
| append (nu-complete git commits all)
| append (nu-complete git files | where description != "Untracked" | select value)
}
# Arguments to `git rebase --onto <arg1> <arg2>`
def "nu-complete git rebase" [] {
(nu-complete git local branches)
| parse "{value}"
| insert description "local branch"
| append (nu-complete git remote branches with prefix
| parse "{value}"
| insert description "remote branch")
| append (nu-complete git commits all)
}
def "nu-complete git stash-list" [] {
git stash list | lines | parse "{value}: {description}"
}
def "nu-complete git tags" [] {
^git tag | lines
}
# See `man git-status` under "Short Format"
# This is incomplete, but should cover the most common cases.
const short_status_descriptions = {
".D": "Deleted"
".M": "Modified"
"!" : "Ignored"
"?" : "Untracked"
"AU": "Staged, not merged"
"MD": "Some modifications staged, file deleted in work tree"
"MM": "Some modifications staged, some modifications untracked"
"R.": "Renamed"
"UU": "Both modified (in merge conflict)"
}
def "nu-complete git files" [] {
let relevant_statuses = ["?",".M", "MM", "MD", ".D", "UU"]
^git status -uall --porcelain=2
| lines
| each { |$it|
if $it starts-with "1 " {
$it | parse --regex "1 (?P<short_status>\\S+) (?:\\S+\\s?){6} (?P<value>\\S+)"
} else if $it starts-with "2 " {
$it | parse --regex "2 (?P<short_status>\\S+) (?:\\S+\\s?){6} (?P<value>\\S+)"
} else if $it starts-with "u " {
$it | parse --regex "u (?P<short_status>\\S+) (?:\\S+\\s?){8} (?P<value>\\S+)"
} else if $it starts-with "? " {
$it | parse --regex "(?P<short_status>.{1}) (?P<value>.+)"
} else {
{ short_status: 'unknown', value: $it }
}
}
| flatten
| where $it.short_status in $relevant_statuses
| insert "description" { |e| $short_status_descriptions | get $e.short_status}
}
def "nu-complete git built-in-refs" [] {
[HEAD FETCH_HEAD ORIG_HEAD]
}
def "nu-complete git refs" [] {
nu-complete git switchable branches
| parse "{value}"
| insert description Branch
| append (nu-complete git tags | parse "{value}" | insert description Tag)
| append (nu-complete git built-in-refs)
}
def "nu-complete git files-or-refs" [] {
nu-complete git switchable branches
| parse "{value}"
| insert description Branch
| append (nu-complete git files | where description == "Modified" | select value)
| append (nu-complete git tags | parse "{value}" | insert description Tag)
| append (nu-complete git built-in-refs)
}
def "nu-complete git subcommands" [] {
^git help -a | lines | where $it starts-with " " | parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
}
def "nu-complete git add" [] {
nu-complete git files
}
# Check out git branches and files
export extern "git checkout" [
...targets: string@"nu-complete git checkout" # name of the branch or files to checkout
--conflict: string # conflict style (merge or diff3)
--detach(-d) # detach HEAD at named commit
--force(-f) # force checkout (throw away local modifications)
--guess # second guess 'git checkout <no-such-branch>' (default)
--ignore-other-worktrees # do not check if another worktree is holding the given ref
--ignore-skip-worktree-bits # do not limit pathspecs to sparse entries only
--merge(-m) # perform a 3-way merge with the new branch
--orphan: string # new unparented branch
--ours(-2) # checkout our version for unmerged files
--overlay # use overlay mode (default)
--overwrite-ignore # update ignored files (default)
--patch(-p) # select hunks interactively
--pathspec-from-file: string # read pathspec from file
--progress # force progress reporting
--quiet(-q) # suppress progress reporting
--recurse-submodules # control recursive updating of submodules
--theirs(-3) # checkout their version for unmerged files
--track(-t) # set upstream info for new branch
-b # create and checkout a new branch
-B: string # create/reset and checkout a branch
-l # create reflog for new branch
]
# Download objects and refs from another repository
export extern "git fetch" [
repository?: string@"nu-complete git remotes" # name of the branch to fetch
--all # Fetch all remotes
--append(-a) # Append ref names and object names to .git/FETCH_HEAD
--atomic # Use an atomic transaction to update local refs.
--depth: int # Limit fetching to n commits from the tip
--deepen: int # Limit fetching to n commits from the current shallow boundary
--shallow-since: string # Deepen or shorten the history by date
--shallow-exclude: string # Deepen or shorten the history by branch/tag
--unshallow # Fetch all available history
--update-shallow # Update .git/shallow to accept new refs
--negotiation-tip: string # Specify which commit/glob to report while fetching
--negotiate-only # Do not fetch, only print common ancestors
--dry-run # Show what would be done
--write-fetch-head # Write fetched refs in FETCH_HEAD (default)
--no-write-fetch-head # Do not write FETCH_HEAD
--force(-f) # Always update the local branch
--keep(-k) # Keep dowloaded pack
--multiple # Allow several arguments to be specified
--auto-maintenance # Run 'git maintenance run --auto' at the end (default)
--no-auto-maintenance # Don't run 'git maintenance' at the end
--auto-gc # Run 'git maintenance run --auto' at the end (default)
--no-auto-gc # Don't run 'git maintenance' at the end
--write-commit-graph # Write a commit-graph after fetching
--no-write-commit-graph # Don't write a commit-graph after fetching
--prefetch # Place all refs into the refs/prefetch/ namespace
--prune(-p) # Remove obsolete remote-tracking references
--prune-tags(-P) # Remove any local tags that do not exist on the remote
--no-tags(-n) # Disable automatic tag following
--refmap: string # Use this refspec to map the refs to remote-tracking branches
--tags(-t) # Fetch all tags
--recurse-submodules: string # Fetch new commits of populated submodules (yes/on-demand/no)
--jobs(-j): int # Number of parallel children
--no-recurse-submodules # Disable recursive fetching of submodules
--set-upstream # Add upstream (tracking) reference
--submodule-prefix: string # Prepend to paths printed in informative messages
--upload-pack: string # Non-default path for remote command
--quiet(-q) # Silence internally used git commands
--verbose(-v) # Be verbose
--progress # Report progress on stderr
--server-option(-o): string # Pass options for the server to handle
--show-forced-updates # Check if a branch is force-updated
--no-show-forced-updates # Don't check if a branch is force-updated
-4 # Use IPv4 addresses, ignore IPv6 addresses
-6 # Use IPv6 addresses, ignore IPv4 addresses
]
# Push changes
export extern "git push" [
remote?: string@"nu-complete git remotes", # the name of the remote
...refs: string@"nu-complete git local branches" # the branch / refspec
--all # push all refs
--atomic # request atomic transaction on remote side
--delete(-d) # delete refs
--dry-run(-n) # dry run
--exec: string # receive pack program
--follow-tags # push missing but relevant tags
--force-with-lease # require old value of ref to be at this value
--force(-f) # force updates
--ipv4(-4) # use IPv4 addresses only
--ipv6(-6) # use IPv6 addresses only
--mirror # mirror all refs
--no-verify # bypass pre-push hook
--porcelain # machine-readable output
--progress # force progress reporting
--prune # prune locally removed refs
--push-option(-o): string # option to transmit
--quiet(-q) # be more quiet
--receive-pack: string # receive pack program
--recurse-submodules: string # control recursive pushing of submodules
--repo: string # repository
--set-upstream(-u) # set upstream for git pull/status
--signed: string # GPG sign the push
--tags # push tags (can't be used with --all or --mirror)
--thin # use thin pack
--verbose(-v) # be more verbose
]
# Pull changes
export extern "git pull" [
remote?: string@"nu-complete git remotes", # the name of the remote
...refs: string@"nu-complete git local branches" # the branch / refspec
--rebase # rebase current branch on top of upstream after fetching
]
# Switch between branches and commits
export extern "git switch" [
switch?: string@"nu-complete git switch" # name of branch to switch to
--create(-c) # create a new branch
--detach(-d): string@"nu-complete git log" # switch to a commit in a detatched state
--force-create(-C): string # forces creation of new branch, if it exists then the existing branch will be reset to starting point
--force(-f) # alias for --discard-changes
--guess # if there is no local branch which matches then name but there is a remote one then this is checked out
--ignore-other-worktrees # switch even if the ref is held by another worktree
--merge(-m) # attempts to merge changes when switching branches if there are local changes
--no-guess # do not attempt to match remote branch names
--no-progress # do not report progress
--no-recurse-submodules # do not update the contents of sub-modules
--no-track # do not set "upstream" configuration
--orphan: string # create a new orphaned branch
--progress # report progress status
--quiet(-q) # suppress feedback messages
--recurse-submodules # update the contents of sub-modules
--track(-t) # set "upstream" configuration
]
# Apply the change introduced by an existing commit
export extern "git cherry-pick" [
commit?: string@"nu-complete git commits all" # The commit ID to be cherry-picked
--edit(-e) # Edit the commit message prior to committing
--no-commit(-n) # Apply changes without making any commit
--signoff(-s) # Add Signed-off-by line to the commit message
--ff # Fast-forward if possible
--continue # Continue the operation in progress
--abort # Cancel the operation
--skip # Skip the current commit and continue with the rest of the sequence
]
# Rebase the current branch
export extern "git rebase" [
branch?: string@"nu-complete git rebase" # name of the branch to rebase onto
upstream?: string@"nu-complete git rebase" # upstream branch to compare against
--continue # restart rebasing process after editing/resolving a conflict
--abort # abort rebase and reset HEAD to original branch
--quit # abort rebase but do not reset HEAD
--interactive(-i) # rebase interactively with list of commits in editor
--onto?: string@"nu-complete git rebase" # starting point at which to create the new commits
--root # start rebase from root commit
]
# List or change branches
export extern "git branch" [
branch?: string@"nu-complete git local branches" # name of branch to operate on
--abbrev # use short commit hash prefixes
--edit-description # open editor to edit branch description
--merged # list reachable branches
--no-merged # list unreachable branches
--set-upstream-to: string@"nu-complete git available upstream" # set upstream for branch
--unset-upstream # remote upstream for branch
--all # list both remote and local branches
--copy # copy branch together with config and reflog
--format # specify format for listing branches
--move # rename branch
--points-at # list branches that point at an object
--show-current # print the name of the current branch
--verbose # show commit and upstream for each branch
--color # use color in output
--quiet # suppress messages except errors
--delete(-d) # delete branch
--list # list branches
--contains: string@"nu-complete git commits all" # show only branches that contain the specified commit
--no-contains # show only branches that don't contain specified commit
--track(-t) # when creating a branch, set upstream
]
# List or change tracked repositories
export extern "git remote" [
--verbose(-v) # Show URL for remotes
]
# Add a new tracked repository
export extern "git remote add" [
]
# Rename a tracked repository
export extern "git remote rename" [
remote: string@"nu-complete git remotes" # remote to rename
new_name: string # new name for remote
]
# Remove a tracked repository
export extern "git remote remove" [
remote: string@"nu-complete git remotes" # remote to remove
]
# Get the URL for a tracked repository
export extern "git remote get-url" [
remote: string@"nu-complete git remotes" # remote to get URL for
]
# Set the URL for a tracked repository
export extern "git remote set-url" [
remote: string@"nu-complete git remotes" # remote to set URL for
url: string # new URL for remote
]
# Show changes between commits, working tree etc
export extern "git diff" [
rev1_or_file?: string@"nu-complete git files-or-refs"
rev2?: string@"nu-complete git refs"
--cached # show staged changes
--name-only # only show names of changed files
--name-status # show changed files and kind of change
--no-color # disable color output
]
# Commit changes
export extern "git commit" [
--all(-a) # automatically stage all modified and deleted files
--amend # amend the previous commit rather than adding a new one
--message(-m) # specify the commit message rather than opening an editor
--no-edit # don't edit the commit message (useful with --amend)
]
# List commits
export extern "git log" [
# Ideally we'd allow completion of revisions here, but that would make completion of filenames not work.
-U # show diffs
--follow # show history beyond renames (single file only)
--grep: string # show log entries matching supplied regular expression
]
# Show or change the reflog
export extern "git reflog" [
]
# Stage files
export extern "git add" [
...file: string@"nu-complete git add" # file to add
--all(-A) # add all files
--dry-run(-n) # don't actually add the file(s), just show if they exist and/or will be ignored
--edit(-e) # open the diff vs. the index in an editor and let the user edit it
--force(-f) # allow adding otherwise ignored files
--interactive(-i) # add modified contents in the working tree interactively to the index
--patch(-p) # interactively choose hunks to stage
--verbose(-v) # be verbose
]
# Delete file from the working tree and the index
export extern "git rm" [
-r # recursive
--force(-f) # override the up-to-date check
--dry-run(-n) # Don't actually remove any file(s)
--cached # unstage and remove paths only from the index
]
# Show the working tree status
export extern "git status" [
--verbose(-v) # be verbose
--short(-s) # show status concisely
--branch(-b) # show branch information
--show-stash # show stash information
]
# Stash changes for later
export extern "git stash push" [
--patch(-p) # interactively choose hunks to stash
]
# Unstash previously stashed changes
export extern "git stash pop" [
stash?: string@"nu-complete git stash-list" # stash to pop
--index(-i) # try to reinstate not only the working tree's changes, but also the index's ones
]
# List stashed changes
export extern "git stash list" [
]
# Show a stashed change
export extern "git stash show" [
stash: string@"nu-complete git stash-list"
-U # show diff
]
# Drop a stashed change
export extern "git stash drop" [
stash?: string@"nu-complete git stash-list"
]
# Create a new git repository
export extern "git init" [
--initial-branch(-b) # initial branch name
]
# List or manipulate tags
export extern "git tag" [
--delete(-d): string@"nu-complete git tags" # delete a tag
]
# Prune all unreachable objects
export extern "git prune" [
--dry-run(-n) # dry run
--expire: string # expire objects older than
--progress # show progress
--verbose(-v) # report all removed objects
]
# Start a binary search to find the commit that introduced a bug
export extern "git bisect start" [
bad?: string # a commit that has the bug
good?: string # a commit that doesn't have the bug
]
# Mark the current (or specified) revision as bad
export extern "git bisect bad" [
]
# Mark the current (or specified) revision as good
export extern "git bisect good" [
]
# Skip the current (or specified) revision
export extern "git bisect skip" [
]
# End bisection
export extern "git bisect reset" [
]
# Show help for a git subcommand
export extern "git help" [
command: string@"nu-complete git subcommands" # subcommand to show help for
]

View file

@ -0,0 +1,44 @@
def "nu-complete just recipes" [] {
^just --unsorted --dump --dump-format json
| from json
| get recipes
| transpose k v
| each {|x|
{
value: $x.k,
description: ( $x.v.parameters
| each {|y|
if ($y.default|is-empty) {
$y.name
} else {
$'($y.name)="($y.default)"'
}
}
| str join ' '
)
}
}
}
def "nu-complete just args" [context: string, offset: int] {
let r = ($context | split row ' ')
^just -u --dump --dump-format json
| from json
| get recipes
| get ($r.1)
| get body
| each {|x| {description: ($x | get 0) }}
| prepend ''
}
export def just [
recipes?: string@"nu-complete just recipes"
...args: any@"nu-complete just args"
] {
if ($recipes | is-empty) {
^just
} else {
^just $recipes ...$args
}
}

View file

@ -0,0 +1,65 @@
def "nu-complete make" [] {
ls
| find --ignore-case makefile
| open $in.0.name
| lines
| find ':'
| where ($it | str starts-with '.') == false
| split column ' '
| get column1
| find ':'
| str replace ':' ''
}
def "nu-complete make jobs" [] {
seq 1 (sys | get cpu | length)
}
def "nu-complete make files" [] {
ls **/* | where type == file | get name
}
def "nu-complete make dirs" [] {
ls **/* | where type == dir | get name
}
export extern "make" [
command?: string@"nu-complete make"
--always-make(-B) # Unconditionally make all targets.
--directory(-C): string@"nu-complete make dirs" # Change to DIRECTORY before doing anything.
--debug(-d) # Print various types of debugging information.
--environment-overrides(-e) # Environment variables override makefiles.
--eval(-E): string # Evaluate STRING as a makefile statement.
--file(-f) # Read FILE as a makefile.
--help(-h) # Print this message and exit.
--ignore-errors(-i) # Ignore errors from recipes.
--include-dir(-I): string@"nu-complete make dirs" # Search DIRECTORY for included makefiles.
--jobs(-j): int@"nu-complete make jobs" # Allow N jobs at once; infinite jobs with no arg.
--keep-going(-k) # Keep going when some targets can't be made.
--load-average(-l): int@"nu-complete make jobs" # Don't start multiple jobs unless load is below N.
--check-symlink-times(-L) # Use the latest mtime between symlinks and target.
--just-print(-n) # Don't actually run any recipe; just print them.
--dry-run
--recon
--assume-old: string@"nu-complete make files" # Consider FILE to be very old and don't remake it.
--old-file(-o): string@"nu-complete make files"
--output-sync(-O) # Synchronize output of parallel jobs by TYPE.
--print-data-base(-p) # Print make's internal database.
--question(-q) # Run no recipe; exit status says if up to date.
--no-builtin-rules(-r) # Disable the built-in implicit rules.
--no-builtin-variables(-R) # Disable the built-in variable settings.
--silent(-s) # Don't echo recipes.
--quiet
--no-silent # Echo recipes (disable --silent mode).
--stop(-S) # Turns off -k.
--no-keep-going
--touch(-t) # Touch targets instead of remaking them.
--trace # Print tracing information.
--version(-v) # Print the version number of make and exit.
--print-directory(-w) # Print the current directory.
--no-print-directory # Turn off -w, even if it was turned on implicitly.
--what-if(-W): string@"nu-complete make files" # Consider FILE to be infinitely new.
--new-file: string@"nu-complete make files"
--assume-new: string@"nu-complete make files"
--warn-undefined-variables # Warn when an undefined variable is referenced.
]

View file

@ -0,0 +1,27 @@
# Function to extract archives with different extensions.
export def extract [name:string] {
let handlers = [
[extension command];
['tar\.bz2|tbz|tbz2' 'tar xvjf']
['tar\.gz|tgz' 'tar xvzf']
['tar\.xz|txz' 'tar xvf']
['tar\.Z' 'tar xvZf']
['bz2' 'bunzip2']
['deb' 'ar x']
['gz' 'gunzip']
['pkg' 'pkgutil --expand']
['rar' 'unrar x']
['tar' 'tar xvf']
['xz' 'xz --decompress']
['zip|war|jar|nupkg' 'unzip']
['Z' 'uncompress']
['7z' '7za x']
]
let maybe_handler = ($handlers | where $name =~ $'\.(($it.extension))$')
if ($maybe_handler | is-empty) {
error make { msg: "unsupported file extension" }
} else {
let handler = ($maybe_handler | first)
nu -c ($handler.command + ' ' + $"'($name)'")
}
}

352
nix/zellij/config.kdl Normal file
View file

@ -0,0 +1,352 @@
// If you'd like to override the default keybindings completely, be sure to change "keybinds" to "keybinds clear-defaults=true"
keybinds clear-defaults=true{
normal {
// uncomment this and adjust key if using copy_on_select=false
// bind "Alt c" { Copy; }
}
locked {
bind "Alt g" { SwitchToMode "Normal"; }
}
resize {
bind "Alt r" { SwitchToMode "Normal"; }
bind "h" "Left" { Resize "Increase Left"; }
bind "j" "Down" { Resize "Increase Down"; }
bind "k" "Up" { Resize "Increase Up"; }
bind "l" "Right" { Resize "Increase Right"; }
bind "H" { Resize "Decrease Left"; }
bind "J" { Resize "Decrease Down"; }
bind "K" { Resize "Decrease Up"; }
bind "L" { Resize "Decrease Right"; }
bind "=" "+" { Resize "Increase"; }
bind "-" { Resize "Decrease"; }
}
pane {
bind "Alt p" { SwitchToMode "Normal"; }
bind "h" "Left" { MoveFocus "Left"; }
bind "l" "Right" { MoveFocus "Right"; }
bind "j" "Down" { MoveFocus "Down"; }
bind "k" "Up" { MoveFocus "Up"; }
bind "p" { SwitchFocus; }
bind "n" { NewPane; SwitchToMode "Normal"; }
bind "d" { NewPane "Down"; SwitchToMode "Normal"; }
bind "r" { NewPane "Right"; SwitchToMode "Normal"; }
bind "x" { CloseFocus; SwitchToMode "Normal"; }
bind "f" { ToggleFocusFullscreen; SwitchToMode "Normal"; }
bind "z" { TogglePaneFrames; SwitchToMode "Normal"; }
bind "w" { ToggleFloatingPanes; SwitchToMode "Normal"; }
bind "e" { TogglePaneEmbedOrFloating; SwitchToMode "Normal"; }
bind "c" { SwitchToMode "RenamePane"; PaneNameInput 0;}
}
move {
bind "Alt m" { SwitchToMode "Normal"; }
bind "n" "Tab" { MovePane; }
bind "p" { MovePaneBackwards; }
bind "h" "Left" { MovePane "Left"; }
bind "j" "Down" { MovePane "Down"; }
bind "k" "Up" { MovePane "Up"; }
bind "l" "Right" { MovePane "Right"; }
}
tab {
bind "Alt t" { SwitchToMode "Normal"; }
bind "r" { SwitchToMode "RenameTab"; TabNameInput 0; }
bind "h" "Left" "Up" "k" { GoToPreviousTab; }
bind "l" "Right" "Down" "j" { GoToNextTab; }
bind "n" { NewTab; SwitchToMode "Normal"; }
bind "x" { CloseTab; SwitchToMode "Normal"; }
bind "s" { ToggleActiveSyncTab; SwitchToMode "Normal"; }
bind "b" { BreakPane; SwitchToMode "Normal"; }
bind "]" { BreakPaneRight; SwitchToMode "Normal"; }
bind "[" { BreakPaneLeft; SwitchToMode "Normal"; }
bind "1" { GoToTab 1; SwitchToMode "Normal"; }
bind "2" { GoToTab 2; SwitchToMode "Normal"; }
bind "3" { GoToTab 3; SwitchToMode "Normal"; }
bind "4" { GoToTab 4; SwitchToMode "Normal"; }
bind "5" { GoToTab 5; SwitchToMode "Normal"; }
bind "6" { GoToTab 6; SwitchToMode "Normal"; }
bind "7" { GoToTab 7; SwitchToMode "Normal"; }
bind "8" { GoToTab 8; SwitchToMode "Normal"; }
bind "9" { GoToTab 9; SwitchToMode "Normal"; }
bind "Tab" { ToggleTab; }
}
scroll {
bind "Alt s" { SwitchToMode "Normal"; }
bind "e" { EditScrollback; SwitchToMode "Normal"; }
bind "s" { SwitchToMode "EnterSearch"; SearchInput 0; }
bind "Ctrl c" { ScrollToBottom; SwitchToMode "Normal"; }
bind "j" "Down" { ScrollDown; }
bind "k" "Up" { ScrollUp; }
bind "Ctrl f" "PageDown" "Right" "l" { PageScrollDown; }
bind "Ctrl b" "PageUp" "Left" "h" { PageScrollUp; }
bind "d" { HalfPageScrollDown; }
bind "u" { HalfPageScrollUp; }
// uncomment this and adjust key if using copy_on_select=false
// bind "Alt c" { Copy; }
}
search {
bind "Alt s" { SwitchToMode "Normal"; }
bind "Ctrl c" { ScrollToBottom; SwitchToMode "Normal"; }
bind "j" "Down" { ScrollDown; }
bind "k" "Up" { ScrollUp; }
bind "Ctrl f" "PageDown" "Right" "l" { PageScrollDown; }
bind "Ctrl b" "PageUp" "Left" "h" { PageScrollUp; }
bind "d" { HalfPageScrollDown; }
bind "u" { HalfPageScrollUp; }
bind "n" { Search "down"; }
bind "p" { Search "up"; }
bind "c" { SearchToggleOption "CaseSensitivity"; }
bind "w" { SearchToggleOption "Wrap"; }
bind "o" { SearchToggleOption "WholeWord"; }
}
entersearch {
bind "Ctrl c" "Esc" { SwitchToMode "Scroll"; }
bind "Enter" { SwitchToMode "Search"; }
}
renametab {
bind "Ctrl c" { SwitchToMode "Normal"; }
bind "Esc" { UndoRenameTab; SwitchToMode "Tab"; }
}
renamepane {
bind "Ctrl c" { SwitchToMode "Normal"; }
bind "Esc" { UndoRenamePane; SwitchToMode "Pane"; }
}
session {
bind "Alt o" { SwitchToMode "Normal"; }
bind "Alt s" { SwitchToMode "Scroll"; }
bind "d" { Detach; }
bind "w" {
LaunchOrFocusPlugin "zellij:session-manager" {
floating true
move_to_focused_tab true
};
SwitchToMode "Normal"
}
}
tmux {
bind "[" { SwitchToMode "Scroll"; }
bind "Alt a" { Write 2; SwitchToMode "Normal"; }
bind "\"" { NewPane "Down"; SwitchToMode "Normal"; }
bind "%" { NewPane "Right"; SwitchToMode "Normal"; }
bind "z" { ToggleFocusFullscreen; SwitchToMode "Normal"; }
bind "c" { NewTab; SwitchToMode "Normal"; }
bind "," { SwitchToMode "RenameTab"; }
bind "p" { GoToPreviousTab; SwitchToMode "Normal"; }
bind "n" { GoToNextTab; SwitchToMode "Normal"; }
bind "Left" { MoveFocus "Left"; SwitchToMode "Normal"; }
bind "Right" { MoveFocus "Right"; SwitchToMode "Normal"; }
bind "Down" { MoveFocus "Down"; SwitchToMode "Normal"; }
bind "Up" { MoveFocus "Up"; SwitchToMode "Normal"; }
bind "h" { MoveFocus "Left"; SwitchToMode "Normal"; }
bind "l" { MoveFocus "Right"; SwitchToMode "Normal"; }
bind "j" { MoveFocus "Down"; SwitchToMode "Normal"; }
bind "k" { MoveFocus "Up"; SwitchToMode "Normal"; }
bind "o" { FocusNextPane; }
bind "d" { Detach; }
bind "Space" { NextSwapLayout; }
bind "x" { CloseFocus; SwitchToMode "Normal"; }
}
shared_except "locked" {
bind "Alt g" { SwitchToMode "Locked"; }
bind "Alt q" { Quit; }
bind "Alt n" { NewPane; }
bind "Alt h" "Alt Left" { MoveFocusOrTab "Left"; }
bind "Alt l" "Alt Right" { MoveFocusOrTab "Right"; }
bind "Alt j" "Alt Down" { MoveFocus "Down"; }
bind "Alt k" "Alt Up" { MoveFocus "Up"; }
bind "Alt =" "Alt +" { Resize "Increase"; }
bind "Alt -" { Resize "Decrease"; }
bind "Alt [" { PreviousSwapLayout; }
bind "Alt ]" { NextSwapLayout; }
}
shared_except "normal" "locked" {
bind "Enter" "Esc" { SwitchToMode "Normal"; }
}
shared_except "pane" "locked" {
bind "Alt p" { SwitchToMode "Pane"; }
}
shared_except "resize" "locked" {
bind "Alt r" { SwitchToMode "Resize"; }
}
shared_except "scroll" "locked" {
bind "Alt s" { SwitchToMode "Scroll"; }
}
shared_except "session" "locked" {
bind "Alt o" { SwitchToMode "Session"; }
}
shared_except "tab" "locked" {
bind "Alt t" { SwitchToMode "Tab"; }
}
shared_except "move" "locked" {
bind "Alt m" { SwitchToMode "Move"; }
}
shared_except "tmux" "locked" {
bind "Alt b" { SwitchToMode "Tmux"; }
}
}
plugins {
tab-bar { path "tab-bar"; }
status-bar { path "status-bar"; }
strider { path "strider"; }
compact-bar { path "compact-bar"; }
session-manager { path "session-manager"; }
}
// Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP
// eg. when terminal window with an active zellij session is closed
// Options:
// - detach (Default)
// - quit
//
// on_force_close "detach"
// Send a request for a simplified ui (without arrow fonts) to plugins
// Options:
// - true
// - false (Default)
//
// simplified_ui false
// Choose the path to the default shell that zellij will use for opening new panes
// Default: $SHELL
//
// default_shell "fish"
// Choose the path to override cwd that zellij will use for opening new panes
//
// default_cwd ""
// Toggle between having pane frames around the panes
// Options:
// - true (default)
// - false
//
// pane_frames true
// Toggle between having Zellij lay out panes according to a predefined set of layouts whenever possible
// Options:
// - true (default)
// - false
//
// auto_layout true
// Whether sessions should be serialized to the cache folder (including their tabs/panes, cwds and running commands) so that they can later be resurrected
// Options:
// - true (default)
// - false
//
// session_serialization false
// Whether pane viewports are serialized along with the session, default is false
// Options:
// - true
// - false (default)
// serialize_pane_viewport true
// Scrollback lines to serialize along with the pane viewport when serializing sessions, 0
// defaults to the scrollback size. If this number is higher than the scrollback size, it will
// also default to the scrollback size. This does nothing if `serialize_pane_viewport` is not true.
//
// scrollback_lines_to_serialize 10000
// Define color themes for Zellij
// For more examples, see: https://github.com/zellij-org/zellij/tree/main/example/themes
// Once these themes are defined, one of them should to be selected in the "theme" section of this file
//
themes {
// example of how to set a theme in HEX format
gruvbox-dark {
fg "#D5C4A1"
bg "#282828"
black "#3C3836"
red "#CC241D"
green "#98971A"
yellow "#D79921"
blue "#3C8588"
magenta "#B16286"
cyan "#689D6A"
white "#FBF1C7"
orange "#D65D0E"
}
}
// Choose the theme that is specified in the themes section.
// Default: default
//
theme "gruvbox-dark"
// The name of the default layout to load on startup
// Default: "default"
//
// default_layout "compact"
// Choose the mode that zellij uses when starting up.
// Default: normal
//
// default_mode "locked"
// Toggle enabling the mouse mode.
// On certain configurations, or terminals this could
// potentially interfere with copying text.
// Options:
// - true (default)
// - false
//
// mouse_mode false
// Configure the scroll back buffer size
// This is the number of lines zellij stores for each pane in the scroll back
// buffer. Excess number of lines are discarded in a FIFO fashion.
// Valid values: positive integers
// Default value: 10000
//
// scroll_buffer_size 10000
// Provide a command to execute when copying text. The text will be piped to
// the stdin of the program to perform the copy. This can be used with
// terminal emulators which do not support the OSC 52 ANSI control sequence
// that will be used by default if this option is not set.
// Examples:
//
// copy_command "xclip -selection clipboard" // x11
// copy_command "wl-copy" // wayland
// copy_command "pbcopy" // osx
// Choose the destination for copied text
// Allows using the primary selection buffer (on x11/wayland) instead of the system clipboard.
// Does not apply when using copy_command.
// Options:
// - system (default)
// - primary
//
// copy_clipboard "primary"
// Enable or disable automatic copy (and clear) of selection when releasing mouse
// Default: true
//
// copy_on_select false
// Path to the default editor to use to edit pane scrollbuffer
// Default: $EDITOR or $VISUAL
//
// scrollback_editor "/usr/bin/vim"
// When attaching to an existing session with other users,
// should the session be mirrored (true)
// or should each user have their own cursor (false)
// Default: false
//
// mirror_session true
// The folder in which Zellij will look for layouts
//
// layout_dir "/path/to/my/layout_dir"
// The folder in which Zellij will look for themes
//
// theme_dir "/path/to/my/theme_dir"
// Enable or disable the rendering of styled and colored underlines (undercurl).
// May need to be disabled for certain unsupported terminals
// Default: true
//
// styled_underlines false

View file

@ -1,6 +1,6 @@
"$schema" = 'https://starship.rs/config-schema.json' "$schema" = 'https://starship.rs/config-schema.json'
continuation_prompt = '---> ' continuation_prompt = ''
format = """ format = """
[](color_orange)\ [](color_orange)\

1
work/.config/git/config Symbolic link
View file

@ -0,0 +1 @@
/nix/store/d1sl5m40shqa5m4n0q9q0bl0bhxjsgcn-home-manager-files/.config/git/config

View file

@ -31,6 +31,7 @@
export PATH="$PATH:$HOME/.local/bin/" export PATH="$PATH:$HOME/.local/bin/"
export PATH="$PATH:/opt" export PATH="$PATH:/opt"
export PATH="$PATH:$HOME/.cargo/bin" export PATH="$PATH:$HOME/.cargo/bin"
export PATH="$PATH:$HOME/.nix-profile/bin"
#prompt #prompt
setprompt() { setprompt() {