-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsys-packinfo.sh
executable file
·52 lines (46 loc) · 1.12 KB
/
sys-packinfo.sh
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
#!/usr/bin/env bash
# Dependencies: pacman, pacman-contrib, fzf
add_args=""
help_opt=""
show="info"
usage() {
echo " Usage: sys-packinfo.sh [OPTIONS]
OPTIONS:
-h Show this message
-s Change previewed item [default: info]
Options:
l,list List all files owned by previewed package
i,info Show package info
d,deps Show dependencies of package
r,revdeps Show reverse dependencies of package
-O Append more pacman query flags to \`pacman -Qeq\`
See also \`man pacman\`"
}
while getopts "hO:s:" opt; do
case "${opt}" in
h)
usage
exit 0
;;
O) add_args=${OPTARG} ;;
s) show=${OPTARG} ;;
\?)
usage
exit 1
;;
esac
done
shift $((OPTIND -1))
case $show in
l|"list") show_cmd="pacman -Ql {}" ;;
i|"info") show_cmd="pacman -Qi {}" ;;
d|"deps") show_cmd="pactree {}" ;;
r|"revdeps") show_cmd="pactree -r {}" ;;
*) show_cmd="pacman -Qi {}" ;;
esac
result=$(pacman -Qq${add_args} | fzf --reverse --preview="${show_cmd}")
retval=$?
if [ $retval -eq 0 ]; then
show_cmd=$(echo ${show_cmd} | sed "s/{}/$result/g")
${show_cmd} | less
fi