diff options
author | Toby Vincent <tobyv13@gmail.com> | 2022-03-26 22:53:33 -0500 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2022-03-26 22:53:33 -0500 |
commit | da06c20b672c99660e041937fd05c5f73aa06bb6 (patch) | |
tree | c33b1ef25466291b95ca0f9ac0e652ad8976aeb2 /wsl/.config | |
parent | 824a5b0eb685673adc44fc138e108ac6d231fa34 (diff) |
feat: create zsh-wsl plugin
Diffstat (limited to 'wsl/.config')
-rwxr-xr-x | wsl/.config/zsh/gpg.sh | 66 | ||||
-rw-r--r-- | wsl/.config/zsh/wsl.sh | 57 |
2 files changed, 0 insertions, 123 deletions
diff --git a/wsl/.config/zsh/gpg.sh b/wsl/.config/zsh/gpg.sh deleted file mode 100755 index ac0bb4c..0000000 --- a/wsl/.config/zsh/gpg.sh +++ /dev/null @@ -1,66 +0,0 @@ -export SSH_AUTH_SOCK="$HOME/.ssh/agent.sock" -export GPG_AGENT_SOCK="$HOME/.gnupg/S.gpg-agent" - -gpg-init() ( - if ! ss -a | grep -q "$SSH_AUTH_SOCK"; then - rm -f "$SSH_AUTH_SOCK" - wsl2_ssh_pageant_bin="$HOME/.ssh/wsl2-ssh-pageant.exe" - if test -x "$wsl2_ssh_pageant_bin"; then - (setsid nohup socat UNIX-LISTEN:"$SSH_AUTH_SOCK,fork" EXEC:"$wsl2_ssh_pageant_bin" >/dev/null 2>&1 &) - else - echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable." - fi - unset wsl2_ssh_pageant_bin - fi - - if ! ss -a | grep -q "$GPG_AGENT_SOCK"; then - rm -rf "$GPG_AGENT_SOCK" - wsl2_ssh_pageant_bin="$HOME/.ssh/wsl2-ssh-pageant.exe" - if test -x "$wsl2_ssh_pageant_bin"; then - (setsid nohup socat UNIX-LISTEN:"$GPG_AGENT_SOCK,fork" EXEC:"$wsl2_ssh_pageant_bin --gpg S.gpg-agent" >/dev/null 2>&1 &) - else - echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable." - fi - unset wsl2_ssh_pageant_bin - fi - - if ! ss -a | grep -q "${GPG_AGENT_SOCK}.extra"; then - rm -rf "${GPG_AGENT_SOCK}.extra" - wsl2_ssh_pageant_bin="$HOME/.ssh/wsl2-ssh-pageant.exe" - if test -x "$wsl2_ssh_pageant_bin"; then - (setsid nohup socat UNIX-LISTEN:"${GPG_AGENT_SOCK}.extra,fork" EXEC:"$wsl2_ssh_pageant_bin --gpg S.gpg-agent.extra" >/dev/null 2>&1 &) - else - echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable." - fi - unset wsl2_ssh_pageant_bin - fi -) - -start-pageant() { - # TODO: WIP - if ! ss -a | grep -q "${GPG_AGENT_SOCK}.extra"; then - rm -rf "${GPG_AGENT_SOCK}.extra" - wsl2_ssh_pageant_bin="$HOME/.ssh/wsl2-ssh-pageant.exe" - if test -x "$wsl2_ssh_pageant_bin"; then - (setsid nohup socat UNIX-LISTEN:"${GPG_AGENT_SOCK}.extra,fork" EXEC:"$wsl2_ssh_pageant_bin --gpg S.gpg-agent.extra" >/dev/null 2>&1 &) - else - echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable." - fi - unset wsl2_ssh_pageant_bin - fi -} - -# Reload -gpg-reset() { - gpg-connect-agent.exe KILLAGENT /bye &>/dev/null - pkill -f 'socat.*wsl2-ssh-pageant.exe' - gpg-connect-agent.exe /bye &>/dev/null - gpg-init -} - -# Relearn card serial number -gpg-learn() { - gpg-connect-agent.exe "scd serialno" "learn --force" /bye -} - -gpg-init diff --git a/wsl/.config/zsh/wsl.sh b/wsl/.config/zsh/wsl.sh deleted file mode 100644 index 80d93af..0000000 --- a/wsl/.config/zsh/wsl.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash - -WINHOME="/mnt/c/Users/$USER" -[ "$PWD" = "$WINHOME" ] && cd - -mkdir -p /tmp/xdg - -export BROWSER=wslview -export EDITOR="code --wait" -export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0 -export XDG_RUNTIME_DIR=/tmp/xdg - -alias wsl=wsl.exe -alias ykman='/mnt/c/Program\ Files/Yubico/YubiKey\ Manager/ykman.exe' -# python -alias pip2="DISPLAY= pip2" -alias pip3="DISPLAY= pip3" -alias pip3.7="DISPLAY= pip3.7" -alias pip3.10="DISPLAY= pip3.10" -alias pip="DISPLAY= pip3" - -wt() { - powershell.exe -NoProfile -c "wt $@" -} - -wsl_cmd_proxy() { - exe="$1" - shift # past exe - - cmd=" ${1}" - shift # past cmd - - args="" - while [[ $# -gt 0 ]]; do - case "$1" in - -*) - args+="${1} '${2}' " - shift - shift - ;; - *) - args+="'${1}'" - shift - ;; - esac - args+=" " - done - - powershell.exe -NoProfile -c 'cd $HOME;' "$exe" "$cmd" "$args" -} - -winget() { wsl_cmd_proxy "winget.exe" "$@"; } -scoop() { wsl_cmd_proxy "scoop" "$@"; } -alacritty() { wsl_cmd_proxy "alacritty.exe" "$@"; } - -# https://github.com/validatedev/drop-cache-if-idle -[ -z "$(ps -ef | grep cron | grep -v grep)" ] && sudo /etc/init.d/cron start &>/dev/null |