aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-03-26 22:53:33 -0500
committerToby Vincent <tobyv13@gmail.com>2022-03-26 22:53:33 -0500
commitda06c20b672c99660e041937fd05c5f73aa06bb6 (patch)
treec33b1ef25466291b95ca0f9ac0e652ad8976aeb2
parent824a5b0eb685673adc44fc138e108ac6d231fa34 (diff)
feat: create zsh-wsl plugin
-rw-r--r--sheldon/.config/sheldon/plugins.toml4
-rw-r--r--wsl/.config/zsh/wsl.sh57
-rw-r--r--[-rwxr-xr-x]wsl/.local/share/zsh-wsl/zsh-wsl.plugin.zsh (renamed from wsl/.config/zsh/gpg.sh)58
3 files changed, 62 insertions, 57 deletions
diff --git a/sheldon/.config/sheldon/plugins.toml b/sheldon/.config/sheldon/plugins.toml
index 297a017..fa4b59f 100644
--- a/sheldon/.config/sheldon/plugins.toml
+++ b/sheldon/.config/sheldon/plugins.toml
@@ -7,6 +7,10 @@ github = 'romkatv/zsh-defer'
defer = { value = 'zsh-defer source "{{ file }}"', each = true }
comp = { value = 'mkdir -p "$XDG_DATA_HOME/zsh/site-functions"; ln -sf "{{ file }}" "$XDG_DATA_HOME/zsh/site-functions/_{{ name }}"', each = true }
+[plugins.zsh-wsl]
+local = '~/.local/share/zsh-wsl'
+apply = ["defer"]
+
[plugins.fast-syntax-highlighting]
github = "zdharma-continuum/fast-syntax-highlighting"
apply = ["defer"]
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
diff --git a/wsl/.config/zsh/gpg.sh b/wsl/.local/share/zsh-wsl/zsh-wsl.plugin.zsh
index ac0bb4c..92b7e5b 100755..100644
--- a/wsl/.config/zsh/gpg.sh
+++ b/wsl/.local/share/zsh-wsl/zsh-wsl.plugin.zsh
@@ -1,6 +1,61 @@
+#!/usr/bin/env bash
+
+[ -n "${WSL_DISTRO_NAME+1}" ] || return 0
+
+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
export SSH_AUTH_SOCK="$HOME/.ssh/agent.sock"
export GPG_AGENT_SOCK="$HOME/.gnupg/S.gpg-agent"
+alias wsl=wsl.exe
+alias ykman='/mnt/c/Program\ Files/Yubico/YubiKey\ Manager/ykman.exe'
+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" "$@"; }
+
gpg-init() (
if ! ss -a | grep -q "$SSH_AUTH_SOCK"; then
rm -f "$SSH_AUTH_SOCK"
@@ -64,3 +119,6 @@ gpg-learn() {
}
gpg-init
+
+# https://github.com/validatedev/drop-cache-if-idle
+[ -z "$(ps -ef | grep cron | grep -v grep)" ] && sudo /etc/init.d/cron start &>/dev/null