diff options
author | Toby Vincent <tobyv13@gmail.com> | 2022-03-25 23:38:13 -0500 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2022-03-25 23:38:13 -0500 |
commit | e6051a38a672182c7f7dfa083ca1e72b97803c94 (patch) | |
tree | 734e251bab033169399432fe1c93fc879dfab578 /wsl/.config/zsh/wsl.sh | |
parent | bb375ba979dfc0c575443f8309ee52d0fd446a26 (diff) |
feat: migrated to gnu stow
Diffstat (limited to 'wsl/.config/zsh/wsl.sh')
-rw-r--r-- | wsl/.config/zsh/wsl.sh | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/wsl/.config/zsh/wsl.sh b/wsl/.config/zsh/wsl.sh new file mode 100644 index 0000000..80d93af --- /dev/null +++ b/wsl/.config/zsh/wsl.sh @@ -0,0 +1,57 @@ +#!/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 |