zsh: update
This commit is contained in:
@@ -5,7 +5,7 @@ z-time() {
|
||||
|
||||
a=${EPOCHREALTIME}
|
||||
"$@" ; r=$?
|
||||
a=$(( EPOCHREALTIME - a ))
|
||||
a=$[ EPOCHREALTIME - a ]
|
||||
a=$(z-ts-to-human "$a" 6)
|
||||
echo >&2
|
||||
echo "time took: $a" >&2
|
||||
@@ -16,7 +16,7 @@ z-time() {
|
||||
if autoload -Uz add-zsh-hook ; then
|
||||
|
||||
typeset -gA ZSHU_PS
|
||||
ZSHU_PS[cmd_threshold]=1
|
||||
ZSHU_PS[cmd_threshold]=3
|
||||
|
||||
__z_cmdtime_measure() {
|
||||
local t x
|
||||
@@ -26,14 +26,14 @@ __z_cmdtime_measure() {
|
||||
unset 'ZSHU[cmd_dt]' 'ZSHU_PS[elapsed]'
|
||||
(( ${+ZSHU[cmd_ts]} )) || return
|
||||
|
||||
t=$(( x - ${ZSHU[cmd_ts]} ))
|
||||
t=$[ x - ZSHU[cmd_ts] ]
|
||||
ZSHU[cmd_ts]=$x
|
||||
|
||||
x=${ZSHU_PS[cmd_threshold]}
|
||||
x=$(( x + 0 )) || x=0
|
||||
x=$[ x + 0 ] || x=0
|
||||
[ "$x" = 0 ] && return
|
||||
|
||||
x=$(( t - x ))
|
||||
x=$[ t - x ]
|
||||
[ "${x:0:1}" = '-' ] && return
|
||||
|
||||
t=$(z-ts-to-human "$t")
|
||||
|
@@ -9,7 +9,7 @@ fpath=( "${ZSHU[d_cache]}/completion" $fpath )
|
||||
__z_compdump_print() { printf '#zshu %s %s\n' "$1" "${(P)1}" ; }
|
||||
|
||||
__z_compdump_invalidate() {
|
||||
command rm -f "${ZSHU[f_compdump]}"
|
||||
rm -f "${ZSHU[f_compdump]}"
|
||||
find "${ZSHU[d_compcache]}/" -xdev -type f '!' -name '.keep' -delete
|
||||
ZSHU[compdump_refresh]=1
|
||||
}
|
||||
@@ -99,5 +99,5 @@ z-comp-invalidate() {
|
||||
|
||||
f="${ZSHU[d_cache]}/completion/_$1"
|
||||
[ -f "$f" ] || return 2
|
||||
command rm -f "$f" || return 3
|
||||
rm -f "$f" || return 3
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ function {
|
||||
for i ( ${ZSHU_PARENTS_PID} ) ; do
|
||||
c=$(ps -o comm= -p $i 2>/dev/null) || :
|
||||
[ -n "$c" ] || continue
|
||||
ZSHU_PARENTS_NAME+=( "${c##*/}" )
|
||||
ZSHU_PARENTS_NAME+=( "${c:t}" )
|
||||
done
|
||||
|
||||
typeset -r ZSHU_PARENTS_PID
|
||||
|
@@ -4,23 +4,23 @@ z-ts-to-human() {
|
||||
local t s n d h m f x
|
||||
|
||||
t=$1
|
||||
t=$(( float(t) ))
|
||||
s=$(( int(t) ))
|
||||
n=$(( int((t - s) * (10**9)) ))
|
||||
t=$[ float(t) ]
|
||||
s=$[ int(t) ]
|
||||
n=$[ int((t - s) * (10**9)) ]
|
||||
t=$s
|
||||
|
||||
d=0 h=0 m=0
|
||||
if [ $t -ge 86400 ] ; then
|
||||
d=$(( t / 86400 ))
|
||||
t=$(( t % 86400 ))
|
||||
d=$[ t / 86400 ]
|
||||
t=$[ t % 86400 ]
|
||||
fi
|
||||
if [ $t -ge 3600 ] ; then
|
||||
h=$(( t / 3600 ))
|
||||
t=$(( t % 3600 ))
|
||||
h=$[ t / 3600 ]
|
||||
t=$[ t % 3600 ]
|
||||
fi
|
||||
if [ $t -ge 60 ] ; then
|
||||
m=$(( t / 60 ))
|
||||
t=$(( t % 60 ))
|
||||
m=$[ t / 60 ]
|
||||
t=$[ t % 60 ]
|
||||
fi
|
||||
|
||||
## strftime does desired rounding for $n/(10**9) internally
|
||||
@@ -28,8 +28,8 @@ z-ts-to-human() {
|
||||
## keep math in sync with format above
|
||||
x=3
|
||||
case "$2" in
|
||||
0) x=7 ;;
|
||||
[1-6]) x=$(( 6 - $2 )) ;;
|
||||
0 ) x=7 ;;
|
||||
[1-6] ) x=$[ 6 - $2 ] ;;
|
||||
esac
|
||||
[ $x -gt 0 ] && f="${f:0:-$x}s"
|
||||
|
||||
|
@@ -7,14 +7,14 @@ z-title-tab() {
|
||||
emulate -L zsh
|
||||
|
||||
case "${TERM}" in
|
||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*)
|
||||
cygwin | xterm* | putty* | rxvt* | konsole* | ansi | mlterm* | alacritty | st* )
|
||||
print -Pn "\e]1;${1:q}\a"
|
||||
;;
|
||||
screen*|tmux*)
|
||||
screen* | tmux* )
|
||||
## hardstatus
|
||||
print -Pn "\ek${1:q}\e\\"
|
||||
;;
|
||||
*)
|
||||
* )
|
||||
z-ti-test fsl tsl || return
|
||||
|
||||
echoti tsl
|
||||
@@ -28,7 +28,7 @@ z-title-window() {
|
||||
emulate -L zsh
|
||||
|
||||
case "${TERM}" in
|
||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*)
|
||||
cygwin | xterm* | putty* | rxvt* | konsole* | ansi | mlterm* | alacritty | st* )
|
||||
print -Pn "\e]2;${1:q}\a"
|
||||
;;
|
||||
esac
|
||||
|
Reference in New Issue
Block a user