From 1037eef3b87473ab715c772ac643d721380135c9 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 3 May 2022 09:38:55 +0200 Subject: [PATCH] config/shell: tweak some helpers --- .config/shell/browse | 2 +- .config/shell/functions | 7 ++++--- .zshenv | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.config/shell/browse b/.config/shell/browse index d5eedcf..d92d374 100644 --- a/.config/shell/browse +++ b/.config/shell/browse @@ -34,7 +34,7 @@ cl() { cd() { if test -d "$DATA" && test "${1:--}" != "-" -a ! -d "$1" -a $# -eq 1 then - dir=$(fd --no-ignore --glob "$1*" "$DATA" --maxdepth 2 --type d --max-results 1) + dir=$(fd --no-ignore --glob "$1*" "$DATA" --maxdepth 2 --type d --max-results 1 2>/dev/null) test -n "$dir" && cd "$dir" else builtin cd "$@" && diff --git a/.config/shell/functions b/.config/shell/functions index 4a9aaba..14309bd 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -104,7 +104,7 @@ edshell() { (*) file="$(find $CONFIG_SHELLS -name "$1*" | head -1 | grep . || echo "$CONFIG_SHELLS/$1")";; esac test -f "$file" && checksum="$(md5sum "$file")" - $EDITOR "$(test "$line" && echo "+normal! ${line}ggzx" || echo "--")" "${file%:*}" + $EDITOR "$(test "$line" && case "$EDITOR" in (nvim) echo "+normal! ${line}ggzx";; (*vi*) echo "+$line";; esac || echo "--")" "${file%:*}" test -s "$file" || return 1 test "$checksum" != "$(md5sum $file)" && rs } @@ -220,12 +220,13 @@ u() { alias dns="drill any @8.8.8.8 -Q" alias delta="sudo systemctl restart openvpn-client@deltaPeak.service || jcl --unit openvpn-client@deltaPeak.service" sshl() { + test "$1" = "-a" && shift && local all=true lemonade server -allow 127.0.0.1 & - local authcache - authcache="/var/tmp/ssh-keys" + local authcache="/var/tmp/ssh-keys" mkdir -p "$authcache" file="$authcache/$1" if test ! -e "$file"; then + test "$all" && pass scp ~/.bash_aliases "$@:" if ! ssh -G "$1" | grep --silent "^user root$" && touch "$file"; then ssh-copy-id -i "$(ssh -G "$1" | grep --max-count 1 "^identityfile " | cut -d " " -f2- | sed "s|^~|$HOME|")" "$1" && touch "$file" TERM=xterm-256color kitty +kitten ssh -R 2489:127.0.0.1:2489 "$@" diff --git a/.zshenv b/.zshenv index cf7167c..44884d3 100644 --- a/.zshenv +++ b/.zshenv @@ -69,7 +69,7 @@ export LESS="--RAW-CONTROL-CHARS --ignore-case --LONG-PROMPT --jump-target=5 $(t # TODO put into config file and use --exclude-from export DIRS_GENERATED="-x generated -x .gradle -x cmake_build -x dist-newstyle -x node_modules -x __pycache__" export DIRS_IGNORE_SAFE="-x .sync -x .stfolder -x .cache -x .cpan -x *Cache -x .pyenv -x .local/cache -x share/baloo -x share/cabal -x share/cargo -x share/digikam -x share/JetBrains -x share/tldr -x share/syncthing -x share/Steam/ubuntu* -x share/Steam/package -x share/virtualenv -x share/Zeal -x state/gradle -x state/android -x Ferdi/Partitions -x oh-my-zsh -x wine/drive_c/windows $DIRS_GENERATED" -export DIRS_IGNORE="-x *build -x .git -x .idea -x out -x *cache -x Partitions $DIRS_IGNORE_SAFE" +export DIRS_IGNORE="-x *build -x .git -x .idea -x env -x out -x cache -x Partitions $DIRS_IGNORE_SAFE" # red stderr test -f "/usr/lib/libstderred.so" && export LD_PRELOAD="/usr/lib/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}" # software config