-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpac
More file actions
executable file
·84 lines (65 loc) · 1.68 KB
/
pac
File metadata and controls
executable file
·84 lines (65 loc) · 1.68 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
#!/bin/bash
_ScriptVersion="1.0.0"
_fzf_flags="--ansi --multi --bind=space:toggle-preview --preview "
function install() {
# search for, selecct and install official packages
programs=$(pacman --color always -Sl | fzf ${_fzf_flags} "pacman -Si {2}" | cut -f 2 -d " " | tr '\n' ' ' | sed 's/\x1b\[[0-9;]*[a-zA-Z]//g')
echo -e "selected: \n${programs}"
if [ -n "$programs" ]; then
sudo pacman --needed -S $programs
fi
}
function uninstall() {
# select and uninstall packages
programs=$(pacman --color always -Q | cut -f 1 -d ' ' | fzf ${_fzf_flags} 'pacman -Qi {1}')
echo -e "selected: \n${programs}"
if [ -n "$programs" ]; then
sudo pacman -Rns $programs
fi
}
function info() {
# search for an installed package and display its info
program=$(pacman -Qq | fzf ${_fzf_flags} "pacman -Qi {}")
if [ -n "$program" ]; then
pacman -Qi "$program"
fi
}
function usage() {
echo "Usage : $0 [options] [--]
Options:
-h|help Display this message
-v|version Display script version"
}
#-----------------------------------------------------------------------
# Handle command line arguments
#-----------------------------------------------------------------------
while getopts ":hvsrq" opt; do
case $opt in
h | help)
usage
exit 0
;;
v | version)
echo "$0 -- Version $_ScriptVersion"
exit 0
;;
s | install) # uses repo sync and search like pacman -S
install
exit 0
;;
r | uninstall) # uses removal like pacman -R
uninstall
exit 0
;;
q | info) # uses local database query like pacman -Q
info
exit 0
;;
*)
echo -e "\n Option does not exist : $OPTARG\n"
usage
exit 1
;;
esac # --- end of case ---
done
shift $(($OPTIND - 1))