···20202121See `--help` for usage.
22222323+## update-gitignore
2424+Quickly and easily create or update `gitignore` files from predefined templates.
2525+2326## adb-auto-connect
2427Automatically find and connect to an Android device with Wireless Debugging over the local network.
2528
+53
scripts/update-gitignore.nu
···11+#!/usr/bin/env nu
22+# SPDX-License-Identifier: AGPL-3.0-only
33+# Copyright (c) 2026 MatrixFurry <matrix@matrixfurry.com>
44+55+const self = path self | path expand
66+const templates_dir = $self | path join ../../resources/gitignore/
77+88+# Create a gitignore file from predefined templates
99+def main [
1010+ --replace (-r) # Overwrite the exiting gitignore rather than appending to it
1111+ --global (-g) # Create a global ignore file at `~/.config/git/ignore`
1212+] {
1313+ let output_path: path = if $global {
1414+ mkdir ~/.config/git
1515+ "~/.config/git/ignore" | path expand
1616+ } else {
1717+ pwd | path join .gitignore
1818+ }
1919+2020+ let op = if ($output_path | path exists) {
2121+ if $replace {$"(ansi red)Replaced"} else {$"(ansi yellow)Appended(ansi reset) to"}
2222+ } else {
2323+ $"(ansi green)Created"
2424+ }
2525+2626+ # TODO: add global to display name or color code
2727+ let templates = ls -f $templates_dir
2828+ | append (ls -f ($templates_dir + "/Global"))
2929+ | where type == file
3030+ | get name
3131+3232+ let selected_templates = $templates
3333+ | input list -mf -s 'smart' -d {|| path parse | get stem} $"Use (ansi blue)<Tab>(ansi reset) to select templates, then (ansi blue)<Return>(ansi reset) to create"
3434+3535+ $selected_templates
3636+ | each {|path|
3737+ let name = $path | path parse | get stem
3838+3939+ $"### ($name) template\n(open --raw $path)"
4040+ }
4141+ | str join "\n"
4242+ | if $replace {
4343+ save -f $output_path
4444+ } else {
4545+ save -a $output_path
4646+ }
4747+4848+ print $"($op)(ansi reset) gitignore at (ansi blue)($output_path)(ansi reset) with the following templates:"
4949+ $selected_templates
5050+ | each {|| $"- (ansi cyan)($in | path parse | get stem)(ansi reset)"}
5151+ | str join "\n"
5252+ | print
5353+}