-
Notifications
You must be signed in to change notification settings - Fork 10
/
start.bat
47 lines (38 loc) · 1.26 KB
/
start.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@echo off
setlocal
set ARGS="%*"
set REPO="https://github.com/XternA/income-generator.git"
set TOOL_DIR="~/.igm"
where winget >nul 2>&1
if %errorlevel% neq 0 (
echo No winget found on the system. Please install winget before proceeding.
exit /b 1
)
where winget >nul 2>&1
if %errorlevel% neq 0 (
echo No git found on the system. Attempting to install git...
winget install -i Git.Git
)
where wsl >nul 2>&1
if %errorlevel% neq 0 (
echo No Windows Subsystem for Linux found on the system. Ensure WSL is enabled before proceeding.
exit /b 1
)
call :CheckAndRegisterAlias
wsl ${SHELL##*/} -ilc "echo; [ ! -d %TOOL_DIR% ] && git clone --depth=1 %REPO% %TOOL_DIR%; sleep 3; igm %ARGS%"
exit /b 0
REM -- Sub-calls -------------
:CheckAndRegisterAlias
wsl -e sh -c "[ -f $HOME/.aliases ]"
if %errorlevel% equ 0 (
wsl grep -q "alias igm=" "$HOME/.aliases" || call :RegisterToAliases
) else (
wsl grep -q "alias igm=" "$HOME/.${SHELL##*/}rc" || call :RegisterToRC
)
exit /b 0
:RegisterToAliases
wsl -e sh -c "echo 'alias igm=\"sh -c '\''cd %TOOL_DIR%; sh start.sh \\\"\\$@\\\"'\'' --\"' >> $HOME/.aliases"
exit /b 0
:RegisterToRC
wsl -e sh -c "echo 'alias igm=\"sh -c '\''cd %TOOL_DIR%; sh start.sh \\\"\\$@\\\"'\'' --\"' >> $HOME/.${SHELL##*/}rc"
exit /b 0