1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-23 21:46:20 +08:00
ohmyzsh/plugins/debian/debian.plugin.zsh

84 lines
2.6 KiB
Bash
Raw Normal View History

2011-08-07 03:22:55 +08:00
# https://github.com/dbb/
2011-03-16 08:31:14 +08:00
#
# Debian-related zsh aliases and functions for zsh
# Aliases ###################################################################
# Some self-explanatory aliases
2011-08-07 03:22:55 +08:00
alias acs="apt-cache search"
2011-03-16 08:31:14 +08:00
alias afs='apt-file search --regexp'
alias aps='aptitude search'
2011-08-07 03:22:55 +08:00
alias as="aptitude -F \"* %p -> %d \n(%v/%V)\" \
--no-gui --disable-columns search" # search package
2011-03-16 08:31:14 +08:00
alias apsrc='apt-get source'
alias apv='apt-cache policy'
2011-08-07 03:22:55 +08:00
# aliases that use su -c ##############
2011-08-07 03:41:52 +08:00
alias apdg='su -lc "aptitude update && aptitude safe-upgrade" root'
alias apud='su -lc "aptitude update" root'
alias apug='su -lc "aptitude safe-upgrade" root'
2011-08-07 03:22:55 +08:00
# end aliases that use su -c ##########
# aliases that use sudo ###############
alias ad="sudo apt-get update" # update packages lists
alias au="sudo apt-get update && \
sudo apt-get dselect-upgrade" # upgrade packages
alias ai="sudo apt-get install" # install package
alias ar="sudo apt-get remove --purge && \
sudo apt-get autoremove --purge" # remove package
alias ac="sudo apt-get clean && sudo apt-get autoclean" # clean apt cache
# end aliases that use sudo ###########
2011-03-16 08:31:14 +08:00
# print all installed packages
alias allpkgs='aptitude search -F "%p" --disable-columns ~i'
# Install all .deb files in the current directory.
# Warning: you will need to put the glob in single quotes if you use:
# glob_subst
2011-08-07 03:41:52 +08:00
alias di='su -lc "dpkg -i ./*.deb" root'
2011-03-16 08:31:14 +08:00
# Create a basic .deb package
alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
# Remove ALL kernel images and headers EXCEPT the one in use
2011-08-07 03:41:52 +08:00
alias kclean='su -lc '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n`uname -r`))'\'' root'
2011-03-16 08:31:14 +08:00
# Functions #################################################################
2011-08-07 03:22:55 +08:00
# install packages without sudo
apin() {
cmd="su -lc 'aptitude -P install $@' root"
print "$cmd"
eval "$cmd"
}
2011-03-16 08:31:14 +08:00
# create a simple script that can be used to 'duplicate' a system
apt-copy() {
print '#!/bin/sh'"\n" > apt-copy.sh
list=$(perl -m'AptPkg::Cache' -e '$c=AptPkg::Cache->new; for (keys %$c){ push @a, $_ if $c->{$_}->{'CurrentState'} eq 'Installed';} print "$_ " for sort @a;')
print 'aptitude install '"$list\n" >> apt-copy.sh
chmod +x apt-copy.sh
}
# Kernel-package building shortcut
2011-08-07 03:22:55 +08:00
kerndeb () {
# temporarily unset MAKEFLAGS ( '-j3' will fail )
MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
2011-03-16 08:31:14 +08:00
appendage='-custom' # this shows up in $ (uname -r )
revision=$(date +"%Y%m%d") # this shows up in the .deb file name
make-kpkg clean
time fakeroot make-kpkg --append-to-version "$appendage" --revision \
"$revision" kernel_image kernel_headers
}