debian.plugin.zsh 2.61 KB
Newer Older
1
# https://github.com/dbb/
Daniel Bolton's avatar
Daniel Bolton committed
2
3
4
5
6
7
8
#
# Debian-related zsh aliases and functions for zsh


# Aliases ###################################################################

# Some self-explanatory aliases
9
alias acs="apt-cache search"
Daniel Bolton's avatar
Daniel Bolton committed
10
11
alias afs='apt-file search --regexp'
alias aps='aptitude search'
12
13
alias as="aptitude -F \"* %p -> %d \n(%v/%V)\" \
		--no-gui --disable-columns search"	# search package
Daniel Bolton's avatar
Daniel Bolton committed
14
15
16
alias apsrc='apt-get source'
alias apv='apt-cache policy'

17
# aliases that use su -c ##############
Daniel Bolton's avatar
Daniel Bolton committed
18
19
20
alias apdg='su -c "aptitude update && aptitude safe-upgrade"'
alias apud='su -c "aptitude update"'
alias apug='su -c "aptitude safe-upgrade"'
21
22
23
24
25
26
27
28
29
30
31
# 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 ###########
Daniel Bolton's avatar
Daniel Bolton committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

# 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
alias di='su -c "dpkg -i ./*.deb"'

# Create a basic .deb package
alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'

# Remove ALL kernel images and headers EXCEPT the one in use
alias kclean='su -c '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n`uname -r`))'\'' root'



# Functions #################################################################

51
52
53
54
55
56
57
# install packages without sudo
apin() {
    cmd="su -lc 'aptitude -P install $@' root"
    print "$cmd"
    eval "$cmd"
}

Daniel Bolton's avatar
Daniel Bolton committed
58
59
60
61
62
63
64
65
66
67
68
69
70
# 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
71
72
73
74
kerndeb () {
    # temporarily unset MAKEFLAGS ( '-j3' will fail )
    MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )		
    print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
Daniel Bolton's avatar
Daniel Bolton committed
75
76
77
78
79
80
81
82
83
84
	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
}