my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.4 KiB

3 years ago
  1. # https://github.com/dbbolton
  2. #
  3. # Below are some useful Perl-related aliases/functions that I use with zsh.
  4. # Aliases ###################################################################
  5. # perlbrew ########
  6. alias pbi='perlbrew install'
  7. alias pbl='perlbrew list'
  8. alias pbo='perlbrew off'
  9. alias pbs='perlbrew switch'
  10. alias pbu='perlbrew use'
  11. # Perl ############
  12. # perldoc`
  13. alias pd='perldoc'
  14. # use perl like awk/sed
  15. alias ple='perl -wlne'
  16. # show the latest stable release of Perl
  17. alias latest-perl='curl -s https://www.perl.org/get.html | perl -wlne '\''if (/perl\-([\d\.]+)\.tar\.gz/) { print $1; exit;}'\'
  18. # Functions #################################################################
  19. # newpl - creates a basic Perl script file and opens it with $EDITOR
  20. newpl () {
  21. # set $EDITOR to 'vim' if it is undefined
  22. [[ -z $EDITOR ]] && EDITOR=vim
  23. # if the file exists, just open it
  24. [[ -e $1 ]] && print "$1 exists; not modifying.\n" && $EDITOR $1
  25. # if it doesn't, make it, and open it
  26. [[ ! -e $1 ]] && print '#!/usr/bin/perl'"\n"'use strict;'"\n"'use warnings;'\
  27. "\n\n" > $1 && $EDITOR $1
  28. }
  29. # pgs - Perl Global Substitution
  30. # find pattern = 1st arg
  31. # replace pattern = 2nd arg
  32. # filename = 3rd arg
  33. pgs() { # [find] [replace] [filename]
  34. perl -i.orig -pe 's/'"$1"'/'"$2"'/g' "$3"
  35. }
  36. # Perl grep, because 'grep -P' is terrible. Lets you work with pipes or files.
  37. prep() { # [pattern] [filename unless STDOUT]
  38. perl -nle 'print if /'"$1"'/;' $2
  39. }