diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-05-04 09:19:40 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-05-04 09:19:40 +0200 |
commit | 41712f9a97da7ee3c98ccbc6a17e119c09d0b7e2 (patch) | |
tree | 9e837a156fc2af20b2149bd857755d29c8e15881 | |
parent | d1fd4c1c04b9fefcdaa21d18b0262c2a700847a9 (diff) | |
parent | 80462e764abf047544be6026c5d67c1f54599ae5 (diff) |
Merge branch 'main' of debuc.com:dotfiles
-rwxr-xr-x | bin/extra/aivpn | 28 | ||||
-rw-r--r-- | config/essentials/shell/aliases.sh | 2 | ||||
-rw-r--r-- | config/essentials/shell/functions.sh | 42 | ||||
-rw-r--r-- | config/essentials/starship.toml | 4 | ||||
-rw-r--r-- | config/essentials/zsh/.zshrc | 7 | ||||
-rw-r--r-- | config/home/.zshenv | 2 |
6 files changed, 70 insertions, 15 deletions
diff --git a/bin/extra/aivpn b/bin/extra/aivpn index aab90a8..21436ed 100755 --- a/bin/extra/aivpn +++ b/bin/extra/aivpn @@ -1,6 +1,6 @@ #!/bin/sh -logn() { printf "%s\n" "$@"; } +err() { printf "%s\n" "$@"; } if [ "$1" = "-k" ] then @@ -8,19 +8,31 @@ then exit fi -keyadd ehb/ai +err "I: Waiting for connectivity..." +while ! ssh -o ConnectTimeout=1 -o BatchMode=yes vm 2>&1 | grep "Permission denied" > /dev/null +do sleep 1 +done + export SSH_ASKPASS="sshpass" export SSH_ASKPASS_REQUIRE="prefer" export PASSWORD="zot/qemu" -logn "I: Waiting for connectivity..." -while ! ssh -o ConnectTimeout=1 -o BatchMode=yes vm 2>&1 | grep "Permission denied" > /dev/null -do sleep 1 -done - -logn "I: Activating vpn" +err "I: Activating vpn" ssh vm "rasdial \"vpn.student.ehb.be\"" + +keyadd ehb/ai ssh -f -N \ -L 2222:10.2.160.41:22 \ vm + +keyadd ehb/vm_int +ssh -f -N \ + -L 2223:10.2.160.9:22 \ + vm +ssh -f -N \ + -L 2224:10.2.160.10:22 \ + vm +ssh -f -N \ + -L 2225:10.2.160.11:22 \ + vm diff --git a/config/essentials/shell/aliases.sh b/config/essentials/shell/aliases.sh index 50238cc..eb48416 100644 --- a/config/essentials/shell/aliases.sh +++ b/config/essentials/shell/aliases.sh @@ -3,6 +3,7 @@ # The most important one alias vi='nvim' +alias cd='z' # Zsh specific aliases if [ $SHELL = "/bin/zsh" ] @@ -149,6 +150,7 @@ alias wd='dict' # ssh alias sha='ssh-add' alias sshs='eval "$(ssh-agent)" && ssh-add' +alias sshids='ssh-add -L | xargs -I{} grep "{}" -l $(find "$HOME/.ssh" -type f -iname '\''*.pub'\'') | sed "s;$HOME/.ssh/;;;s;\.pub$;;"' alias whatsmyip='curl -s "ifconfig.co"' alias icognito='unset HISTFILE' alias webcam='v4l2-ctl --set-fmt-video=width=1280,height=720; mpv --demuxer-lavf-format=video4linux2 --demuxer-lavf-o-set=input_format=mjpeg av://v4l2:/dev/video0 --profile=low-latency --untimed --no-resume-playback' diff --git a/config/essentials/shell/functions.sh b/config/essentials/shell/functions.sh index 3078f46..1fd6e92 100644 --- a/config/essentials/shell/functions.sh +++ b/config/essentials/shell/functions.sh @@ -296,6 +296,15 @@ edit_in_dir() { $EDITOR "$file" } +# Download a file from google drive +# link like this: https://drive.usercontent.google.com/download?id=1TiJDEftTtF1KTMBI950Bj487ndYqkwpQ&export=download +gdown () { + agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/12$(head /dev/urandom | tr -dc '0-1' | cut -c1).0.0.0 Safari/537.36" + uuid=$(curl -sL "$1" -A "$agent" | sed -nE 's|.*(uuid=[^"]*)".*|\1|p') + aria2c -x16 -s16 "$1&confirm=t&$uuid" -U "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36" --summary-interval=0 -d "${2:-.}" +} + +# toggle wireguard vpn on $1 -> interface wgtoggle() { d="${1:-wg0}" ip -br a | awk '{print $1}' | grep "$d" > /dev/null && @@ -303,9 +312,34 @@ wgtoggle() { doas wg-quick up "$d" } +# serve a file through dufs serve() { - docker container run \ - --rm \ - --volume "$(readlink -f "$1")":/data \ - --publish 80:5000 sigoden/dufs:latest /data --allow-all + if [ "$1" ] + then + logn "Serving $1" + docker container run \ + --rm \ + --volume "$(readlink -f "$1")":/data \ + --publish 80:5000 sigoden/dufs /data + else + + logn "Receiving files.." + docker container run \ + --rm \ + --volume /tmp/data:/data \ + --publish 80:5000 sigoden/dufs /data --allow-upload + fi +} + +ssh_keyadd() { ssh-keygen -f "$HOME"/.ssh/"$1" -P "$(pass generate -f keys/"$HOST"/ssh/"$1" | tail -n 1)" -t ed25519; } + + +fchange() +{ + [ "$1" ] || return 1 + inotifywait -m -e create,modify,delete --format "%f" "${2:-.}" | + while read -r EVENT + do + eval "$1" + done } diff --git a/config/essentials/starship.toml b/config/essentials/starship.toml index cd5832f..15139f5 100644 --- a/config/essentials/starship.toml +++ b/config/essentials/starship.toml @@ -34,8 +34,6 @@ disabled = false [custom.upds] command = 'cat ~/.cache/updates' # shows output of command -# detect_files = ['foo'] # can specify filters but wildcards are not supported -when = ''' test "$(cat ~/.cache/updates)" -gt 0''' +when = '[ "$(cat ~/.cache/updates)" -gt 0 ]' symbol = '📦' format = '$output$symbol ' - diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index c9bf8b1..ab66fcb 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -110,6 +110,13 @@ bindkey -M menuselect '^xh' accept-and-hold # Hold bindkey -M menuselect '^xn' accept-and-infer-next-history # Next bindkey -M menuselect '^xu' undo # Undo +space-expand-alias() { + zle _expand_alias + zle self-insert +} +zle -N space-expand-alias +bindkey -M main ' ' space-expand-alias + ## window title hooks add-zsh-hook -Uz preexec () { print -n "\e]0;$1\a\033[0m"; } add-zsh-hook -Uz precmd set_wt (){ print -Pn "\e]0;%n@%m on %~\a"; } diff --git a/config/home/.zshenv b/config/home/.zshenv index 5d4e10c..65fe153 100644 --- a/config/home/.zshenv +++ b/config/home/.zshenv @@ -70,6 +70,8 @@ export LESS="-j 4 -i -r" export MANPAGER="less -R --use-color -Dd+r -Du+b" export MANROFFOPT="-P -c" +export CM_LAUNCHER="commander -c" + export PATH="$HOME/.local/bin:$PATH" export PATH="$HOME/bin:$PATH" export PATH="$HOME/go/bin:$PATH" |