1
0

zsh: aliases and related

This commit is contained in:
2021-12-07 02:46:50 +03:00
parent 95d73f7f64
commit 731471aee7
15 changed files with 66 additions and 35 deletions

View File

@@ -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 '

View File

@@ -1,3 +1,5 @@
#!/bin/zsh
z-alt-set-static 'diff|. .' 'diff --color=auto|diff'
z-alt-set-static \
'diff|. .' \
'diff --color=auto|diff'

View File

@@ -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"

View File

@@ -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 '

View File

@@ -2,5 +2,4 @@
fc() { builtin fc -i "$@" ; }
# alias history='z-history '
history() { builtin fc -il "$@" ; }
# history() { builtin fc -il "$@" ; }

View File

@@ -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 &>/dev/null
"$@"
)
}

View File

@@ -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}"

View File

@@ -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 "

View File

@@ -1,4 +1,4 @@
#!/bin/zsh
alias sudo-i='sudo -i'
alias sudoi='sudo -i'
alias sudo-i='sudo -i '
alias sudoi='sudo -i '