Added wrapter - a wrapper for apt[itude]
This commit is contained in:
parent
938bd641a2
commit
1565b90bd9
37
wrapter
Normal file
37
wrapter
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
# A wrapper for apt[itutde]
|
||||
# searches the repos for your query before trying to do the action.
|
||||
# Install : # apt install aptitude dmenu ; cp wrapter /usr/local/bin/wrapter ; cd /usr/local/bin/ ; chmod +x wrapter ; for link in Install Isntall Show Remove Why ; do ln -s wrapter $link ; done
|
||||
|
||||
action="$(basename "${0}")"
|
||||
|
||||
test "${action}" = wrapter && action="$(dmenu <<< "\
|
||||
install
|
||||
show
|
||||
remove
|
||||
why\
|
||||
")"
|
||||
|
||||
case "${action}" in
|
||||
*[iI][ns][ns]tall* )
|
||||
action=install
|
||||
sudo="sudo ";;
|
||||
*[sS]how* )
|
||||
action=show;;
|
||||
*[Rr]emove* | *purge* )
|
||||
action=purge
|
||||
sudo="sudo ";;
|
||||
*[wW]hy* )
|
||||
action=why;;
|
||||
* )
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
pkgs="$(aptitude search $@ | grep -v ":i386" )"
|
||||
|
||||
test -z "${pkgs}" && echo "No pkgs found matching $@." && exit 2
|
||||
nb="$(wc -l <<< "${pkgs}")"
|
||||
test "${nb}" -gt 1 && echo "$nb packages found." && pkgs="$(echo -e "${pkgs}" | dmenu)"
|
||||
|
||||
test "$(wc -l <<< "${pkgs}")" -eq 1 && pkgs="$(tr -s " " <<< "${pkgs}" | cut -d " " -f 2)" && echo -e "Package was found: ${action}ing ${pkgs}\n\$ ${sudo}aptitude ${action} ${pkgs}" && ${sudo}aptitude ${action} "${pkgs}"
|
Loading…
Reference in New Issue
Block a user