debian.plugin.zsh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # https://github.com/dbbolton/
  2. #
  3. # Debian-related zsh aliases and functions for zsh
  4. # Aliases ###################################################################
  5. # Some self-explanatory aliases
  6. alias afs='apt-file search --regexp'
  7. alias aps='aptitude search'
  8. alias apsrc='apt-get source'
  9. alias apv='apt-cache policy'
  10. alias apdg='su -c "aptitude update && aptitude safe-upgrade"'
  11. alias apud='su -c "aptitude update"'
  12. alias apug='su -c "aptitude safe-upgrade"'
  13. # print all installed packages
  14. alias allpkgs='aptitude search -F "%p" --disable-columns ~i'
  15. # Install all .deb files in the current directory.
  16. # Warning: you will need to put the glob in single quotes if you use:
  17. # glob_subst
  18. alias di='su -c "dpkg -i ./*.deb"'
  19. # Create a basic .deb package
  20. alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
  21. # Remove ALL kernel images and headers EXCEPT the one in use
  22. alias kclean='su -c '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n`uname -r`))'\'' root'
  23. # Functions #################################################################
  24. # create a simple script that can be used to 'duplicate' a system
  25. apt-copy() {
  26. print '#!/bin/sh'"\n" > apt-copy.sh
  27. list=$(perl -m'AptPkg::Cache' -e '$c=AptPkg::Cache->new; for (keys %$c){ push @a, $_ if $c->{$_}->{'CurrentState'} eq 'Installed';} print "$_ " for sort @a;')
  28. print 'aptitude install '"$list\n" >> apt-copy.sh
  29. chmod +x apt-copy.sh
  30. }
  31. # Kernel-package building shortcut
  32. dbb-build () {
  33. MAKEFLAGS='' # temporarily unset MAKEFLAGS ( '-j3' will fail )
  34. appendage='-custom' # this shows up in $ (uname -r )
  35. revision=$(date +"%Y%m%d") # this shows up in the .deb file name
  36. make-kpkg clean
  37. time fakeroot make-kpkg --append-to-version "$appendage" --revision \
  38. "$revision" kernel_image kernel_headers
  39. }