generated from aubreypwd/zsh-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zsh-plugin-vcshr.plugin.zsh
52 lines (41 loc) · 1.27 KB
/
zsh-plugin-vcshr.plugin.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/zsh
if [[ $(command -v antigen) ]]; then
antigen bundle aubreypwd/[email protected]
antigen apply
require "vcsh" "brew reinstall vcsh" "brew"
fi
###
# vcshr
#
# E.g. vcshr "homebrew" "aubreypwd" "vcsh-homebrew" --overwrite --autoignore
#
# This will require https://github.com/
#
# @since 1.0.0
# @since 10/2/20
#
# @author Aubrey Portwood <[email protected]>
##
function vcshr {
if ! [[ -x $(command -v vcsh) ]]; then >&2 echo "This uses the command 'vcsh' and we could not find the command." && return; fi
local name="$1"
local username="$2"
local repo="$3"
if [[ $(vcsh list) == *"$name"* ]]; then
return; # You already have it in your list, fail gracefully.
fi
local repo_url="https://github.com/$username/$repo" # Default to https, unless they pass the --ssh flag.
if [[ "$@" == *"--ssh"* ]]; then
local repo_url="ssh://[email protected]/$username/$repo.git"
fi
vcsh clone "$repo_url" "$name"
if [[ "$@" == *"--overwrite"* ]]; then
vcsh "$name" reset --hard origin/master
fi
if [[ "$@" == *"--autoignore"* ]]; then
sleep 2
# Yes, we have to do it twice
vcsh write-gitignore "$name" # Once to make the backup file, but it exists.
vcsh write-gitignore "$name" # Again, to write the new ignore file because the first one exited.
fi
}