-
Notifications
You must be signed in to change notification settings - Fork 5
/
git-zmv
executable file
·83 lines (74 loc) · 1.53 KB
/
git-zmv
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/zsh
# Copyright 2013 Mark Lodato <[email protected]>
# Released under the MIT license; see LICENSE for details.
SUBDIRECTORY_OK=Yes
OPTIONS_KEEPDASHDASH=
OPTIONS_SPEC="\
git zmv [options] <srcpat> <dest>
Use zsh's \"zmv\" module with \"git mv\". If invoked as 'mmv', -wW is assumed.
--
f,force force move/rename even if target exists
i,interactive show each line to be executed and ask whether to execute it
k skip move/rename errors
n print git-mv commands but do not execute
dry-run dry run (passed to git-mv)
v,verbose be verbose; given twice, be extra verbose
w implicitly add parentheses to wildcards in <srcpat>
W implicitly turn wildcards in <dest> into \${1} .. \${N}
"
emulate sh
autoload zmv
. "$(git --exec-path)/git-sh-setup"
require_work_tree
interactive=
zmv_verbose=
git_verbose=
force=
skip=
zmv_dry_run=
git_dry_run=
src_wild=
dest_wild=
case "$0" in
*-mmv)
src_wild=-w
dest_wild=-W
;;
esac
while test $# != 0
do
case "$1" in
-f|--force)
force=-f ;;
-i|--interactive)
interactive=-i ;;
-k)
skip=-k ;;
-n)
zmv_dry_run=-n ;;
--dry-run)
git_dry_run=-n ;;
-v|--verbose)
if [[ -n $zmv_verbose ]]; then
zmv_verbose=-v
else
git_verbose=-v
fi
;;
-w)
src_wild=-w ;;
-W)
dest_wild=-W ;;
--)
shift; break ;;
*)
break ;;
esac
shift
done
if [[ $# -ne 2 ]]; then
usage
fi
emulate zsh
zmv -p git -o "mv $force $skip $git_dry_run $git_verbose" \
$zmv_dry_run $interactive $zmv_verbose $src_wild $dest_wild -- "$@"