Browse code

Merge branch 'master' of https://github.com/dbbolton/oh-my-zsh into dbbolton-master

Robby Russell authored on 16/03/2011 at 14:59:18
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,60 @@
0
+# https://github.com/dbbolton/
1
+#
2
+# Debian-related zsh aliases and functions for zsh
3
+
4
+
5
+# Aliases ###################################################################
6
+
7
+# Some self-explanatory aliases
8
+alias afs='apt-file search --regexp'
9
+alias aps='aptitude search'
10
+alias apsrc='apt-get source'
11
+alias apv='apt-cache policy'
12
+
13
+alias apdg='su -c "aptitude update && aptitude safe-upgrade"'
14
+alias apud='su -c "aptitude update"'
15
+alias apug='su -c "aptitude safe-upgrade"'
16
+
17
+# print all installed packages
18
+alias allpkgs='aptitude search -F "%p" --disable-columns ~i'
19
+
20
+# Install all .deb files in the current directory.
21
+# Warning: you will need to put the glob in single quotes if you use:
22
+# glob_subst
23
+alias di='su -c "dpkg -i ./*.deb"'
24
+
25
+# Create a basic .deb package
26
+alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
27
+
28
+# Remove ALL kernel images and headers EXCEPT the one in use
29
+alias kclean='su -c '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n`uname -r`))'\'' root'
30
+
31
+
32
+
33
+# Functions #################################################################
34
+
35
+# create a simple script that can be used to 'duplicate' a system
36
+apt-copy() {
37
+	print '#!/bin/sh'"\n" > apt-copy.sh
38
+
39
+	list=$(perl -m'AptPkg::Cache' -e '$c=AptPkg::Cache->new; for (keys %$c){ push @a, $_ if $c->{$_}->{'CurrentState'} eq 'Installed';} print "$_ " for sort @a;')
40
+
41
+	print 'aptitude install '"$list\n" >> apt-copy.sh
42
+
43
+	chmod +x apt-copy.sh
44
+}
45
+
46
+
47
+# Kernel-package building shortcut
48
+dbb-build () {
49
+	MAKEFLAGS=''		# temporarily unset MAKEFLAGS ( '-j3' will fail )
50
+	appendage='-custom' # this shows up in $ (uname -r )
51
+    revision=$(date +"%Y%m%d") # this shows up in the .deb file name
52
+
53
+    make-kpkg clean
54
+
55
+    time fakeroot make-kpkg --append-to-version "$appendage" --revision \
56
+        "$revision" kernel_image kernel_headers
57
+}
58
+
59
+
0 60
new file mode 100644
... ...
@@ -0,0 +1,62 @@
0
+# https://github.com/dbbolton
1
+#
2
+# Below are some useful Perl-related aliases/functions that I use with zsh.
3
+
4
+
5
+# Aliases ###################################################################
6
+
7
+# perlbrew ########
8
+alias pbi='perlbrew install'
9
+alias pbl='perlbrew list'
10
+alias pbo='perlbrew off'
11
+alias pbs='perlbrew switch'
12
+alias pbu='perlbrew use'
13
+
14
+# Perl ############
15
+
16
+# perldoc`
17
+alias pd='perldoc'
18
+
19
+# use perl like awk/sed
20
+alias ple='perl -wlne'
21
+
22
+# show the latest stable release of Perl
23
+alias latest-perl='curl -s http://www.perl.org/get.html | perl -wlne '\''if (/perl\-([\d\.]+)\.tar\.gz/) { print $1; exit;}'\'
24
+
25
+
26
+
27
+# Functions #################################################################
28
+
29
+# newpl - creates a basic Perl script file and opens it with $EDITOR 
30
+newpl () {
31
+	# set $EDITOR to 'vim' if it is undefined
32
+	[[ -z $EDITOR ]] && EDITOR=vim
33
+
34
+	# if the file exists, just open it
35
+	[[ -e $1 ]] && print "$1 exists; not modifying.\n" && $EDITOR $1
36
+
37
+	# if it doesn't, make it, and open it
38
+	[[ ! -e $1 ]] && print '#!/usr/bin/perl'"\n"'use strict;'"\n"'use warnings;'\
39
+		"\n\n" > $1 && $EDITOR $1
40
+}
41
+
42
+
43
+# pgs - Perl Global Substitution
44
+# find pattern		= 1st arg
45
+# replace pattern	= 2nd arg
46
+# filename			= 3rd arg
47
+pgs() { # [find] [replace] [filename]
48
+    perl -i.orig -pe 's/'"$1"'/'"$2"'/g' "$3"
49
+}
50
+
51
+
52
+# Perl grep, because 'grep -P' is terrible. Lets you work with pipes or files.
53
+prep() { # [pattern] [filename unless STDOUT]
54
+    perl -nle 'print if /'"$1"'/;' $2
55
+}
56
+
57
+# say - append a newline to 'print'
58
+say() {
59
+    print "$1\n"
60
+}
61
+