From 0ef8aa01e7a0d62ec519322e0271d051c15e1e47 Mon Sep 17 00:00:00 2001 From: Valerie Wolfe Date: Thu, 22 Aug 2024 09:27:15 -0400 Subject: [PATCH] scripts: added 'cmd.sh' --- README.md | 1 + scripts/cmd.sh | 21 +++++++++++++++++++++ scripts/justfile | 1 + 3 files changed, 23 insertions(+) create mode 100755 scripts/cmd.sh diff --git a/README.md b/README.md index 490d8ee..8d0d487 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ A feature-barren DOS clone of `ls` that hides Windows hidden files. Relies on ## Scripts +- `cmd.sh`: Simple wrapper for `cmd.exe`. - `dos.sh`: Simple wrapper for executing Windows commands directly. - `elevate.sh`: Elevate WSL (`-l`) or Windows (`-w`) commands from WSL. - `explorer.sh`: Launch explorer from WSL. diff --git a/scripts/cmd.sh b/scripts/cmd.sh new file mode 100755 index 0000000..9f8c09d --- /dev/null +++ b/scripts/cmd.sh @@ -0,0 +1,21 @@ +#!/usr/bin/bash + +if [ "$#" -eq 0 ]; then + args='' + for arg in $@; do + if [[ $arg =~ ^-.+$ ]]; then + transform=(${arg//-//}) + if [[ $arg =~ ^-.+=.+$ ]]; then + transform=(${transform//=/:}) + fi + args="$args $transform" + else + args="$args $arg" + fi + done + + /mnt/c/Windows/System32/cmd.exe $args +else + /mnt/c/Windows/System32/cmd.exe +fi + diff --git a/scripts/justfile b/scripts/justfile index 5f687ea..bb71ad0 100644 --- a/scripts/justfile +++ b/scripts/justfile @@ -2,6 +2,7 @@ alias i := install install DIR="~/.bin": + cp cmd.sh {{DIR}}/cmd cp dos.sh {{DIR}}/dos cp elevate.sh {{DIR}}/elevate cp explorer.sh {{DIR}}/explorer