From a8056c5575e22c814fce2a87f5b1b0d71c8fc402 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 15 Aug 2024 13:08:00 +0200 Subject: ... --- accounts/gkleen@sif/zshrc | 175 ++-------------------------------------------- 1 file changed, 4 insertions(+), 171 deletions(-) (limited to 'accounts/gkleen@sif/zshrc') diff --git a/accounts/gkleen@sif/zshrc b/accounts/gkleen@sif/zshrc index 83e86270..82e66337 100644 --- a/accounts/gkleen@sif/zshrc +++ b/accounts/gkleen@sif/zshrc @@ -1,106 +1,3 @@ -filebin() { - basePath=/srv/www/files - ssh ymir find /srv/www/files -type f -printf "$'%T@ %TY-%Tm-%TdT%TH:%TM %P\\\\0'" | sort -zn | cut -z -d ' ' -f 2- \ - | while IFS= read -r -d $'\0' l; do - IFS=' ' read -r t p <<<"${l}" - printf "%s https://f.141.li/%s\n" "${t}" "${p}" - done -} - -push2bin() { - if [[ ${#@} -eq 1 && ! -r ${1} ]]; then - uux -p 'ymir!push2bin' $(echo -n "${1:t}" | tr -c $'[:alnum:]+-=.' '_') - else - for f (${@}); do - uux -p 'ymir!push2bin' $(echo -n "${f:t}" | tr -c $'[:alnum:]+-=.' '_') <${f} - done - fi -} - -genmail() { - local baseName="" - local target="" - if [[ ${#@} -ge 1 ]]; then - target=${1} - shift - fi - - if [[ ${#@} -ge 1 ]]; then - baseName=$(pwgen ${@}) - else - baseName=$(pwgen -v -A -0 16 1) - fi - baseName=$(tr -cd $'[:alnum:]!#$%&*+-/=?^_{|}~.' <<<${baseName}) - address=${baseName}@141.li - insertAddr() { - echo "${baseName} gkleen" | ssh ymir tee -a /srv/mail/spm 1>/dev/null \ - } - - printf "%s\n" ${address} - read -q 'cont?Continue [y/N]? ' || return - - insertAddr -} - -s() { - dir=$(pwd) - [[ ${#@} -ge 1 ]] && dir=$1 - - shellFile=$(findNix ${@}) - [[ ${#@} -ge 1 ]] && shift - - typeset -a cmd - if [[ -d ${dir}/.nix-gc-roots ]]; then - cmd=(persistent-nix-shell ${shellFile} ${S_EXTRA_ARGS} ${@}) - else - cmd=(nix-shell ${shellFile} ${S_EXTRA_ARGS} ${@}) - fi - - if [[ -n "${S_SYSTEMD}" ]]; then - systemd-run --user --slice=development.slice --collect -E PATH=${PATH} -p WorkingDirectory=${dir} -- ${cmd} - else - ( - cd ${dir} - - exec ${cmd} - ) - fi -} - -sz() { - typeset -a S_EXTRA_ARGS - S_EXTRA_ARGS=(--run "env __ETC_ZSHENV_SOURCED=1 zsh") s ${@} -} -st() { - typeset -a S_EXTRA_ARGS - S_EXTRA_ARGS=(--run "tmux new-session env __ETC_ZSHENV_SOURCED=1 zsh") s ${@} -} -stt() { - typeset -a S_EXTRA_ARGS - S_SYSTEMD=true S_EXTRA_ARGS=(--run "urxvt -e tmux -S .tmux.sock new-session env __ETC_ZSHENV_SOURCED=1 zsh") s ${@} -} -se() { - typeset -a S_EXTRA_ARGS - S_SYSTEMD=true S_EXTRA_ARGS=(--run "emacs") s ${@} -} - -findNix() { - if [[ $#@ -eq 0 ]]; then - findNix $(pwd) - elif [[ -f "$1" ]]; then - print ${1:a} - elif [[ -d "$1" && -f "$1"/shell.nix ]]; then - print ${1:a}/shell.nix - elif [[ -d "$1" && -f "$1"/default.nix ]]; then - print ${1:a}/default.nix - elif [[ -d "$1" && "$1" != "/" ]]; then - findNix ${1:h} - else - printf "Traversed directories to ‘/’ and found no shell specification\n" >&2 - return 1 - fi -} - dir() { curlArchive=false templateArchive="" @@ -231,60 +128,9 @@ dir() { fi - # if [[ -n ${notmuchMsg} ]]; then - # getMimeTypes() { - # nix-shell -p mailcap --run "find \${buildInputs} -path '*/etc/mime.types' | head -n 1 | xargs -- cat" - # } - - # typeset -a messages - # messages=(${(z)$(notmuch search --output=messages ${notmuchMsg})}) - - # for message (${messages}); do - # typeset -A notmuchAtts - # notmuchAtts=() - - # while IFS= read -r -d $'\n' line; do - # [[ ${line} =~ '(attachment|part)\{ ID: ([0-9]+)' ]] || continue - # attId=${match[2]} - - # [[ ${line} =~ 'Content-type: multipart/' ]] && continue - - # fName="part_${attId}" - # [[ ${line} =~ 'Filename: (([^,]|,[^ ])+)' ]] && fName=${match[1]} - - # if [[ ${#messages} -gt 1 ]]; then - # fName="${message}/${fName}" - # fi - - # fExt="${fName:e}" - # [[ -n "${fExt}" ]] && fName="${fName:r}" - - # if [[ -z "${fExt}" && ${line} =~ 'Content-type: (([^,]|,[^ ])+)$' ]]; then - # fExt=$(getMimeTypes | grep ${match[1]}$'\t' | head -n 1 | awk '{ print $2; }') - # fi - - # mkdir -p ${fName:h} - # if [[ -n "${fExt}" ]]; then - # fName=$(mktemp -p . "${fName}.XXXXXX.${fExt}") - # else - # fName=$(mktemp -p . "${fName}.XXXXXX") - # fi - - # notmuchAtts[${attId}]=${fName} - # done <<(notmuch show --decrypt=false -- ${message} | tr -d $'\f') - - # for attId fName in ${(kv)notmuchAtts}; do - # [[ -d ${fName:h} ]] || mkdir -p ${fName:h} - # printf "#%d → ‘%s’\n" "${attId}" "${fName}" >&2 - - # notmuch show --decrypt=false --part=${attId} -- ${message} | pv -W -D 2 -i 0.1 >${fName} - # done - # done - # fi - - ${wormhole} && wormhole receive + if ${quickserve}; then quickserve --root . --upload . --show-hidden --tar gz fi @@ -370,16 +216,6 @@ tmpdir() { ) } -inhibit-sleep() { - if systemctl --user is-active prevent-suspend.service 1>/dev/null; then - echo "Allowing suspend" - systemctl --user stop prevent-suspend.service - else - echo "Inhibiting suspend" - systemctl --user start prevent-suspend.service - fi -} - qr() { qrencode -l M -o - -t ANSIUTF8 $@ } @@ -422,7 +258,7 @@ swap() { } ls() { - exa --all --group-directories-first --colour=always $@ | less --mouse -FR + eza --all --group-directories-first --colour=always $@ | less --mouse -FR } l() { @@ -437,10 +273,6 @@ ure() { systemctl --user --restart $@ } -u2wdb() { - ssh -t postgres@uniworxdb2 psql uni2work -} - ssh-installer() { ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentityFile=~/.ssh/gkleen@sif.midgard.yggdrasil $@ } @@ -483,4 +315,5 @@ bindkey -e bindkey ';5C' emacs-forward-word bindkey ';5D' emacs-backward-word bindkey '^[[1;5C' emacs-forward-word -bindkey '^[[1;5D' emacs-backward-word \ No newline at end of file +bindkey '^[[1;5D' emacs-backward-word +bindkey '^H' backward-kill-word -- cgit v1.2.3