#k# Delete current word
bindkey "3~" delete-word
+## use Ctrl-left-arrow and Ctrl-right-arrow for jumping to word-beginnings on the CL
+bindkey "\e[5C" forward-word
+bindkey "\e[5D" backward-word
+bindkey "\e[1;5C" forward-word
+bindkey "\e[1;5D" backward-word
+## the same for alt-left-arrow and alt-right-arrow
+bindkey '^[[1;3C' forward-word
+bindkey '^[[1;3D' backward-word
+
bindkey '^xp' history-beginning-search-backward
bindkey '^xP' history-beginning-search-forward
bindkey "\e[5~" history-beginning-search-backward #PageUp
#k# complete word from history with menu
bindkey "^X^X" hist-complete
+## complete word from currently visible SCREEN buffer.
+if check_com -c screen ; then
+ _complete_screen_display() {
+ [[ "$TERM" != "screen" ]] && return 1
+
+ local TMPFILE=$(mktemp)
+ local -U -a _screen_display_wordlist
+ trap "rm -f $TMPFILE" EXIT
+
+ screen -X hardcopy $TMPFILE
+ # fill array with contents from screen hardcopy
+ _screen_display_wordlist=( ${(QQ)$(<$TMPFILE)} )
+ # remove PREFIX to be completed from that array
+ _screen_display_wordlist[${_screen_display_wordlist[(i)$PREFIX]}]=""
+ compadd -a _screen_display_wordlist
+ }
+ #k# complete word from currently visible GNU screen buffer
+ bindkey -r "^XS"
+ compdef -k _complete_screen_display complete-word '^XS'
+fi
+
# }}}
# {{{ history
#f5# Clean up directory - remove well known tempfiles
purge() {
- FILES=(*~(N) .*~(N) \#*\#(N) *.o(N) a.out(N) *.core(N) *.cmo(N) *.cmi(N) .*.swp(N))
- NBFILES=${#FILES}
+ emulate -L zsh
+ setopt HIST_SUBST_PATTERN
+ local -a TEXTEMPFILES GHCTEMPFILES PYTEMPFILES FILES
+ TEXTEMPFILES=(*.tex(N:s/%tex/'(log|toc|aux|nav|snm|out|tex.backup|bbl|blg|bib.backup|vrb|lof|lot|hd|idx)(N)'/))
+ GHCTEMPFILES=(*.(hs|lhs)(N:r:s/%/'.(hi|hc|(p|u|s)_(o|hi))(N)'/))
+ PYTEMPFILES=(*.py(N:s/%py/'(pyc|pyo)(N)'/))
+ LONELY_MOOD_FILES=((*.mood)(NDe:'local -a AF;AF=( ${${REPLY#.}%mood}(mp3|flac|ogg|asf|wmv|aac)(N) ); [[ -z "$AF" ]]':))
+ FILES=(*~(.N) \#*\#(.N) *.o(.N) a.out(.N) (*.|)core(.N) *.cmo(.N) *.cmi(.N) .*.swp(.N) *.(orig|rej)(.DN) *.dpkg-(old|dist|new)(DN) ._(cfg|mrg)[0-9][0-9][0-9][0-9]_*(N) ${~TEXTEMPFILES} ${~GHCTEMPFILES} ${~PYTEMPFILES} ${LONELY_MOOD_FILES})
+ local NBFILES=${#FILES}
+ local CURDIRSUDO=""
+ [[ ! -w ./ ]] && CURDIRSUDO=$SUDO
if [[ $NBFILES > 0 ]] ; then
- print $FILES
+ print -l $FILES
local ans
echo -n "Remove these files? [y/n] "
read -q ans
if [[ $ans == "y" ]] ; then
- rm ${FILES}
+ $CURDIRSUDO rm ${FILES}
echo ">> $PWD purged, $NBFILES files removed"
else
echo "Ok. .. then not.."
}
fi
+#f5# run command or function in a list of directories
+rundirs() {
+ local d CMD STARTDIR=$PWD
+ CMD=$1; shift
+ ( for d ($@) {cd -q $d && { print cd $d; ${(z)CMD} ; cd -q $STARTDIR }} )
+}
+
# Translate DE<=>EN
# 'translate' looks up fot a word in a file with language-to-language
# translations (field separator should be " : "). A typical wordlist looks
autoload $func
done
}
+compdef _functions refunc
# a small check to see which DIR is located on which server/partition.
# stolen and modified from Sven's zshrc.forall