dotfiles

Cross platform dotfiles for linux, mac and windows
git clone git@getsh.org:dotfiles.git
Log | Files | Refs

setup.cmd (2652B)


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