This repository has been archived on 2022-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
prezto/plugins/perl/perl.plugin.zsh

37 lines
660 B
Bash
Raw Normal View History

2011-08-28 15:28:09 -04:00
# Aliases
2011-03-14 01:43:33 -04: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 15:28:09 -04:00
alias pd='perldoc'
2011-03-14 01:43:33 -04:00
2011-08-28 15:28:09 -04:00
# Perl Global Substitution
function pgs() {
if (( $# < 2 )) ; then
echo "Usage: $0 find replace [file ...]" >&2
return 1
fi
2011-03-14 01:43:33 -04:00
2011-08-28 15:28:09 -04:00
local find="$1"
local replace="$2"
repeat 2 shift
2011-03-14 01:43:33 -04:00
2011-08-28 15:28:09 -04:00
perl -i.orig -pe 's/'"$find"'/'"$replace"'/g' "$@"
2011-03-14 01:43:33 -04:00
}
2011-08-28 15:28:09 -04: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 01:43:33 -04:00
2011-08-28 15:28:09 -04:00
local pattern="$1"
shift
2011-03-14 01:43:33 -04:00
2011-08-28 15:28:09 -04:00
perl -nle 'print if /'"$pattern"'/;' "$@"
2011-03-14 01:43:33 -04:00
}