5bbd87a33380ab4fb9cab6688b11cb98faa61cd7

Author
Daniel Bolton <danielbarrettbolton@gmail.com>
Committer
Daniel Bolton <danielbarrettbolton@gmail.com>
Date

Message

add Perl plugins file

Diff

 1diff --git a/plugins/perl/perl.plugin.zsh b/plugins/perl/perl.plugin.zsh
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..f94c4195dcecb2d0c15e5baa6a651731212405ad
 4--- /dev/null
 5+++ b/plugins/perl/perl.plugin.zsh
 6@@ -0,0 +1,62 @@
 7+# https://github.com/dbbolton
 8+#
 9+# Below are some useful Perl-related aliases/functions that I use with zsh.
10+
11+
12+# Aliases ###################################################################
13+
14+# perlbrew ########
15+alias pbi='perlbrew install'
16+alias pbl='perlbrew list'
17+alias pbo='perlbrew off'
18+alias pbs='perlbrew switch'
19+alias pbu='perlbrew use'
20+
21+# Perl ############
22+
23+# perldoc`
24+alias pd='perldoc'
25+
26+# use perl like awk/sed
27+alias ple='perl -wlne'
28+
29+# show the latest stable release of Perl
30+alias latest-perl='curl -s http://www.perl.org/get.html | perl -wlne '\''if (/perl\-([\d\.]+)\.tar\.gz/) { print $1; exit;}'\'
31+
32+
33+
34+# Functions #################################################################
35+
36+# newpl - creates a basic Perl script file and opens it with $EDITOR 
37+newpl () {
38+	# set $EDITOR to 'vim' if it is undefined
39+	[[ -z $EDITOR ]] && EDITOR=vim
40+
41+	# if the file exists, just open it
42+	[[ -e $1 ]] && print "$1 exists; not modifying.\n" && $EDITOR $1
43+
44+	# if it doesn't, make it, and open it
45+	[[ ! -e $1 ]] && print '#!/usr/bin/perl'"\n"'use strict;'"\n"'use warnings;'\
46+		"\n\n" > $1 && $EDITOR $1
47+}
48+
49+
50+# pgs - Perl Global Substitution
51+# find pattern		= 1st arg
52+# replace pattern	= 2nd arg
53+# filename			= 3rd arg
54+pgs() { # [find] [replace] [filename]
55+    perl -i.orig -pe 's/'"$1"'/'"$2"'/g' "$3"
56+}
57+
58+
59+# Perl grep, because 'grep -P' is terrible. Lets you work with pipes or files.
60+prep() { # [pattern] [filename unless STDOUT]
61+    perl -nle 'print if /'"$1"'/;' $2
62+}
63+
64+# say - append a newline to 'print'
65+say() {
66+    print "$1\n"
67+}
68+