diff options
-rw-r--r-- | shell/wsl.sh | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/shell/wsl.sh b/shell/wsl.sh index 100deaf..06e2d7e 100644 --- a/shell/wsl.sh +++ b/shell/wsl.sh @@ -20,37 +20,44 @@ alias wsl=wsl.exe alias ykman='/mnt/c/Program\ Files/Yubico/YubiKey\ Manager/ykman.exe' alias dmu="docker-machine-wsl" -function docker-machine-wsl() { +docker-machine-wsl() { docker-machine-use $@ export DOCKER_HOST=${DOCKER_HOST:-tcp://0.0.0.0:2375} export DOCKER_MACHINE_NAME=${DOCKER_MACHINE_NAME:-$HOST} } -function wt() { +wt() { powershell.exe -NoProfile -c "wt $@" } -function winget() { - cmd="winget.exe $1" +wsl_cmd_proxy() { + exe="$1" + shift # past exe + + cmd=" ${1}" shift # past cmd + args="" while [[ $# -gt 0 ]]; do - key="$1" - case $key in - -*) # key value pair - cmd+=" $key '$2'" - shift # past argument - shift # past value + case "$1" in + -*) + args+="${1} '${2}' " + shift + shift ;; - *) # positional argument - cmd+=" '$1'" # add it to the list - shift # past argument + *) + args+="'${1}'" + shift ;; esac + args+=" " done - - powershell.exe -NoProfile -c "$cmd" + + powershell.exe -NoProfile -c 'cd $HOME;' "$exe" "$cmd" "$args" } +function winget { wsl_cmd_proxy "winget.exe" "$@"; } +function scoop { wsl_cmd_proxy "scoop" "$@"; } + # https://github.com/validatedev/drop-cache-if-idle [ -z "$(ps -ef | grep cron | grep -v grep)" ] && sudo /etc/init.d/cron start &>/dev/null |