zsh: update
This commit is contained in:
@@ -10,14 +10,16 @@ git-dir-usage() {
|
||||
else
|
||||
d=$(__z_git rev-parse --path-format=absolute --git-dir)
|
||||
fi
|
||||
|
||||
case "$d" in
|
||||
*/* ) p=${d%/*} ; d=${d##*/} ;;
|
||||
*/* ) p=${d%/*} ; d=${d:t} ;;
|
||||
esac
|
||||
## ${p:+ env -C "$p" } du -cd2 "$d"
|
||||
|
||||
## ${p:+ env -C "$p" } du -d2 "$d"
|
||||
if [ -n "$p" ] ; then
|
||||
env -C "$p" du -cd2 "$d"
|
||||
env -C "$p" du -d2 "$d"
|
||||
else
|
||||
du -cd2 "$d"
|
||||
du -d2 "$d"
|
||||
fi | grep -Ev '^[0-9]\s' | sort -Vk2
|
||||
}
|
||||
|
||||
|
@@ -1,14 +1,14 @@
|
||||
#!/bin/zsh
|
||||
|
||||
gpg-warmup() {
|
||||
local t r
|
||||
|
||||
(( ${+commands[gpg]} )) || return 1
|
||||
|
||||
local t r
|
||||
|
||||
t=$(mktemp)
|
||||
command gpg -abs "$t"
|
||||
r=$?
|
||||
command rm -f "$t" "$t.asc"
|
||||
rm -f "$t" "$t.asc"
|
||||
|
||||
return "$r"
|
||||
}
|
||||
|
@@ -9,11 +9,12 @@ z-alt-grep() {
|
||||
n=${#a}
|
||||
[ -z "$1" ] && n=0
|
||||
case "$n" in
|
||||
0) ;;
|
||||
*) z-alt-set-static \
|
||||
"grep|-q -e ' ' ${ZSHU[d_conf]}/_.zsh" \
|
||||
"$1" \
|
||||
"GREP_OPTIONS='' command" \
|
||||
0 ) ;;
|
||||
* )
|
||||
z-alt-set-static \
|
||||
"grep|-q -e ' ' ${ZSHU[d_conf]}/_.zsh" \
|
||||
"$1" \
|
||||
"GREP_OPTIONS='' command" \
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@@ -25,5 +26,6 @@ z-alt-grep "grep ${GREP_GNU}|grep"
|
||||
unfunction z-alt-grep
|
||||
unset GREP_GNU
|
||||
|
||||
alias grep='grep '
|
||||
alias egrep='grep -E '
|
||||
alias fgrep='grep -F '
|
||||
|
@@ -1,16 +1,24 @@
|
||||
#!/bin/zsh
|
||||
|
||||
idle() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
local f
|
||||
|
||||
f=$(type "$1")
|
||||
case "$f" in
|
||||
"$1 is /"*) z-idle-ext "$@" ;;
|
||||
*) z-idle-int "$@" ;;
|
||||
"$1 is /"* )
|
||||
z-idle-ext "$@"
|
||||
;;
|
||||
* )
|
||||
z-idle-int "$@"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
z-idle-ext() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
local -a s
|
||||
|
||||
s+=( $(z-alt-find 'nice -n +40') )
|
||||
@@ -20,6 +28,8 @@ z-idle-ext() {
|
||||
}
|
||||
|
||||
z-idle-int() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
## execute in subshell
|
||||
(
|
||||
{
|
||||
|
@@ -1,3 +1,3 @@
|
||||
#!/bin/zsh
|
||||
|
||||
alias k=kubectl
|
||||
alias k='kubectl '
|
||||
|
@@ -1,17 +1,25 @@
|
||||
#!/bin/zsh
|
||||
|
||||
kconf-set() {
|
||||
local n v
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
n=$1 v=$2 ; shift 2
|
||||
grep -ElZ "^((CONFIG_)?$n=|# (CONFIG_)?$n is not set)" "$@" \
|
||||
local n=$1 v=$2
|
||||
shift 2
|
||||
|
||||
[ $# -gt 0 ] || return 2
|
||||
|
||||
command grep -ElZ "^((CONFIG_)?$n=|# (CONFIG_)?$n is not set)" "$@" \
|
||||
| xargs -0 -r sed -i -E -e "s/^(((CONFIG_)?$n)=.+|# ((CONFIG_)?$n) is not set)\$/\\2\\4=$v/"
|
||||
}
|
||||
|
||||
kconf-unset() {
|
||||
local n
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
n=$1 ; shift
|
||||
grep -ElZ "^(CONFIG_)?$n=" "$@" \
|
||||
local n=$1
|
||||
shift
|
||||
|
||||
[ $# -gt 0 ] || return 2
|
||||
|
||||
command grep -ElZ "^(CONFIG_)?$n=" "$@" \
|
||||
| xargs -0 -r sed -i -E -e "s/^((CONFIG_)?$n)=.+\$/# \\1 is not set/"
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ if [ -z "${LS_COLORS}" ] ; then
|
||||
fi
|
||||
|
||||
case "${ZSHU[os_family]}" in
|
||||
bsd|darwin) export LSCOLORS="Gxfxcxdxbxegedabagacad" ;;
|
||||
bsd | darwin ) export LSCOLORS="Gxfxcxdxbxegedabagacad" ;;
|
||||
esac
|
||||
|
||||
z-alt-ls() {
|
||||
@@ -17,11 +17,12 @@ z-alt-ls() {
|
||||
n=${#a}
|
||||
[ -z "$1" ] && n=0
|
||||
case "$n" in
|
||||
0) ;;
|
||||
*) z-alt-set-static \
|
||||
'ls|-d .' \
|
||||
"$1" \
|
||||
"LS_OPTIONS='' command"
|
||||
0 ) ;;
|
||||
* )
|
||||
z-alt-set-static \
|
||||
'ls|-d .' \
|
||||
"$1" \
|
||||
"LS_OPTIONS='' command"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@@ -29,12 +30,12 @@ z-alt-ls() {
|
||||
LS_GNU='--color=tty --group-directories-first'
|
||||
|
||||
case "${ZSHU[os_type]}" in
|
||||
linux*) alt="ls ${LS_GNU}|ls" ;;
|
||||
netbsd*) alt="gls ${LS_GNU}|ls" ;;
|
||||
openbsd*) alt="gls ${LS_GNU}|colorls -G|ls" ;;
|
||||
freebsd*) alt="gls ${LS_GNU}|ls -G|ls" ;;
|
||||
darwin*) alt="gls ${LS_GNU}|ls -G|ls" ;;
|
||||
*) alt="ls ${LS_GNU}|ls" ;;
|
||||
linux* ) alt="ls ${LS_GNU}|ls" ;;
|
||||
netbsd* ) alt="gls ${LS_GNU}|ls" ;;
|
||||
openbsd* ) alt="gls ${LS_GNU}|colorls -G|ls" ;;
|
||||
freebsd* ) alt="gls ${LS_GNU}|ls -G|ls" ;;
|
||||
darwin* ) alt="gls ${LS_GNU}|ls -G|ls" ;;
|
||||
* ) alt="ls ${LS_GNU}|ls" ;;
|
||||
esac
|
||||
|
||||
z-alt-ls "${alt}"
|
||||
@@ -44,13 +45,13 @@ unset alt LS_GNU
|
||||
[ -n "${LS_COLORS}" ] && zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
||||
|
||||
case "${ZSHU[os_family]}" in
|
||||
linux) alias l='ls -lhF ' ;;
|
||||
bsd) alias l='ls -lhIF ' ;;
|
||||
linux ) alias l='ls -lhF ' ;;
|
||||
bsd ) alias l='ls -lhIF ' ;;
|
||||
esac
|
||||
|
||||
alias ll='ls -lAF '
|
||||
|
||||
case "${ZSHU[os_family]}" in
|
||||
linux) alias lll='ls -lAn --full-time ' ;;
|
||||
bsd) alias lll='ls -lAnT ' ;;
|
||||
linux ) alias lll='ls -lAn --full-time ' ;;
|
||||
bsd ) alias lll='ls -lAnT ' ;;
|
||||
esac
|
||||
|
79
.config/zsh/alias/quilt.zsh
Normal file
79
.config/zsh/alias/quilt.zsh
Normal file
@@ -0,0 +1,79 @@
|
||||
#!/bin/zsh
|
||||
|
||||
quilt-series-strip-comments() {
|
||||
sed -E '/^[[:space:]]*(#|$)/d' "$@"
|
||||
}
|
||||
|
||||
quilt-series-auto() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
find "$1/" -follow -type f -printf '%P\0' \
|
||||
| sed -zEn '/\.(diff|patch)$/p' \
|
||||
| sort -zuV | xargs -0r -n1
|
||||
}
|
||||
|
||||
krd-quilt() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
(( $+commands[quilt] )) || return 2
|
||||
|
||||
local patchdir series tmp_series
|
||||
|
||||
if [ -d "$1" ] ; then
|
||||
patchdir="$1/debian/patches"
|
||||
if [ -d "${patchdir}" ] ; then
|
||||
[ -f "${patchdir}/series" ] || return 3
|
||||
else
|
||||
patchdir="$1"
|
||||
fi
|
||||
|
||||
series="${patchdir}/series"
|
||||
if ! [ -f "${series}" ] ; then
|
||||
tmp_series=1
|
||||
series=$(mktemp)
|
||||
quilt-series-auto "${patchdir}" > "${series}"
|
||||
fi
|
||||
elif [ -f "$1" ] ; then
|
||||
[ -s "$1" ] || return 3
|
||||
|
||||
series="$1"
|
||||
patchdir=${series:h}
|
||||
else
|
||||
return 3
|
||||
fi
|
||||
|
||||
local r
|
||||
(
|
||||
z-quilt-default-env
|
||||
set -a
|
||||
QUILT_SERIES="${series}"
|
||||
QUILT_PATCHES="${patchdir}"
|
||||
set +a
|
||||
|
||||
command quilt pop -a ; echo
|
||||
|
||||
r=0
|
||||
while read -r i ; do
|
||||
[ -n "$i" ] || continue
|
||||
|
||||
k="${patchdir}/$i"
|
||||
command quilt --fuzz=0 push "$k"
|
||||
r=$? ; [ $r -eq 0 ] || exit $r
|
||||
command quilt refresh "$k"
|
||||
r=$? ; [ $r -eq 0 ] || exit $r
|
||||
|
||||
sed -E -i \
|
||||
-e 's#^(-{3} )[^/][^/]*/(.*)$#\1a/\2#;' \
|
||||
-e 's#^(\+{3} )[^/][^/]*/(.*)$#\1b/\2#' \
|
||||
"$k"
|
||||
|
||||
rm -f "$k"'~'
|
||||
done <<< $(quilt-series-strip-comments "${series}")
|
||||
exit $r
|
||||
)
|
||||
r=$?
|
||||
|
||||
[ -z "${tmp_series}" ] || rm -f "${series}"
|
||||
|
||||
return $r
|
||||
}
|
67
.config/zsh/alias/sbuild.zsh
Normal file
67
.config/zsh/alias/sbuild.zsh
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/bin/zsh
|
||||
|
||||
krd-debsrc() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
local dstdir
|
||||
case "$1" in
|
||||
*/* ) dstdir="$1/src" ;;
|
||||
* ) dstdir="/tmp/$1/src" ;;
|
||||
esac
|
||||
rm -rf "${dstdir}"
|
||||
deb-src-export "${dstdir}"
|
||||
}
|
||||
|
||||
krd-sbuild() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
[ -n "${2:?}" ] || return 1
|
||||
|
||||
(( $+commands[sbuild] )) || return 2
|
||||
(( $+commands[xz] )) || return 2
|
||||
|
||||
local topdir
|
||||
case "$1" in
|
||||
*/* ) topdir="$1" ;;
|
||||
* ) topdir="/tmp/$1" ;;
|
||||
esac
|
||||
[ -d "${topdir}" ] || return 3
|
||||
|
||||
local srcdir="${topdir}/src"
|
||||
[ -d "${srcdir}" ] || return 3
|
||||
|
||||
arch="$2"
|
||||
|
||||
## done with args
|
||||
shift 2
|
||||
|
||||
local -a sbuild_env sbuild_args
|
||||
local i
|
||||
for i ; do
|
||||
## naive splitting args and env
|
||||
case "$i" in
|
||||
*=* ) sbuild_env+=( $i ) ;;
|
||||
*) sbuild_args+=( $i ) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
(
|
||||
for i ( ${sbuild_env} ) ; do
|
||||
export "$i"
|
||||
done
|
||||
|
||||
z-set-tmpdir /tmp
|
||||
|
||||
builddir="${topdir}/${arch}"
|
||||
mkdir -p "${topdir}/all" "${builddir}" "${builddir}-debug"
|
||||
|
||||
cd "${builddir}"
|
||||
for i ( "${srcdir}"/*.dsc(N.r) ) ; do
|
||||
idle sbuild --arch-all --arch-any --arch=${arch} ${sbuild_args[@]} "$i"
|
||||
find -name '*.build' -type l -exec rm -f {} +
|
||||
find -name '*.build' -type f -exec xz -9vv {} +
|
||||
done
|
||||
|
||||
find -name '*dbgsym*.deb' -type f -exec mv -nvt "../${arch}-debug" {} +
|
||||
find -name '*_all.deb' -type f -exec mv -nvt '../all' {} +
|
||||
)
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/zsh
|
||||
|
||||
case "${ZSHU[os_type]}" in
|
||||
linux-gnu) alias tl='telnet -K ' ;;
|
||||
*bsd*) alias tl='telnet -K -N -y ' ;;
|
||||
linux-gnu ) alias tl='telnet -K ' ;;
|
||||
*bsd* ) alias tl='telnet -K -N -y ' ;;
|
||||
esac
|
||||
|
Reference in New Issue
Block a user