init
This commit is contained in:
11
.zprezto/modules/utility/functions/_cdls_popdls_pushdls
Normal file
11
.zprezto/modules/utility/functions/_cdls_popdls_pushdls
Normal file
@@ -0,0 +1,11 @@
|
||||
#compdef cdls popdls pushdls
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes cdls, popdls, and pushdls.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_cd
|
11
.zprezto/modules/utility/functions/_dut
Normal file
11
.zprezto/modules/utility/functions/_dut
Normal file
@@ -0,0 +1,11 @@
|
||||
#compdef dut
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes dut.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_du
|
13
.zprezto/modules/utility/functions/_mkdcd
Normal file
13
.zprezto/modules/utility/functions/_mkdcd
Normal file
@@ -0,0 +1,13 @@
|
||||
#compdef mkdcd
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes mkdcd.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local expl
|
||||
|
||||
_wanted directories expl 'directory' _path_files -/ || _message 'directory'
|
18
.zprezto/modules/utility/functions/_prep
Normal file
18
.zprezto/modules/utility/functions/_prep
Normal file
@@ -0,0 +1,18 @@
|
||||
#compdef prep
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes prep.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments \
|
||||
'-i[ignore case]' \
|
||||
'-m[^ and $ match the start and the end of a line]' \
|
||||
'-s[. matches newline]' \
|
||||
'-v[invert match]' \
|
||||
'-x[ignore whitespace and comments]' \
|
||||
'1::pattern:' \
|
||||
'2::files:_files' && return 0
|
19
.zprezto/modules/utility/functions/_psub
Normal file
19
.zprezto/modules/utility/functions/_psub
Normal file
@@ -0,0 +1,19 @@
|
||||
#compdef psub
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes psub.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments \
|
||||
'-g[match globally]' \
|
||||
'-i[ignore case]' \
|
||||
'-m[^ and $ match the start and the end of a line]' \
|
||||
'-s[. matches newline]' \
|
||||
'-x[ignore whitespace and comments]' \
|
||||
'1::pattern:' \
|
||||
'2::replacement:' \
|
||||
'3::files:_files' && return 0
|
22
.zprezto/modules/utility/functions/diff
Normal file
22
.zprezto/modules/utility/functions/diff
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Highlights diff output.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function diff {
|
||||
if zstyle -t ':prezto:module:utility:diff' color; then
|
||||
if (( $+commands[colordiff] )); then
|
||||
command diff --unified "$@" | colordiff --difftype diffu
|
||||
elif (( $+commands[git] )); then
|
||||
git --no-pager diff --color=auto --no-ext-diff --no-index "$@"
|
||||
else
|
||||
command diff --unified "$@"
|
||||
fi
|
||||
else
|
||||
command diff --unified "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
diff "$@"
|
27
.zprezto/modules/utility/functions/dut
Normal file
27
.zprezto/modules/utility/functions/dut
Normal file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Displays the grand total disk usage using human readable units.
|
||||
#
|
||||
# Authors:
|
||||
# Suraj N. Kurapati <sunaku@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function dut {
|
||||
(( $# == 0 )) && set -- *
|
||||
|
||||
if grep -q -i 'GNU' < <(du --version 2>&1); then
|
||||
du -khsc "$@" | sort -h -r
|
||||
else
|
||||
local line size name
|
||||
local -a record
|
||||
|
||||
while IFS=$'\n' read line; do
|
||||
record=(${(z)line})
|
||||
size="$(($record[1] / 1024.0))"
|
||||
name="$record[2,-1]"
|
||||
printf "%9.1LfM %s\n" "$size" "$name"
|
||||
done < <(du -kcs "$@") | sort -n -r
|
||||
fi
|
||||
}
|
||||
|
||||
dut "$@"
|
20
.zprezto/modules/utility/functions/make
Normal file
20
.zprezto/modules/utility/functions/make
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# Highlights make output.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function make {
|
||||
if zstyle -t ':prezto:module:utility:make' color; then
|
||||
if (( $+commands[colormake] )); then
|
||||
colormake "$@"
|
||||
else
|
||||
command make "$@"
|
||||
fi
|
||||
else
|
||||
command make "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
make "$@"
|
52
.zprezto/modules/utility/functions/prep
Normal file
52
.zprezto/modules/utility/functions/prep
Normal file
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# Provides a grep-like pattern search.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local usage pattern modifiers invert
|
||||
|
||||
usage="$(
|
||||
cat <<EOF
|
||||
usage: $0 [-option ...] [--] pattern [file ...]
|
||||
|
||||
options:
|
||||
-i ignore case
|
||||
-m ^ and $ match the start and the end of a line
|
||||
-s . matches newline
|
||||
-v invert match
|
||||
-x ignore whitespace and comments
|
||||
EOF
|
||||
)"
|
||||
|
||||
while getopts ':imsxv' opt; do
|
||||
case "$opt" in
|
||||
(i) modifiers="${modifiers}i" ;;
|
||||
(m) modifiers="${modifiers}m" ;;
|
||||
(s) modifiers="${modifiers}s" ;;
|
||||
(x) modifiers="${modifiers}x" ;;
|
||||
(v) invert="yes" ;;
|
||||
(:)
|
||||
print "$0: option requires an argument: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
([?])
|
||||
print "$0: unknown option: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
if (( $# < 1 )); then
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
pattern="$1"
|
||||
shift
|
||||
|
||||
perl -n -l -e "print if ${invert:+not} m/${pattern//\//\\/}/${modifiers}" "$@"
|
53
.zprezto/modules/utility/functions/psub
Normal file
53
.zprezto/modules/utility/functions/psub
Normal file
@@ -0,0 +1,53 @@
|
||||
#
|
||||
# Provides a sed-like pattern substitution.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local usage pattern replacement modifiers
|
||||
|
||||
usage="$(
|
||||
cat <<EOF
|
||||
usage: $0 [-option ...] [--] pattern replacement [file ...]
|
||||
|
||||
options:
|
||||
-g match globally
|
||||
-i ignore case
|
||||
-m ^ and $ match the start and the end of a line
|
||||
-s . matches newline
|
||||
-x ignore whitespace and comments
|
||||
EOF
|
||||
)"
|
||||
|
||||
while getopts ':gimsx' opt; do
|
||||
case "$opt" in
|
||||
(g) modifiers="${modifiers}g" ;;
|
||||
(i) modifiers="${modifiers}i" ;;
|
||||
(m) modifiers="${modifiers}m" ;;
|
||||
(s) modifiers="${sodifiers}s" ;;
|
||||
(x) modifiers="${modifiers}x" ;;
|
||||
(:)
|
||||
print "$0: option requires an argument: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
([?])
|
||||
print "$0: unknown option: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
if (( $# < 2 )); then
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
pattern="$1"
|
||||
replacement="$2"
|
||||
repeat 2 shift
|
||||
|
||||
perl -i'.orig' -n -l -e "s/${pattern//\//\\/}/${replacement//\//\\/}/${modifiers}; print" "$@"
|
29
.zprezto/modules/utility/functions/wdiff
Normal file
29
.zprezto/modules/utility/functions/wdiff
Normal file
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# Highlights wdiff output.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function wdiff {
|
||||
if zstyle -t ':prezto:module:utility:wdiff' color; then
|
||||
if (( $+commands[wdiff] )); then
|
||||
command wdiff \
|
||||
--avoid-wraps \
|
||||
--start-delete="$(print -n $FG[red])" \
|
||||
--end-delete="$(print -n $FG[none])" \
|
||||
--start-insert="$(print -n $FG[green])" \
|
||||
--end-insert="$(print -n $FG[none])" \
|
||||
"$@" \
|
||||
| sed 's/^\(@@\( [+-][[:digit:]]*,[[:digit:]]*\)\{2\} @@\)$/;5;6m\10m/g'
|
||||
elif (( $+commands[git] )); then
|
||||
git --no-pager diff --color=auto --no-ext-diff --no-index --color-words "$@"
|
||||
else
|
||||
command wdiff "$@"
|
||||
fi
|
||||
else
|
||||
command wdiff "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
wdiff "$@"
|
Reference in New Issue
Block a user