update fish functions
This commit is contained in:
parent
997ce5e140
commit
a56e23bd47
2 changed files with 23 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
function ls
|
||||
command exa --all \
|
||||
command eza --all \
|
||||
--long \
|
||||
--group-directories-first \
|
||||
--tree \
|
||||
|
|
22
.config/fish/functions/worktree.fish
Normal file
22
.config/fish/functions/worktree.fish
Normal file
|
@ -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
|
Loading…
Reference in a new issue