my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.6 KiB

3 years ago
  1. (( $+commands[apt] )) && APT=apt || APT=apt-get
  2. alias acs='apt-cache search'
  3. alias afs='apt-file search --regexp'
  4. # These are apt/apt-get only
  5. alias ags="$APT source"
  6. alias acp='apt-cache policy'
  7. #List all installed packages
  8. alias agli='apt list --installed'
  9. # List available updates only
  10. alias aglu='apt list --upgradable'
  11. alias acsp='apt-cache showpkg'
  12. compdef _acsp acsp='apt-cache showpkg'
  13. # superuser operations ######################################################
  14. alias afu='sudo apt-file update'
  15. alias ppap='sudo ppa-purge'
  16. alias age="sudo $APT"
  17. alias aga="sudo $APT autoclean"
  18. alias agb="sudo $APT build-dep"
  19. alias agc="sudo $APT clean"
  20. alias agd="sudo $APT dselect-upgrade"
  21. alias agi="sudo $APT install"
  22. alias agp="sudo $APT purge"
  23. alias agr="sudo $APT remove"
  24. alias agu="sudo $APT update"
  25. alias agud="sudo $APT update && sudo $APT dist-upgrade"
  26. alias agug="sudo $APT upgrade"
  27. alias aguu="sudo $APT update && sudo $APT upgrade"
  28. alias agar="sudo $APT autoremove"
  29. # Remove ALL kernel images and headers EXCEPT the one in use
  30. alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n`uname -r`))'
  31. # Misc. #####################################################################
  32. # print all installed packages
  33. alias allpkgs='dpkg --get-selections | grep -v deinstall'
  34. # Create a basic .deb package
  35. alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
  36. # apt-add-repository with automatic install/upgrade of the desired package
  37. # Usage: aar ppa:xxxxxx/xxxxxx [packagename]
  38. # If packagename is not given as 2nd argument the function will ask for it and guess the default by taking
  39. # the part after the / from the ppa name which is sometimes the right name for the package you want to install
  40. function aar() {
  41. if [ -n "$2" ]; then
  42. PACKAGE=$2
  43. else
  44. read "PACKAGE?Type in the package name to install/upgrade with this ppa [${1##*/}]: "
  45. fi
  46. if [ -z "$PACKAGE" ]; then
  47. PACKAGE=${1##*/}
  48. fi
  49. sudo apt-add-repository $1 && sudo $APT update
  50. sudo $APT install $PACKAGE
  51. }
  52. # Prints apt history
  53. # Usage:
  54. # apt-history install
  55. # apt-history upgrade
  56. # apt-history remove
  57. # apt-history rollback
  58. # apt-history list
  59. # Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
  60. function apt-history() {
  61. case "$1" in
  62. install)
  63. zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
  64. ;;
  65. upgrade|remove)
  66. zgrep --no-filename $1 $(ls -rt /var/log/dpkg*)
  67. ;;
  68. rollback)
  69. zgrep --no-filename upgrade $(ls -rt /var/log/dpkg*) | \
  70. grep "$2" -A10000000 | \
  71. grep "$3" -B10000000 | \
  72. awk '{print $4"="$5}'
  73. ;;
  74. list)
  75. zgrep --no-filename '' $(ls -rt /var/log/dpkg*)
  76. ;;
  77. *)
  78. echo "Parameters:"
  79. echo " install - Lists all packages that have been installed."
  80. echo " upgrade - Lists all packages that have been upgraded."
  81. echo " remove - Lists all packages that have been removed."
  82. echo " rollback - Lists rollback information."
  83. echo " list - Lists all contains of dpkg logs."
  84. ;;
  85. esac
  86. }
  87. # Kernel-package building shortcut
  88. function kerndeb() {
  89. # temporarily unset MAKEFLAGS ( '-j3' will fail )
  90. MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
  91. print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
  92. appendage='-custom' # this shows up in $(uname -r)
  93. revision=$(date +"%Y%m%d") # this shows up in the .deb file name
  94. make-kpkg clean
  95. time fakeroot make-kpkg --append-to-version "$appendage" --revision \
  96. "$revision" kernel_image kernel_headers
  97. }
  98. # List packages by size
  99. function apt-list-packages {
  100. dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
  101. grep -v deinstall | \
  102. sort -n | \
  103. awk '{print $1" "$2}'
  104. }