|
1 | 1 | @echo off
|
2 |
| - |
3 |
| -REM ----------------------.vimrc--------------------------- |
| 2 | +setlocal |
4 | 3 | pushd %~dp0
|
5 |
| -fsutil hardlink list .vimrc|findstr "%HOMEPATH%" 2>&1>nul |
6 |
| -IF %ERRORLEVEL% == 0 ( |
7 |
| - echo .vimrc was already linked |
8 |
| -) ELSE ( |
9 |
| - IF EXIST "%USERPROFILE%\\\.vimrc" ( |
| 4 | + |
| 5 | +REM ------------------------python------------------------- |
| 6 | +py --version 2>&1>nul |
| 7 | +if not errorlevel 0 ( |
| 8 | + winget install Python -e --source winget |
| 9 | + if errorlevel == 1 ( |
| 10 | + echo [FAIL] Python not found and could not be installed |
| 11 | + set FAIL=1 |
| 12 | + ) else ( |
| 13 | + echo [ OK ] Python not found and could not be installed |
| 14 | + ) |
| 15 | +) else ( |
| 16 | + echo [ OK ] Python ok |
| 17 | +) |
| 18 | + |
| 19 | +REM -------------------------git--------------------------- |
| 20 | +where git | find "git.exe" 2>&1>nul |
| 21 | +if errorlevel == 1 ( |
| 22 | + winget install --id Git.Git -e --source winget |
| 23 | + if errorlevel == 1 ( |
| 24 | + echo [FAIL] Git not found and could not be installed |
| 25 | + set FAIL=1 |
| 26 | + ) else ( |
| 27 | + echo [ OK ] Git not found and could not be installed |
| 28 | + ) |
| 29 | +) else ( |
| 30 | + echo [ OK ] Git ok |
| 31 | +) |
| 32 | + |
| 33 | + |
| 34 | +REM --------------------- .vimrc -------------------------- |
| 35 | +set TARGET=%HOMEPATH%\.vimrc |
| 36 | +fsutil hardlink list .vimrc | find "%TARGET%" 2>&1>nul |
| 37 | +if errorlevel == 1 ( |
| 38 | + if EXIST %TARGET% ( |
10 | 39 | set BKPFILENAME=.vimrc-backup-%DATE:/=-%-%TIME::=.%
|
11 |
| - echo The file ' %USERPROFILE%\.vimrc' exists and is not linked to %CD%\.vimrc |
12 |
| - echo Renaming it to '%BKPFILENAME%' up the existing file before creating the link |
13 |
| - ren %USERPROFILE%\.vimrc %BKPFILENAME% |
| 40 | + echo The file '%TARGET%' already exists and will be renamed to '%BKPFILENAME%' |
| 41 | + ren "%TARGET%" "%BKPFILENAME%" |
| 42 | + ) |
| 43 | + |
| 44 | + mklink /h "%TARGET%" .vimrc 2>&1>nul |
| 45 | + if errorlevel == 0 ( |
| 46 | + echo [ OK ] %TARGET% [link created] |
| 47 | + ) else ( |
| 48 | + echo [FAIL] %TARGET% link could not be created |
| 49 | + set FAIL=1 |
14 | 50 | )
|
15 |
| - mklink /h %USERPROFILE%\.vimrc .vimrc |
| 51 | +) else ( |
| 52 | + echo [ OK ] %TARGET% |
16 | 53 | )
|
17 | 54 |
|
18 |
| -if NOT EXIST %LOCALAPPDATA%\nvim mkdir %LOCALAPPDATA%\nvim |
19 | 55 |
|
20 | 56 | REM ---------------------init.vim--------------------------
|
21 |
| -fsutil hardlink list init.vim|findstr "%LOCALAPPDATA:~2%\nvim\init\.vim" 2>&1>NUL |
22 |
| -IF %ERRORLEVEL% == 0 ( |
23 |
| - echo init.vim was already linked |
24 |
| -) ELSE ( |
25 |
| - IF EXIST "%LOCALAPPDATA%\nvim\init.vim" ( |
| 57 | +if NOT EXIST %LOCALAPPDATA%\nvim mkdir %LOCALAPPDATA%\nvim |
| 58 | +set TARGET=%LOCALAPPDATA:~2%\nvim\init.vim |
| 59 | +fsutil hardlink list init.vim | find "%TARGET%" 2>&1>NUL |
| 60 | +if errorlevel == 1 ( |
| 61 | + if EXIST %TARGET% ( |
26 | 62 | set BKPFILENAME=init.vim-backup-%DATE:/=-%-%TIME::=.%
|
27 |
| - echo The file ' %LOCALAPPDATA%\nvim\init.vim' exists and is not linked to %CD%\init.vim |
28 |
| - echo Renaming it to '%BKPFILENAME%' up the existing file before creating the link |
29 |
| - ren %LOCALAPPDATA%\nvim\init.vim %BKPFILENAME% |
| 63 | + echo The file '%TARGET%' already exists and will be renamed to '%BKPFILENAME%' |
| 64 | + ren "%TARGET%" "%BKPFILENAME%" |
30 | 65 | )
|
31 |
| - mklink /h %LOCALAPPDATA%\nvim\init.vim init.vim |
| 66 | + |
| 67 | + mklink /h "%TARGET%" init.vim 2>&1>nul |
| 68 | + if errorlevel == 0 ( |
| 69 | + echo [ OK ] %TARGET% [link created] |
| 70 | + ) else ( |
| 71 | + echo [FAIL] %TARGET% link could not be created |
| 72 | + set FAIL=1 |
| 73 | + ) |
| 74 | +) else ( |
| 75 | + echo [ OK ] %TARGET% |
32 | 76 | )
|
33 | 77 |
|
34 |
| -REM ---------------------ginit.vim------------------------- |
35 |
| -fsutil hardlink list ginit.vim|findstr "%LOCALAPPDATA:~2%\nvim\ginit\.vim" 2>&1>NUL |
36 |
| -IF %ERRORLEVEL% == 0 ( |
37 |
| - echo ginit.vim was already linked |
38 |
| -) ELSE ( |
39 |
| - IF EXIST "%LOCALAPPDATA%\nvim\ginit.vim" ( |
| 78 | +REM ---------------------ginit.vim-------------------------- |
| 79 | +set TARGET=%LOCALAPPDATA:~2%\nvim\ginit.vim |
| 80 | +fsutil hardlink list ginit.vim | find "%TARGET%" 2>&1>NUL |
| 81 | +if errorlevel == 1 ( |
| 82 | + if EXIST %TARGET% ( |
40 | 83 | set BKPFILENAME=ginit.vim-backup-%DATE:/=-%-%TIME::=.%
|
41 |
| - echo The file ' %LOCALAPPDATA%\nvim\ginit.vim' exists and is not linked to %CD%\ginit.vim |
42 |
| - echo Renaming it to '%BKPFILENAME%' up the existing file before creating the link |
43 |
| - ren %LOCALAPPDATA%\nvim\ginit.vim %BKPFILENAME% |
| 84 | + echo The file '%TARGET%' already exists and will be renamed to '%BKPFILENAME%' |
| 85 | + ren "%TARGET%" "%BKPFILENAME%" |
| 86 | + ) |
| 87 | + |
| 88 | + mklink /h "%TARGET%" ginit.vim 2>&1>nul |
| 89 | + if errorlevel == 0 ( |
| 90 | + echo [ OK ] %TARGET% [link created] |
| 91 | + ) else ( |
| 92 | + echo [FAIL] %TARGET% link could not be created |
| 93 | + set FAIL=1 |
44 | 94 | )
|
45 |
| - mklink /h %LOCALAPPDATA%\nvim\ginit.vim ginit.vim |
| 95 | +) else ( |
| 96 | + echo [ OK ] %TARGET% |
46 | 97 | )
|
47 | 98 |
|
48 |
| -REM ------------------------.vim--------------------------- |
49 |
| -dir /AL %USERPROFILE%\ | findstr %CD%\\\.vim 2>&1>NUL |
50 |
| -IF %ERRORLEVEL% == 0 ( |
51 |
| - echo .vim folder was already linked |
52 |
| -) ELSE ( |
53 |
| - IF EXIST "%USERPROFILE%\.vim" ( |
| 99 | +REM ---------------------.vim folder------------------------ |
| 100 | +set TARGET=%USERPROFILE:~2%\.vim |
| 101 | +dir /AL %USERPROFILE%\ | find "%CD%\.vim" 2>&1>NUL |
| 102 | +if errorlevel == 1 ( |
| 103 | + if EXIST %TARGET% ( |
54 | 104 | set BKPFILENAME=.vim-backup-%DATE:/=-%-%TIME::=.%
|
55 |
| - echo The fodler ' %USERPROFILE%\.vim' exists and is not linked to %CD%\.vim |
56 |
| - echo Renaming it to '%BKPFILENAME%' up the existing file before creating the link |
57 |
| - ren %USERPROFILE%\.vim %BKPFILENAME% |
| 105 | + echo The folder '%TARGET%' already exists and will be renamed to '%BKPFILENAME%' |
| 106 | + ren "%TARGET%" "%BKPFILENAME%" |
| 107 | + ) |
| 108 | + |
| 109 | + mklink /j "%TARGET%" "%CD%\.vim" |
| 110 | + if errorlevel == 0 ( |
| 111 | + echo [ OK ] %TARGET% [link created] |
| 112 | + ) else ( |
| 113 | + echo [FAIL] %TARGET% link could not be created |
| 114 | + set FAIL=1 |
58 | 115 | )
|
59 |
| - mklink /j %USERPROFILE%\.vim %CD%\.vim |
| 116 | +) else ( |
| 117 | + echo [ OK ] %TARGET% |
| 118 | +) |
| 119 | + |
| 120 | +if not defined FAIL ( |
| 121 | + echo "Vim will open to install packages..." |
| 122 | + nvim-qt -- -c PlugInstall |
60 | 123 | )
|
0 commit comments