s4bba7

Alias to apt, apt-get with completion.

Apr 30th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.68 KB | None | 0 0
  1. # author: s4bba7
  2. # ver: 1.1 (updated on 19.06.2016)
  3.  
  4. # Just paste it to .bashrc and execute `source .bashrc` or restart OS ;)
  5. # Of course you may change aliases as you like.
  6.  
  7. alias apti="sudo apt install"
  8. alias apta="sudo apt-get autoremove"
  9. alias aptr="sudo apt remove --auto-remove"
  10. alias apts="sudo apt search"
  11. alias aptu="sudo apt update && sudo apt upgrade"
  12.  
  13. getAptCache() {
  14.     mapfile -t COMPREPLY < <(apt-cache --no-generate pkgnames "$2");
  15. }
  16.  
  17. getInstalledPackages() {
  18.     mapfile -t COMPREPLY < <(dpkg --get-selections | grep -v deinstall | cut -f 1 | grep "$2");
  19. }
  20.  
  21. complete -F getAptCache apti
  22. complete -F getInstalledPackages aptr
  23. complete -F getAptCache apts
Advertisement
Add Comment
Please, Sign In to add comment