-
Notifications
You must be signed in to change notification settings - Fork 1
/
J.fish
56 lines (48 loc) · 1.39 KB
/
J.fish
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
function J -d "jujutsu launcher"
# !i -> --ignore-immutable
# !b -> --allow-backwards
# !n -> --allow-new
# !p -> --no-pager
# !ae -> --reset-author --no-edit
# ^XX -> --remote XX
#
# TODO: unify with vyxnix somehow?
# Specify --vyx-dry-run to echo the command that would be executed.
set -f dryrun 0
# $args: arguments passed to the command
set -f args
for arg in $argv
if test "$arg" = --vyx-dry-run
set dryrun 1
continue
end
if test "$arg" = "!i"
set -a args --ignore-immutable
continue
else if test "$arg" = "!b"
set -a args --allow-backwards
continue
else if test "$arg" = "!n"
set -a args --allow-new
continue
else if test "$arg" = "!p"
set -a args --no-pager
continue
else if test "$arg" = "!ae"
set -a args --reset-author --no-edit
continue
end
if string match -qr '\A\^(?<remote>.+)\z' -- "$arg"
set -a args --remote "$remote"
continue
end
set -a args $arg
end
if test "$dryrun" -eq 1
echo command jj (string escape -- $args)
else
command jj $args
end
end
complete -c J -l vyx-dry-run -d "do a dry run of this command; i.e. echo what would be run"
complete -c J -w jj