diff options
Diffstat (limited to 'accounts/gkleen@sif/zshrc')
| -rw-r--r-- | accounts/gkleen@sif/zshrc | 175 |
1 files changed, 4 insertions, 171 deletions
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 @@ | |||
| 1 | filebin() { | ||
| 2 | basePath=/srv/www/files | ||
| 3 | ssh ymir find /srv/www/files -type f -printf "$'%T@ %TY-%Tm-%TdT%TH:%TM %P\\\\0'" | sort -zn | cut -z -d ' ' -f 2- \ | ||
| 4 | | while IFS= read -r -d $'\0' l; do | ||
| 5 | IFS=' ' read -r t p <<<"${l}" | ||
| 6 | printf "%s https://f.141.li/%s\n" "${t}" "${p}" | ||
| 7 | done | ||
| 8 | } | ||
| 9 | |||
| 10 | push2bin() { | ||
| 11 | if [[ ${#@} -eq 1 && ! -r ${1} ]]; then | ||
| 12 | uux -p 'ymir!push2bin' $(echo -n "${1:t}" | tr -c $'[:alnum:]+-=.' '_') | ||
| 13 | else | ||
| 14 | for f (${@}); do | ||
| 15 | uux -p 'ymir!push2bin' $(echo -n "${f:t}" | tr -c $'[:alnum:]+-=.' '_') <${f} | ||
| 16 | done | ||
| 17 | fi | ||
| 18 | } | ||
| 19 | |||
| 20 | genmail() { | ||
| 21 | local baseName="" | ||
| 22 | local target="" | ||
| 23 | if [[ ${#@} -ge 1 ]]; then | ||
| 24 | target=${1} | ||
| 25 | shift | ||
| 26 | fi | ||
| 27 | |||
| 28 | if [[ ${#@} -ge 1 ]]; then | ||
| 29 | baseName=$(pwgen ${@}) | ||
| 30 | else | ||
| 31 | baseName=$(pwgen -v -A -0 16 1) | ||
| 32 | fi | ||
| 33 | baseName=$(tr -cd $'[:alnum:]!#$%&*+-/=?^_{|}~.' <<<${baseName}) | ||
| 34 | address=${baseName}@141.li | ||
| 35 | insertAddr() { | ||
| 36 | echo "${baseName} gkleen" | ssh ymir tee -a /srv/mail/spm 1>/dev/null \ | ||
| 37 | } | ||
| 38 | |||
| 39 | printf "%s\n" ${address} | ||
| 40 | read -q 'cont?Continue [y/N]? ' || return | ||
| 41 | |||
| 42 | insertAddr | ||
| 43 | } | ||
| 44 | |||
| 45 | s() { | ||
| 46 | dir=$(pwd) | ||
| 47 | [[ ${#@} -ge 1 ]] && dir=$1 | ||
| 48 | |||
| 49 | shellFile=$(findNix ${@}) | ||
| 50 | [[ ${#@} -ge 1 ]] && shift | ||
| 51 | |||
| 52 | typeset -a cmd | ||
| 53 | if [[ -d ${dir}/.nix-gc-roots ]]; then | ||
| 54 | cmd=(persistent-nix-shell ${shellFile} ${S_EXTRA_ARGS} ${@}) | ||
| 55 | else | ||
| 56 | cmd=(nix-shell ${shellFile} ${S_EXTRA_ARGS} ${@}) | ||
| 57 | fi | ||
| 58 | |||
| 59 | if [[ -n "${S_SYSTEMD}" ]]; then | ||
| 60 | systemd-run --user --slice=development.slice --collect -E PATH=${PATH} -p WorkingDirectory=${dir} -- ${cmd} | ||
| 61 | else | ||
| 62 | ( | ||
| 63 | cd ${dir} | ||
| 64 | |||
| 65 | exec ${cmd} | ||
| 66 | ) | ||
| 67 | fi | ||
| 68 | } | ||
| 69 | |||
| 70 | sz() { | ||
| 71 | typeset -a S_EXTRA_ARGS | ||
| 72 | S_EXTRA_ARGS=(--run "env __ETC_ZSHENV_SOURCED=1 zsh") s ${@} | ||
| 73 | } | ||
| 74 | st() { | ||
| 75 | typeset -a S_EXTRA_ARGS | ||
| 76 | S_EXTRA_ARGS=(--run "tmux new-session env __ETC_ZSHENV_SOURCED=1 zsh") s ${@} | ||
| 77 | } | ||
| 78 | stt() { | ||
| 79 | typeset -a S_EXTRA_ARGS | ||
| 80 | S_SYSTEMD=true S_EXTRA_ARGS=(--run "urxvt -e tmux -S .tmux.sock new-session env __ETC_ZSHENV_SOURCED=1 zsh") s ${@} | ||
| 81 | } | ||
| 82 | se() { | ||
| 83 | typeset -a S_EXTRA_ARGS | ||
| 84 | S_SYSTEMD=true S_EXTRA_ARGS=(--run "emacs") s ${@} | ||
| 85 | } | ||
| 86 | |||
| 87 | findNix() { | ||
| 88 | if [[ $#@ -eq 0 ]]; then | ||
| 89 | findNix $(pwd) | ||
| 90 | elif [[ -f "$1" ]]; then | ||
| 91 | print ${1:a} | ||
| 92 | elif [[ -d "$1" && -f "$1"/shell.nix ]]; then | ||
| 93 | print ${1:a}/shell.nix | ||
| 94 | elif [[ -d "$1" && -f "$1"/default.nix ]]; then | ||
| 95 | print ${1:a}/default.nix | ||
| 96 | elif [[ -d "$1" && "$1" != "/" ]]; then | ||
| 97 | findNix ${1:h} | ||
| 98 | else | ||
| 99 | printf "Traversed directories to ‘/’ and found no shell specification\n" >&2 | ||
| 100 | return 1 | ||
| 101 | fi | ||
| 102 | } | ||
| 103 | |||
| 104 | dir() { | 1 | dir() { |
| 105 | curlArchive=false | 2 | curlArchive=false |
| 106 | templateArchive="" | 3 | templateArchive="" |
| @@ -231,60 +128,9 @@ dir() { | |||
| 231 | fi | 128 | fi |
| 232 | 129 | ||
| 233 | 130 | ||
| 234 | # if [[ -n ${notmuchMsg} ]]; then | ||
| 235 | # getMimeTypes() { | ||
| 236 | # nix-shell -p mailcap --run "find \${buildInputs} -path '*/etc/mime.types' | head -n 1 | xargs -- cat" | ||
| 237 | # } | ||
| 238 | |||
| 239 | # typeset -a messages | ||
| 240 | # messages=(${(z)$(notmuch search --output=messages ${notmuchMsg})}) | ||
| 241 | |||
| 242 | # for message (${messages}); do | ||
| 243 | # typeset -A notmuchAtts | ||
| 244 | # notmuchAtts=() | ||
| 245 | |||
| 246 | # while IFS= read -r -d $'\n' line; do | ||
| 247 | # [[ ${line} =~ '(attachment|part)\{ ID: ([0-9]+)' ]] || continue | ||
| 248 | # attId=${match[2]} | ||
| 249 | |||
| 250 | # [[ ${line} =~ 'Content-type: multipart/' ]] && continue | ||
| 251 | |||
| 252 | # fName="part_${attId}" | ||
| 253 | # [[ ${line} =~ 'Filename: (([^,]|,[^ ])+)' ]] && fName=${match[1]} | ||
| 254 | |||
| 255 | # if [[ ${#messages} -gt 1 ]]; then | ||
| 256 | # fName="${message}/${fName}" | ||
| 257 | # fi | ||
| 258 | |||
| 259 | # fExt="${fName:e}" | ||
| 260 | # [[ -n "${fExt}" ]] && fName="${fName:r}" | ||
| 261 | |||
| 262 | # if [[ -z "${fExt}" && ${line} =~ 'Content-type: (([^,]|,[^ ])+)$' ]]; then | ||
| 263 | # fExt=$(getMimeTypes | grep ${match[1]}$'\t' | head -n 1 | awk '{ print $2; }') | ||
| 264 | # fi | ||
| 265 | |||
| 266 | # mkdir -p ${fName:h} | ||
| 267 | # if [[ -n "${fExt}" ]]; then | ||
| 268 | # fName=$(mktemp -p . "${fName}.XXXXXX.${fExt}") | ||
| 269 | # else | ||
| 270 | # fName=$(mktemp -p . "${fName}.XXXXXX") | ||
| 271 | # fi | ||
| 272 | |||
| 273 | # notmuchAtts[${attId}]=${fName} | ||
| 274 | # done <<(notmuch show --decrypt=false -- ${message} | tr -d $'\f') | ||
| 275 | |||
| 276 | # for attId fName in ${(kv)notmuchAtts}; do | ||
| 277 | # [[ -d ${fName:h} ]] || mkdir -p ${fName:h} | ||
| 278 | # printf "#%d → ‘%s’\n" "${attId}" "${fName}" >&2 | ||
| 279 | |||
| 280 | # notmuch show --decrypt=false --part=${attId} -- ${message} | pv -W -D 2 -i 0.1 >${fName} | ||
| 281 | # done | ||
| 282 | # done | ||
| 283 | # fi | ||
| 284 | |||
| 285 | |||
| 286 | ${wormhole} && wormhole receive | 131 | ${wormhole} && wormhole receive |
| 287 | 132 | ||
| 133 | |||
| 288 | if ${quickserve}; then | 134 | if ${quickserve}; then |
| 289 | quickserve --root . --upload . --show-hidden --tar gz | 135 | quickserve --root . --upload . --show-hidden --tar gz |
| 290 | fi | 136 | fi |
| @@ -370,16 +216,6 @@ tmpdir() { | |||
| 370 | ) | 216 | ) |
| 371 | } | 217 | } |
| 372 | 218 | ||
| 373 | inhibit-sleep() { | ||
| 374 | if systemctl --user is-active prevent-suspend.service 1>/dev/null; then | ||
| 375 | echo "Allowing suspend" | ||
| 376 | systemctl --user stop prevent-suspend.service | ||
| 377 | else | ||
| 378 | echo "Inhibiting suspend" | ||
| 379 | systemctl --user start prevent-suspend.service | ||
| 380 | fi | ||
| 381 | } | ||
| 382 | |||
| 383 | qr() { | 219 | qr() { |
| 384 | qrencode -l M -o - -t ANSIUTF8 $@ | 220 | qrencode -l M -o - -t ANSIUTF8 $@ |
| 385 | } | 221 | } |
| @@ -422,7 +258,7 @@ swap() { | |||
| 422 | } | 258 | } |
| 423 | 259 | ||
| 424 | ls() { | 260 | ls() { |
| 425 | exa --all --group-directories-first --colour=always $@ | less --mouse -FR | 261 | eza --all --group-directories-first --colour=always $@ | less --mouse -FR |
| 426 | } | 262 | } |
| 427 | 263 | ||
| 428 | l() { | 264 | l() { |
| @@ -437,10 +273,6 @@ ure() { | |||
| 437 | systemctl --user --restart $@ | 273 | systemctl --user --restart $@ |
| 438 | } | 274 | } |
| 439 | 275 | ||
| 440 | u2wdb() { | ||
| 441 | ssh -t postgres@uniworxdb2 psql uni2work | ||
| 442 | } | ||
| 443 | |||
| 444 | ssh-installer() { | 276 | ssh-installer() { |
| 445 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentityFile=~/.ssh/gkleen@sif.midgard.yggdrasil $@ | 277 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentityFile=~/.ssh/gkleen@sif.midgard.yggdrasil $@ |
| 446 | } | 278 | } |
| @@ -483,4 +315,5 @@ bindkey -e | |||
| 483 | bindkey ';5C' emacs-forward-word | 315 | bindkey ';5C' emacs-forward-word |
| 484 | bindkey ';5D' emacs-backward-word | 316 | bindkey ';5D' emacs-backward-word |
| 485 | bindkey '^[[1;5C' emacs-forward-word | 317 | bindkey '^[[1;5C' emacs-forward-word |
| 486 | bindkey '^[[1;5D' emacs-backward-word \ No newline at end of file | 318 | bindkey '^[[1;5D' emacs-backward-word |
| 319 | bindkey '^H' backward-kill-word | ||
