Skip to content

Instantly share code, notes, and snippets.

@trapd00r
Created September 14, 2011 05:28
Show Gist options
  • Save trapd00r/1215916 to your computer and use it in GitHub Desktop.
Save trapd00r/1215916 to your computer and use it in GitHub Desktop.
#!/usr/bin/zsh
typeset -Ag abbreviations
abbreviations=(
"pinc" "/usr/{lib,share}/perl5/{core,site,vendor}_perl/"
"Paralel" "Parallel"
"Paralell" "Parallel"
"Para::Fork" "Parallel::ForkManager"
"D::D" "Data::Dumper"
"jj" "!$"
"jk" "!-2$"
"Im" "| more"
"Ia" "| awk"
"Ig" "| grep"
"Ieg" "| egrep"
"Iag" "| agrep"
"Igr" "| groff -s -p -t -e -Tlatin1 -mandoc"
"Ip" "| $PAGER"
"Ih" "| head"
"Ik" "| keep"
"It" "| tail"
"Is" "| sort"
"Iv" "| ${VISUAL:-${EDITOR}}"
"Iw" "| wc"
"Ix" "| xargs"
)
magic-abbrev-expand() {
local MATCH
LBUFFER=${LBUFFER%%(#m)[_a-zA-Z0-9]#}
LBUFFER+=${abbreviations[$MATCH]:-$MATCH}
zle self-insert
}
no-magic-abbrev-expand() {
LBUFFER+=' '
}
zle -N magic-abbrev-expand
zle -N no-magic-abbrev-expand
bindkey " " magic-abbrev-expand
bindkey "^x " no-magic-abbrev-expand
# vim: set ts=2 expandtab sw=2:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment