prezto_config/plugins/perl/perl.plugin.zsh

37 lines
660 B
Bash
Raw Normal View History

2011-08-28 21:28:09 +02:00
# Aliases
2011-03-14 06:43:33 +01:00
alias pbi='perlbrew install'
alias pbl='perlbrew list'
alias pbo='perlbrew off'
alias pbs='perlbrew switch'
alias pbu='perlbrew use'
alias ple='perl -wlne'
2011-08-28 21:28:09 +02:00
alias pd='perldoc'
2011-03-14 06:43:33 +01:00
2011-08-28 21:28:09 +02:00
# Perl Global Substitution
function pgs() {
if (( $# < 2 )) ; then
echo "Usage: $0 find replace [file ...]" >&2
return 1
fi
2011-03-14 06:43:33 +01:00
2011-08-28 21:28:09 +02:00
local find="$1"
local replace="$2"
repeat 2 shift
2011-03-14 06:43:33 +01:00
2011-08-28 21:28:09 +02:00
perl -i.orig -pe 's/'"$find"'/'"$replace"'/g' "$@"
2011-03-14 06:43:33 +01:00
}
2011-08-28 21:28:09 +02:00
# Perl grep since 'grep -P' is terrible.
function prep() {
if (( $# < 1 )) ; then
echo "Usage: $0 pattern [file ...]" >&2
return 1
fi
2011-03-14 06:43:33 +01:00
2011-08-28 21:28:09 +02:00
local pattern="$1"
shift
2011-03-14 06:43:33 +01:00
2011-08-28 21:28:09 +02:00
perl -nle 'print if /'"$pattern"'/;' "$@"
2011-03-14 06:43:33 +01:00
}