This repository was archived by the owner on Jan 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy path_p2-autocomplete.zsh
More file actions
84 lines (75 loc) · 2.5 KB
/
_p2-autocomplete.zsh
File metadata and controls
84 lines (75 loc) · 2.5 KB
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
84
#compdef p2
_p2() {
if ! docker version >/dev/null 2>&1; then
return
fi
_subcmd() {
local commands
commands=(
'attach:Attach into container'
'build:Build Docker image'
'commit:Commit container to image'
'rm:Remove container and its volumes'
'kill:Stop container from running'
'volume:Enter into container volume'
'ls:List pwnpad instances'
'update:Update image to the latest build'
)
_describe 'command' commands
}
_getcontainer() {
local listed=${words[${#words[@]}-1]}
local containers=( $(docker container ls -a --filter "ancestor=platypew/pwnpad" --filter "ancestor=platypew/pwnpad:lite" --format "{{.Names}}") )
for con in "${containers[@]}"; do
if [[ "$con" == "$listed" ]]; then
return
fi
done
compadd $containers
}
_arguments -C \
'1: :_subcmd' \
'*::arg:->args'
case $state in
args)
case $line[1] in
attach)
_getcontainer
_arguments -C \
'(-h)-h[help]' \
'(-P)-P[use privileged mode (not recommended)]' \
'(-S)-S[use sys_admin capability (required for chroot)]' \
'(-X)-X[support X11 forwarding]' \
'(-D)-D[run as daemon mode]' \
'(-d)-d[display]' \
'(-e)-e[use environmental variables]' \
'(-p)-p[port range]' \
'(-t)-t[ssh tunnelling]' \
'(-v)-v[mount volumes]' \
'(-i)-i[select image]'
;;
build)
_arguments -C : \
'-h[help]' \
'-i[image]' \
'-p[platform]'
;;
rm)
_getcontainer
_arguments -C : \
'-h[help]' \
'-f[forcefully remove mounted shared directory]'
;;
ls)
_arguments -C : \
'-h[help]' \
'-l[verbose]'
;;
commit | kill | volume)
_getcontainer
;;
esac
;;
esac
}
_p2