diff --git a/.config/zsh/alias.zsh b/.config/zsh/alias.zsh index f2703ff..1532418 100644 --- a/.config/zsh/alias.zsh +++ b/.config/zsh/alias.zsh @@ -1,5 +1,5 @@ #!/bin/zsh -# alias which-command='whence -p ' -# alias which='whence -p ' -# alias zsh-which='whence -c ' +alias which='whence -p ' +alias which-command='whence -p ' +alias zsh-which='whence -c ' diff --git a/.config/zsh/alias/buildah.zsh b/.config/zsh/alias/buildah.zsh index 181cb4a..859c8f3 100644 --- a/.config/zsh/alias/buildah.zsh +++ b/.config/zsh/alias/buildah.zsh @@ -1,3 +1,3 @@ #!/bin/zsh -bud() { command buildah bud --isolation chroot --network host --format docker -f "$@" ; } +alias bud='buildah build --isolation chroot --network host --format docker -f ' diff --git a/.config/zsh/alias/diff.zsh b/.config/zsh/alias/diff.zsh index 9927f77..39e3bb1 100644 --- a/.config/zsh/alias/diff.zsh +++ b/.config/zsh/alias/diff.zsh @@ -1,3 +1,5 @@ #!/bin/zsh -z-alt-set-static 'diff|. .' 'diff --color=auto|diff' +z-alt-set-static \ + 'diff|. .' \ + 'diff --color=auto|diff' diff --git a/.config/zsh/alias/gpg.zsh b/.config/zsh/alias/gpg.zsh index 35920d7..6096616 100644 --- a/.config/zsh/alias/gpg.zsh +++ b/.config/zsh/alias/gpg.zsh @@ -4,7 +4,7 @@ gpg-warmup() { (( ${+commands[gpg]} )) || return 1 local r t t=$(mktemp) - gpg --expert -abs "$t" + command gpg -abs "$t" r=$? command rm -f "$t" "$t.asc" return "$r" diff --git a/.config/zsh/alias/grep.zsh b/.config/zsh/alias/grep.zsh index 9fc9b11..e975d75 100644 --- a/.config/zsh/alias/grep.zsh +++ b/.config/zsh/alias/grep.zsh @@ -7,8 +7,12 @@ z-alt-grep() { local n=${#a} [ -z "$1" ] && n=0 case "$n" in - 0) : do nothing ;; - *) z-alt-set-static "grep|-q -e ' ' ${ZSHU[d_zdot]}/.zshenv" "$1" "GREP_OPTIONS='' " ;; + 0) ;; + *) z-alt-set-static \ + "grep|-q -e ' ' ${ZSHU[d_zdot]}/.zshenv" \ + "$1" \ + "GREP_OPTIONS='' command" \ + ;; esac } @@ -16,9 +20,8 @@ z-alt-grep() { GREP_GNU='--color=auto' z-alt-grep "grep ${GREP_GNU}|grep" - unfunction z-alt-grep unset GREP_GNU -egrep() { grep -E "$@" ; } -fgrep() { grep -F "$@" ; } +alias egrep='grep -E ' +alias fgrep='grep -F ' diff --git a/.config/zsh/alias/history.zsh b/.config/zsh/alias/history.zsh index ebfe502..0adbf6e 100644 --- a/.config/zsh/alias/history.zsh +++ b/.config/zsh/alias/history.zsh @@ -2,5 +2,4 @@ fc() { builtin fc -i "$@" ; } -# alias history='z-history ' -history() { builtin fc -il "$@" ; } +# history() { builtin fc -il "$@" ; } diff --git a/.config/zsh/alias/idle.zsh b/.config/zsh/alias/idle.zsh index 1ef0f82..2edc848 100644 --- a/.config/zsh/alias/idle.zsh +++ b/.config/zsh/alias/idle.zsh @@ -1,9 +1,30 @@ #!/bin/zsh -function { +idle() { + local f + f=$(type "$1") + case "$f" in + "$1 is /"*) z-idle-ext "$@" ;; + *) z-idle-int "$@" ;; + esac +} + +z-idle-ext() { local -a s s+=( $(z-alt-find 'nice -n +40') ) s+=( $(z-alt-find 'chrt -i 0' ) ) s+=( $(z-alt-find 'ionice -c 3') ) - z-alt-set-static idle "$s|env" + command ${s[@]} "$@" +} + +z-idle-int() { + ## execute in subshell + ( + { + command renice -n +40 -p ${sysparams[pid]} + command chrt -i -p 0 ${sysparams[pid]} + command ionice -c 3 -p ${sysparams[pid]} + } /dev/null + "$@" + ) } diff --git a/.config/zsh/alias/ls.zsh b/.config/zsh/alias/ls.zsh index 713f0eb..f946f8c 100644 --- a/.config/zsh/alias/ls.zsh +++ b/.config/zsh/alias/ls.zsh @@ -8,17 +8,19 @@ case "${ZSHU[os_family]}" in bsd|darwin) export LSCOLORS="Gxfxcxdxbxegedabagacad" ;; esac -__z_alt_ls() { +z-alt-ls() { local -a a a=( ${(@s:|:)1} ) [ ${#a} = 0 ] && a=( "$1" ) local n=${#a} [ -z "$1" ] && n=0 case "$n" in - 0) : do nothing ;; - *) z-alt-set-static 'ls|-d .' "$1" "LS_OPTIONS='' " ;; -# 1) z-alt-set-static 'ls|-d .' "$1" "LS_OPTIONS='' " ;; -# *) z-alt-set-dynamic 'ls|-d .' "$1" "LS_OPTIONS='' " ;; + 0) ;; + *) z-alt-set-static \ + 'ls|-d .' \ + "$1" \ + "LS_OPTIONS='' command" + ;; esac } @@ -33,8 +35,8 @@ darwin*) alt="gls ${LS_GNU}|ls -G|ls" ;; *) alt="ls ${LS_GNU}|ls" ;; esac -__z_alt_ls "${alt}" -unset -f __z_alt_ls +z-alt-ls "${alt}" +unset -f z-alt-ls unset alt LS_GNU [ -n "${LS_COLORS}" ] && zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" diff --git a/.config/zsh/alias/podman.zsh b/.config/zsh/alias/podman.zsh index 7bcabf4..330ec30 100644 --- a/.config/zsh/alias/podman.zsh +++ b/.config/zsh/alias/podman.zsh @@ -1,4 +1,4 @@ #!/bin/zsh -run() { command podman run ${TERM:+-e "TERM=$TERM"} --network host --rm -it "$@" ; } -run-sh() { run --entrypoint='["/bin/sh"]' --user=0:0 "$@" ; } +alias run='podman run -e "TERM=$TERM" --network host --rm -it ' +alias run-sh="run --entrypoint='[\"/bin/sh\"]' --user=0:0 " diff --git a/.config/zsh/alias/sudo.zsh b/.config/zsh/alias/sudo.zsh index 063f8e5..e97c825 100644 --- a/.config/zsh/alias/sudo.zsh +++ b/.config/zsh/alias/sudo.zsh @@ -1,4 +1,4 @@ #!/bin/zsh -alias sudo-i='sudo -i' -alias sudoi='sudo -i' +alias sudo-i='sudo -i ' +alias sudoi='sudo -i ' diff --git a/.config/zsh/lib/alternatives.zsh b/.config/zsh/lib/alternatives.zsh index 2cbd2e9..b8ccc50 100644 --- a/.config/zsh/lib/alternatives.zsh +++ b/.config/zsh/lib/alternatives.zsh @@ -16,6 +16,7 @@ z-alt-find() { c=$(which "${a[1]}") [ -z "$c" ] && continue + a[1]="$c" # r=$(readlink -f "$c" 2>/dev/null) # [ -z "$r" ] && continue @@ -50,8 +51,8 @@ z-alt-set-static() { if [ -n "$a" ] ; then r=0 [ -n "$4" ] && s+=( "$4 ;" ) - [ -n "$3" ] && s+=( "$3" ) - s+=( "command $a \"\$@\" || return 127" ) + s+=( "${3:-command}" ) + s+=( "$a \"\$@\" || return 127" ) [ -n "$5" ] && s+=( "; $5" ) else r=127 @@ -76,8 +77,8 @@ z-alt-set-dynamic() { fi [ -n "$4" ] && s+=( "$4 ;" ) s+=( 'local a=$(z-alt-find' "${(qq)2}" "${t:+' $t'} ) ;" ) - [ -n "$3" ] && s+=( "$3" ) - s+=( 'command ${(@s: :)a} "$@" || return 127' ) + s+=( "${3:-command}" ) + s+=( '${(@s: :)a} "$@" || return 127' ) [ -n "$5" ] && s+=( "; $5" ) eval "$n () { ${s[@]} ; } ; typeset -g $n" } diff --git a/.config/zsh/lib/cmdtime.zsh b/.config/zsh/lib/cmdtime.zsh index 4c79751..04a0c9b 100644 --- a/.config/zsh/lib/cmdtime.zsh +++ b/.config/zsh/lib/cmdtime.zsh @@ -1,7 +1,5 @@ #!/bin/zsh -zmodload -i zsh/datetime - z-time() { local a b elapsed result a=${EPOCHREALTIME} diff --git a/.config/zsh/lib/history.zsh b/.config/zsh/lib/history.zsh index 5cdcbc1..5436917 100644 --- a/.config/zsh/lib/history.zsh +++ b/.config/zsh/lib/history.zsh @@ -9,3 +9,8 @@ z-history() { [[ ${@[-1]-} = *[0-9]* ]] && builtin fc -il "$@" || builtin fc -il "$@" 1 fi } + +z-grephist() { + local what=$1 ; shift + z-history -m "*${what}*" "$@" +} diff --git a/.config/zsh/lib/time.zsh b/.config/zsh/lib/time.zsh index 3c04859..5de4885 100644 --- a/.config/zsh/lib/time.zsh +++ b/.config/zsh/lib/time.zsh @@ -1,8 +1,5 @@ #!/bin/zsh -zmodload -i zsh/datetime -zmodload -i zsh/mathfunc - z-ts-to-human() { local t=$1 local s=$(( int(t) )) diff --git a/.config/zsh/rc.zsh b/.config/zsh/rc.zsh index 3876f2a..05ac613 100644 --- a/.config/zsh/rc.zsh +++ b/.config/zsh/rc.zsh @@ -5,10 +5,13 @@ zshu_modules+=( complete complist computil + datetime langinfo main + mathfunc parameter stat + system terminfo zle zutil