Merge pull request #5 from pagedMov/script-refactor

Script refactor
This commit is contained in:
2024-11-16 17:57:55 -05:00
committed by GitHub
4 changed files with 26 additions and 12 deletions

View File

@@ -5,7 +5,7 @@
movOpts = { movOpts = {
sysEnv = { sysEnv = {
issue.enable = true; issue.enable = true;
sddmConfig.enable = true; sddmConfig.enable = false;
stylixConfig.enable = true; stylixConfig.enable = true;
nixSettings.enable = true; nixSettings.enable = true;
}; };

View File

@@ -1,6 +1,11 @@
{ {
programs.nixvim = { programs.nixvim = {
keymaps = [ keymaps = [
{
action = "gg<S-V>G"; # select entire document
key = "<C-a>";
mode = "n";
}
{ {
action = "<cmd>ChatGPTEditWithInstructions<CR>"; action = "<cmd>ChatGPTEditWithInstructions<CR>";
key = "!egpt"; key = "!egpt";

View File

@@ -3,12 +3,15 @@ pkgs.writeShellApplication {
name = "viconf"; name = "viconf";
runtimeInputs = with pkgs; [ coreutils fd ripgrep fzf ]; runtimeInputs = with pkgs; [ coreutils fd ripgrep fzf ];
text = '' text = ''
#!/usr/bin/env bash set -- "''${1:-}"
if [ ! $# -lt 1 ]; then
[ ! $# -eq 1 ] && echo "Usage: viconf <*.nix>" && exit 1 results=$(find "$FLAKEPATH" -exec find {} \; | sort | uniq | rg '\.nix$')
numresults=$(echo "$results" | wc -l)
else
results=$(find "$FLAKEPATH" -wholename "*$1*" -exec find {} \; | sort | uniq | rg '\.nix$') results=$(find "$FLAKEPATH" -wholename "*$1*" -exec find {} \; | sort | uniq | rg '\.nix$')
numresults=$(echo "$results" | wc -l) numresults=$(echo "$results" | wc -l)
fi
[ "$numresults" -eq 0 ] && echo "$1 not found in \$FLAKEPATH" && exit 1 [ "$numresults" -eq 0 ] && echo "$1 not found in \$FLAKEPATH" && exit 1
@@ -16,10 +19,16 @@ pkgs.writeShellApplication {
# cut up the paths to give shorter path names to fuzzy finder # cut up the paths to give shorter path names to fuzzy finder
results_prefix=$(echo "$results" | tail -n 1 | cut -d'/' -f-3) results_prefix=$(echo "$results" | tail -n 1 | cut -d'/' -f-3)
results=$(echo "$results" | cut -d'/' -f4-) results=$(echo "$results" | cut -d'/' -f4-)
if [ -n "$1" ]; then
results=$(echo "$results" | grep "$1") results=$(echo "$results" | grep "$1")
fi
file=$(echo "$results" | tr ' ' '\n' | fzf) file=$(echo "$results" | tr ' ' '\n' | fzf)
if [ -n "$file" ]; then
file="$results_prefix/$file" file="$results_prefix/$file"
else
exit 1
fi
# Check if the file contains any non-UTF-8 characters # Check if the file contains any non-UTF-8 characters
if grep --color='auto' -P -q "[^\x00-\x7F]" "$file"; then if grep --color='auto' -P -q "[^\x00-\x7F]" "$file"; then

View File

@@ -10,10 +10,10 @@ pkgs.writeShellApplication {
str="''${str::-1}" str="''${str::-1}"
if [ "$char" = "-" ]; then return 0; fi if [ "$char" = "-" ]; then return 0; fi
case "$char" in case "$char" in
"a") if checkbools; then echo "$usage" && exit 1; else all=true; fi ;; "a") if checkbools; then all=true; else echo -e "$usage" && exit 1; fi ;;
"s") if checkbools; then system=true; else echo "$usage" && exit 1; fi ;; "s") if checkbools; then system=true; else echo -e "$usage" && exit 1; fi ;;
"h") if checkbools; then home=true; else echo "$usage" && exit 1; fi ;; "h") if checkbools; then home=true; else echo -e "$usage" && exit 1; fi ;;
"n") if [ "$dry" = false ]; then dry=true; else echo "$usage" && exit 1; fi ;; "n") if [ "$dry" = false ]; then dry=true; else echo -e "$usage" && exit 1; fi ;;
*) echo -e "$usage" && exit 1 ;; *) echo -e "$usage" && exit 1 ;;
esac esac
checkflags "$str" checkflags "$str"