From 9d1de606488bbb59e7b869f0a5edf3cfacdf4ae8 Mon Sep 17 00:00:00 2001 From: Konstantin Demin Date: Sat, 27 Jan 2024 00:10:58 +0300 Subject: [PATCH] zsh: update --- .config/dotfiles/gitignore | 3 ++ .config/dotfiles/scripts/.keep | 0 .config/zsh/_.zsh | 11 ++--- .config/zsh/alias/git.zsh | 10 +++-- .config/zsh/alias/gpg.zsh | 6 +-- .config/zsh/alias/grep.zsh | 12 +++--- .config/zsh/alias/idle.zsh | 14 +++++- .config/zsh/alias/k8s.zsh | 2 +- .config/zsh/alias/kconfig.zsh | 20 ++++++--- .config/zsh/alias/ls.zsh | 33 +++++++------- .config/zsh/alias/quilt.zsh | 79 ++++++++++++++++++++++++++++++++++ .config/zsh/alias/sbuild.zsh | 67 ++++++++++++++++++++++++++++ .config/zsh/alias/telnet.zsh | 4 +- .config/zsh/env.zsh | 10 ++--- .config/zsh/env/quilt.zsh | 20 +++++---- .config/zsh/lib/cmdtime.zsh | 10 ++--- .config/zsh/lib/completion.zsh | 4 +- .config/zsh/lib/pswalk.zsh | 2 +- .config/zsh/lib/time.zsh | 22 +++++----- .config/zsh/lib/title.zsh | 8 ++-- .config/zsh/rc/keyboard.zsh | 2 +- 21 files changed, 258 insertions(+), 81 deletions(-) create mode 100644 .config/dotfiles/scripts/.keep create mode 100644 .config/zsh/alias/quilt.zsh create mode 100644 .config/zsh/alias/sbuild.zsh diff --git a/.config/dotfiles/gitignore b/.config/dotfiles/gitignore index 624fd84..5fd0e8f 100644 --- a/.config/dotfiles/gitignore +++ b/.config/dotfiles/gitignore @@ -5,6 +5,7 @@ !/.config/dotfiles/gen-gitignore.sh !/.config/dotfiles/gitignore !/.config/dotfiles/install.sh +!/.config/dotfiles/scripts/.keep !/.config/htop/htoprc.example !/.config/zsh/_.zsh !/.config/zsh/alias.zsh @@ -20,6 +21,8 @@ !/.config/zsh/alias/kconfig.zsh !/.config/zsh/alias/ls.zsh !/.config/zsh/alias/podman.zsh +!/.config/zsh/alias/quilt.zsh +!/.config/zsh/alias/sbuild.zsh !/.config/zsh/alias/sudo.zsh !/.config/zsh/alias/telnet.zsh !/.config/zsh/completion/.keep diff --git a/.config/dotfiles/scripts/.keep b/.config/dotfiles/scripts/.keep new file mode 100644 index 0000000..e69de29 diff --git a/.config/zsh/_.zsh b/.config/zsh/_.zsh index 574c653..f0711e2 100644 --- a/.config/zsh/_.zsh +++ b/.config/zsh/_.zsh @@ -12,9 +12,10 @@ ZSHU[d_conf]="${ZDOTDIR}/.config/zsh" ZSHU[d_var]="${ZSHU[d_conf]}/var" -ZSHU[d_bin]="${ZDOTDIR}/.config/dotfiles/bin/" +ZSHU[d_bin]="${ZDOTDIR}/.config/dotfiles/bin" +ZSHU[d_scripts]="${ZDOTDIR}/.config/dotfiles/scripts" -for i ( d_zdot d_cache d_conf d_bin d_var ) ; do +for i ( d_zdot d_cache d_conf d_bin d_scripts d_var ) ; do d=${ZSHU[$i]} [ -d "$d" ] || mkdir -p "$d" done ; unset i d @@ -36,12 +37,12 @@ umask 0022 zshu_parts=( env opt lib rc alias local ) -for n ( $zshu_parts ) ; do +for n ( ${zshu_parts} ) ; do f="${ZSHU[d_conf]}/$n.zsh" [ -s "$f" ] && source "$f" done ; unset n f -for n ( $zshu_parts ) ; do +for n ( ${zshu_parts} ) ; do d="${ZSHU[d_conf]}/$n" [ -d "$d" ] || continue for i ( $d/*.zsh(N.r) ) ; do @@ -53,7 +54,7 @@ unset zshu_parts ZSHU[t_end]=${(%):-%D{%s.%6.}} -ZSHU[t_load]=$(( ZSHU[t_end] - ZSHU[t_begin] )) +ZSHU[t_load]=$[ ZSHU[t_end] - ZSHU[t_begin] ] ZSHU[t_load]=${ZSHU[t_load]:0:6} unset 'ZSHU[t_begin]' 'ZSHU[t_end]' diff --git a/.config/zsh/alias/git.zsh b/.config/zsh/alias/git.zsh index e8c2ee4..1663d7a 100644 --- a/.config/zsh/alias/git.zsh +++ b/.config/zsh/alias/git.zsh @@ -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 } diff --git a/.config/zsh/alias/gpg.zsh b/.config/zsh/alias/gpg.zsh index a9410cb..473cbb0 100644 --- a/.config/zsh/alias/gpg.zsh +++ b/.config/zsh/alias/gpg.zsh @@ -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" } diff --git a/.config/zsh/alias/grep.zsh b/.config/zsh/alias/grep.zsh index c6b253a..d214fca 100644 --- a/.config/zsh/alias/grep.zsh +++ b/.config/zsh/alias/grep.zsh @@ -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 ' diff --git a/.config/zsh/alias/idle.zsh b/.config/zsh/alias/idle.zsh index 6456eaa..6a92cb8 100644 --- a/.config/zsh/alias/idle.zsh +++ b/.config/zsh/alias/idle.zsh @@ -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 ( { diff --git a/.config/zsh/alias/k8s.zsh b/.config/zsh/alias/k8s.zsh index 5398569..8b8ad64 100644 --- a/.config/zsh/alias/k8s.zsh +++ b/.config/zsh/alias/k8s.zsh @@ -1,3 +1,3 @@ #!/bin/zsh -alias k=kubectl +alias k='kubectl ' diff --git a/.config/zsh/alias/kconfig.zsh b/.config/zsh/alias/kconfig.zsh index 30af63d..7a0df71 100644 --- a/.config/zsh/alias/kconfig.zsh +++ b/.config/zsh/alias/kconfig.zsh @@ -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/" } diff --git a/.config/zsh/alias/ls.zsh b/.config/zsh/alias/ls.zsh index 7da20b5..2a50f9f 100644 --- a/.config/zsh/alias/ls.zsh +++ b/.config/zsh/alias/ls.zsh @@ -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 diff --git a/.config/zsh/alias/quilt.zsh b/.config/zsh/alias/quilt.zsh new file mode 100644 index 0000000..e62efdb --- /dev/null +++ b/.config/zsh/alias/quilt.zsh @@ -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 +} diff --git a/.config/zsh/alias/sbuild.zsh b/.config/zsh/alias/sbuild.zsh new file mode 100644 index 0000000..21216b7 --- /dev/null +++ b/.config/zsh/alias/sbuild.zsh @@ -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' {} + + ) +} diff --git a/.config/zsh/alias/telnet.zsh b/.config/zsh/alias/telnet.zsh index a25fe59..4ee551b 100644 --- a/.config/zsh/alias/telnet.zsh +++ b/.config/zsh/alias/telnet.zsh @@ -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 diff --git a/.config/zsh/env.zsh b/.config/zsh/env.zsh index eb0f21e..076b25b 100644 --- a/.config/zsh/env.zsh +++ b/.config/zsh/env.zsh @@ -14,7 +14,7 @@ function { ## process in-home part t=( ${(@)p:#${HOME}/*} ) - npath+=( "${ZSHU[d_bin]}" "${HOME}/bin" ) + npath+=( "${ZSHU[d_scripts]}" "${ZSHU[d_bin]}" "${HOME}/bin" ) npath+=( ${(@)p:|t} ) p=( $t ) @@ -65,16 +65,16 @@ ZSHU[uname]=${ZSHU[uname]:l} ZSHU[mach]=$(uname -m 2>/dev/null) ZSHU[mach]=${ZSHU[mach]:l} case "${ZSHU[mach]}" in -amd64) ZSHU[mach]=x86_64 ;; -arm64) ZSHU[mach]=aarch64 ;; -armv*) ZSHU[mach]=arm ;; +amd64 ) ZSHU[mach]=x86_64 ;; +arm64 ) ZSHU[mach]=aarch64 ;; +armv* ) ZSHU[mach]=arm ;; esac ZSHU[os_type]=${OSTYPE:l} ZSHU[os_family]=${ZSHU[uname]:l} case "${ZSHU[os_family]}" in -*bsd) ZSHU[os_family]=bsd ;; +*bsd ) ZSHU[os_family]=bsd ;; esac ZSHU[host_name]=${(%):-%m} diff --git a/.config/zsh/env/quilt.zsh b/.config/zsh/env/quilt.zsh index b617e9d..e2f12d6 100644 --- a/.config/zsh/env/quilt.zsh +++ b/.config/zsh/env/quilt.zsh @@ -1,11 +1,15 @@ #!/bin/zsh -QUILT_PATCHES="debian/patches" -QUILT_NO_DIFF_INDEX=1 -QUILT_NO_DIFF_TIMESTAMPS=1 -QUILT_PATCH_OPTS="--reject-format=unified" -QUILT_DIFF_ARGS="-p ab --no-timestamps --no-index --color=auto" -QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index" -QUILT_COLORS="diff_hdr=1;32:diff_add=1;34:diff_rem=1;31:diff_hunk=1;33:diff_ctx=35:diff_cctx=33" +z-quilt-default-env() { + set -a + QUILT_PATCHES='debian/patches' + QUILT_NO_DIFF_INDEX=1 + QUILT_NO_DIFF_TIMESTAMPS=1 + QUILT_PATCH_OPTS='--reject-format=unified' + QUILT_DIFF_ARGS='-pab --no-timestamps --no-index --color=auto' + QUILT_REFRESH_ARGS='-pab --no-timestamps --no-index' + QUILT_COLORS='diff_hdr=1;32:diff_add=1;34:diff_rem=1;31:diff_hunk=1;33:diff_ctx=35:diff_cctx=33' + set +a +} -typeset -x -m 'QUILT*' +z-quilt-default-env diff --git a/.config/zsh/lib/cmdtime.zsh b/.config/zsh/lib/cmdtime.zsh index db52fcc..669a5dd 100644 --- a/.config/zsh/lib/cmdtime.zsh +++ b/.config/zsh/lib/cmdtime.zsh @@ -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") diff --git a/.config/zsh/lib/completion.zsh b/.config/zsh/lib/completion.zsh index 1e35bf8..a504ef5 100644 --- a/.config/zsh/lib/completion.zsh +++ b/.config/zsh/lib/completion.zsh @@ -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 } diff --git a/.config/zsh/lib/pswalk.zsh b/.config/zsh/lib/pswalk.zsh index 0aa8a00..0eb0a62 100644 --- a/.config/zsh/lib/pswalk.zsh +++ b/.config/zsh/lib/pswalk.zsh @@ -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 diff --git a/.config/zsh/lib/time.zsh b/.config/zsh/lib/time.zsh index 9e1627e..b5ef149 100644 --- a/.config/zsh/lib/time.zsh +++ b/.config/zsh/lib/time.zsh @@ -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" diff --git a/.config/zsh/lib/title.zsh b/.config/zsh/lib/title.zsh index aac17ab..a254757 100644 --- a/.config/zsh/lib/title.zsh +++ b/.config/zsh/lib/title.zsh @@ -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 diff --git a/.config/zsh/rc/keyboard.zsh b/.config/zsh/rc/keyboard.zsh index 4e6d1ce..ce493b9 100644 --- a/.config/zsh/rc/keyboard.zsh +++ b/.config/zsh/rc/keyboard.zsh @@ -85,7 +85,7 @@ z-bind () { [ ${#keys} -eq 0 ] && return 1 case "${widget}" in - /*) + /* ) widget=${widget:1} emulate zsh -c "autoload -RUz ${widget}" zle -N "${widget}"