setup.cmd (2764B)
1 @echo on 2 rem TODO Make this work for Administrator accounts 3 4 5 goto :main 6 7 :set_var 8 set _tail=%* 9 call set _tail=%%_tail:*%1 =%% 10 echo Setting "%~1" to "%_tail%" 11 setx %~1 "%_tail%" 12 set %~1=%_tail% 13 goto :eof 14 15 :add_path 16 for /f "tokens=2* skip=2" %%i in ('reg query HKCU\Environment /v PATH') do ( 17 echo %%j | find /i "%~1" || call :set_var PATH %%j;%~1 18 ) 19 goto :eof 20 21 :update_shim <shim_file> <path> <args> 22 echo path = "%~2"> %~1 23 echo args = %~3>> %~1 24 goto :eof 25 26 :main 27 where scoop >nul 2>&1 28 if not %errorlevel% equ 0 ( 29 rem Run this in powershell, before 30 echo Run this in powershell to install scoop and run this script again: 31 echo Set-ExecutionPolicy RemoteSigned -scope CurrentUser 32 echo powershell -Command "Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')" 33 rem Install only the absolute essentials 34 echo scoop config shim 71 35 echo scoop reset -a 36 echo scoop install 7zip clink dos2unix grep gpg lf make mingit mpv sed sudo unzip vim 37 exit 1 38 ) 39 40 @call %~dp0\..\profile.cmd %1 41 42 call :set_var XDG_ROOT %USERPROFILE% 43 if NOT "%1" == "" call :set_var XDG_ROOT "" 44 45 call :add_path "C:\bin" 46 call :set_var XDG_ROOT %USERPROFILE% 47 call :set_var XDG_CONFIG_HOME %XDG_ROOT%\.config 48 call :set_var XDG_DATA_HOME %XDG_ROOT%\.local\share 49 call :set_var XDG_CACHE_HOME %XDG_ROOT%\.cache 50 call :set_var SCOOP %XDG_ROOT%\scoop 51 52 call :set_var VISUAL vim 53 call :set_var EDITOR %VISUAL% 54 55 call :set_var GNUPGHOME %XDG_DATA_HOME%\gnupg 56 call :set_var GPGHOME %XDG_DATA_HOME%\gnupg 57 call :set_var PASSWORD_STORE_DIR %XDG_DATA_HOME%\pass 58 call :set_var PASS_BASE_DIR %XDG_DATA_HOME%\pass 59 60 call :set_var LYNX_CFG %XDG_CONFIG_HOME%/lynx/lynx.cfg 61 call :set_var LYNX_LSS %XDG_CONFIG_HOME%/lynx/lynx.lss 62 63 call :set_var FUZZER fzf 64 65 call :add_path %USERPROFILE%\.local\bin\cmd 66 67 rem Apply config patches 68 rem TODO Use mklink instead of xcopy, it will prevent overriding changed files in the destination dir. 69 xcopy /Y %USERPROFILE%\.config\cmd\patch %USERPROFILE%\ /S /E 70 71 mkdir %SYSTEMDRIVE%\bin 72 if EXIST "%SCOOP%\apps\busybox\current\busybox.exe" ( 73 copy "%SCOOP%\apps\busybox\current\busybox.exe" %SYSTEMDRIVE%\bin 74 copy "%SCOOP%\apps\scoop\current\supporting\shims\71\shim.exe" %SYSTEMDRIVE%\bin\sh.exe 75 call :update_shim C:\bin\sh.shim "C:\bin\busybox.exe" "sh -l" 76 ) 77 if EXIST "%SCOOP%\apps\lynx\current\lynx.exe" ( 78 call :update_shim "%SCOOP%\shims\lynx.shim" "%SCOOP%\apps\lynx\current\lynx.exe" "-cfg %XDG_CONFIG_HOME%\lynx\lynx.cfg" 79 ) 80 81 rem TODO Report this in scoop and remove this line 82 del %SCOOP%\apps\gpg\current\bin\gpgconf.ctl 83 84 call clink autorun install -- clink inject -q 85 call clink set clink.autostart "%XDG_CONFIG_HOME%\profile.cmd" 86 call clink set clink.autoupdate off 87