From a56e23bd4735c47270f53c02260418efbed2021d Mon Sep 17 00:00:00 2001
From: sloane <1699281+sloanelybutsurely@users.noreply.github.com>
Date: Wed, 6 Mar 2024 10:42:56 -0500
Subject: [PATCH] update fish functions
---
.config/fish/functions/ls.fish | 2 +-
.config/fish/functions/worktree.fish | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 .config/fish/functions/worktree.fish
diff --git a/.config/fish/functions/ls.fish b/.config/fish/functions/ls.fish
index 1491011..fc3197d 100644
--- a/.config/fish/functions/ls.fish
+++ b/.config/fish/functions/ls.fish
@@ -1,5 +1,5 @@
function ls
- command exa --all \
+ command eza --all \
--long \
--group-directories-first \
--tree \
diff --git a/.config/fish/functions/worktree.fish b/.config/fish/functions/worktree.fish
new file mode 100644
index 0000000..6da2f2d
--- /dev/null
+++ b/.config/fish/functions/worktree.fish
@@ -0,0 +1,22 @@
+# inspired heavily by https://github.com/llimllib/personal_code/blob/daab9eb1da9f777df57c742e5629247a94b54947/homedir/.local/bin/worktree
+
+function worktree
+ set branchname $argv[1]
+ set dirname (string replace -a "/" "_" $branchname)
+
+ if not git pull
+ echo "Unable to run git pull, there may not be an upstream"
+ end
+
+ if git for-each-ref --format='%(refname:lstrip=2)' refs/heads | grep -E "^$branchname\$" > /dev/null 2>&1
+ git worktree add "../$dirname" "$branchname"
+ else if git for-each-ref --format='%(refname:lstrip=3)' refs/remotes/origin | grep -E "^$branchname\$" > /dev/null 2>&1
+ git worktree add "../$dirname" "$branchname"
+ else
+ git worktree add -b "$branchname" "../$dirname"
+ end
+
+ if test -d "node_modules"
+ cp -Rc node_modules ../$dirname/node_modules
+ end
+end