aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--_zsh/10-param.zsh13
-rw-r--r--_zsh/10-setopt.zsh8
-rw-r--r--_zsh/40-functions.zsh57
-rw-r--r--_zsh/70-history.zsh4
4 files changed, 63 insertions, 19 deletions
diff --git a/_zsh/10-param.zsh b/_zsh/10-param.zsh
new file mode 100644
index 0000000..99f0942
--- /dev/null
+++ b/_zsh/10-param.zsh
@@ -0,0 +1,13 @@
+#
+# zsh/param.zsh
+# see zshparam(1)
+#
+
+# Ask only if the top of the listing would scroll off the screen
+LISTMAX=0
+
+# Report consuming time statistics if user+system greater than 60 seconds
+REPORTTIME=60
+
+# Format of process time reports with the `time' keyword
+TIMEFMT="%J %U user %S system %P cpu %MM memory %*E total"
diff --git a/_zsh/10-setopt.zsh b/_zsh/10-setopt.zsh
index c415dc3..8d95b41 100644
--- a/_zsh/10-setopt.zsh
+++ b/_zsh/10-setopt.zsh
@@ -1,6 +1,6 @@
#
# zsh/setopt.zsh
-# see man zshoptions(1)
+# see zshoptions(1)
#
## Basics
@@ -20,6 +20,8 @@ setopt EXTENDED_GLOB
setopt INTERACTIVE_COMMENTS
# display PID when suspending processes as well
setopt LONG_LIST_JOBS
+# disable output flow control via start/stop characters (^S/^Q)
+unsetopt FLOW_CONTROL
## History
# allow multiple terminal sessions to all append to one zsh command history
@@ -41,7 +43,7 @@ setopt HIST_VERIFY
## Completion
-# * shouldn't match dotfiles. ever.
+# `*' shouldn't match dotfiles. ever.
setopt NO_GLOB_DOTS
# allow completion from within a word/phrase
setopt COMPLETE_IN_WORD
@@ -50,6 +52,8 @@ setopt ALWAYS_TO_END
# show completion menu on successive tab press (needs 'unsetopt MENU_COMPLETE')
setopt AUTO_MENU
unsetopt MENU_COMPLETE
+# make the completion list compact
+setopt LIST_PACKED
## Correction
# spelling correction for commands
diff --git a/_zsh/40-functions.zsh b/_zsh/40-functions.zsh
index 2b078ed..2a15058 100644
--- a/_zsh/40-functions.zsh
+++ b/_zsh/40-functions.zsh
@@ -13,17 +13,20 @@ function exists() {
type "$1" >/dev/null 2>&1
}
+
## Check whether the program is running
function is_running() {
- pgrep -x -u "${USER}" $1 &> /dev/null
+ pgrep -x -u "${USER}" "$1" /dev/null 2>&1
}
+
function zsh_recompile() {
autoload -U zrecompile
rm -f ~/.zsh/*.zwc
[[ -f ~/.zshrc ]] && zrecompile -p ~/.zshrc
[[ -f ~/.zshrc.zwc.old ]] && rm -f ~/.zshrc.zwc.old
+ local f
for f in ~/.zsh/**/*.zsh; do
[[ -f $f ]] && zrecompile -p $f
[[ -f $f.zwc.old ]] && rm -f $f.zwc.old
@@ -37,7 +40,7 @@ function zsh_recompile() {
function extract() {
- echo Extracting $1 ...
+ echo "Extracting '$1' ..."
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2)
@@ -63,10 +66,10 @@ function extract() {
*.7z)
7z x "$1";;
*)
- echo "'$1' cannot be extracted via extract()" ;;
+ echo "Unable to extract: '$1'" ;;
esac
else
- echo "'$1' is not a valid file"
+ echo "Invalid file: '$1'"
fi
}
@@ -89,21 +92,45 @@ function trash() {
}
-function strip_diff_leading_symbols() {
- local color_code_regex="(\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K])"
+## Print a horizontal rule
+function rule() {
+ printf "%$(tput cols)s\n" | tr ' ' '-'
+}
+
+
+## Interactive move/rename: making renaming long filenames less sucks
+# Credit: http://chneukirchen.org/dotfiles/.zshrc
+function imv() {
+ local src dst
+ for src; do
+ [[ -e "$src" ]] || { print -u2 "$src: does not exist"; continue }
+ dst="$src"
+ vared dst
+ [[ "$src" != "$dst" ]] && mkdir -p ${dst:h} && mv -n $src $dst
+ done
+}
+
- # simplify the unified patch diff header
- sed -r "s/^($color_code_regex)diff --git .*$//g" | \
- sed -r "s/^($color_code_regex)index .*$/\n\1$(rule)/g" | \
- sed -r "s/^($color_code_regex)\+\+\+(.*)$/\1+++\5\n\1$(rule)\x1B\[m/g" |\
- # actually strips the leading symbols
- sed -r "s/^($color_code_regex)[\+\-]/\1 /g"
+## Print pre-defined C macros
+# Credit: http://chneukirchen.org/dotfiles/.zshrc
+ccdef() {
+ ${1:-cc} $@[2,-1] -dM -E - </dev/null
}
-## Print a horizontal rule
-function rule() {
- printf "%$(tput cols)s\n" | tr ' ' '-'
+## Run up to N CMD in parallel with ARGS
+# zapply [-jN] [-iv] CMD... -- ARGS...
+# CMD will be run as zsh command if it contains a $
+# without explicit '--', assume CMD is first argument
+# {} (or $1) may be used to access argument
+# Credit: http://chneukirchen.org/dotfiles/.zshrc
+zapply() {
+ local s="$@[(i)--]" xopt=
+ (( s > $# )) && argv[2]=(-- "$argv[2]") && s=2
+ zparseopts -D -M -A xopt n: p t P: j:=P v=t i=p # map to xargs(1) flags
+ (( $@[(i){}] < s )) && xopt[-I]={}
+ [[ $1 = *'$'* ]] && argv[1]=(zsh -c "$1" --) && (( s += 3 ))
+ printf '%s\0' "$@[s+1,-1]" | xargs -0 -r -n1 ${(kv)=xopt} "$@[1,s-1]"
}
# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=zsh: #
diff --git a/_zsh/70-history.zsh b/_zsh/70-history.zsh
index efbdb5f..1d294f6 100644
--- a/_zsh/70-history.zsh
+++ b/_zsh/70-history.zsh
@@ -1,10 +1,10 @@
#
# zsh/history.zsh
+# see zshparam(1)
#
HISTFILE=~/.zsh_history
-
-HISTSIZE=10000
+HISTSIZE=9000
SAVEHIST=9000
# ignore these commands without arguments
HISTIGNORE="cd:ls:ll"