Skip to content

Instantly share code, notes, and snippets.

@debxp
Last active June 9, 2019 15:37
Show Gist options
  • Save debxp/ad0a678236fd4c812d8d093dafff68c4 to your computer and use it in GitHub Desktop.
Save debxp/ad0a678236fd4c812d8d093dafff68c4 to your computer and use it in GitHub Desktop.
Meus aliases - apt
# ações cotidianas
alias up='sudo apt update'
alias upl='echo -e "$(apt list --upgradable 2>/dev/null)" | less'
alias upg='sudo apt upgrade'
alias apti='sudo apt install'
# busca pacotes instalados (sem argumentos=todos)
aptinstalled() {
echo ""
list="$(apt list --installed 2>/dev/null)"
if [[ $# -eq 0 ]]; then
less <<< $list
else
for pkg in "$@"; do
grep -e $pkg <<< $list
done
fi
echo ""
}
# info dos pacotes pesquisados
aptinfo() { apt-cache show "$@" | less; }
# busca pacotes disponíveis
aptsearch() { apt-cache search "$@" | sort | less; }
# Autocompletar dos aliases apt(x)
auto_complete_apt() {
mapfile -t COMPREPLY < <(apt-cache --no-generate pkgnames "$2");
}
complete -F auto_complete_apt apti
complete -F auto_complete_apt aptsearch
complete -F auto_complete_apt aptinfo
complete -F auto_complete_apt aptinstalled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment