|
| 1 | +@echo off |
| 2 | +setlocal enabledelayedexpansion |
| 3 | + |
| 4 | +:: Store the original directory |
| 5 | +set "ORIGINAL_DIR=%CD%" |
| 6 | + |
| 7 | +:: Change to the directory where the script resides |
| 8 | +cd /d %~dp0 |
| 9 | + |
| 10 | +set "targetPath=%USERPROFILE%\AppData\Roaming\Python\Python312\Scripts" |
| 11 | +set "found=0" |
| 12 | + |
| 13 | +:: Iterate over each entry in PATH |
| 14 | +for %%A in ("%PATH:;=" "%") do ( |
| 15 | + if /i "%%~A"=="!targetPath!" ( |
| 16 | + set "found=1" |
| 17 | + echo The path is already included in the PATH. |
| 18 | + goto :checkDone |
| 19 | + ) |
| 20 | +) |
| 21 | + |
| 22 | +if "!found!"=="0" ( |
| 23 | + rem The target path is not in the PATH, so we will append it |
| 24 | + echo Appending "!targetPath!" to the PATH... |
| 25 | + setx PATH "%PATH%;!targetPath!" |
| 26 | + rem Update the current session PATH variable |
| 27 | + set "PATH=%PATH%;!targetPath!" |
| 28 | +) |
| 29 | + |
| 30 | +:checkDone |
| 31 | + |
| 32 | +call :ConfigureGit |
| 33 | +call :ConfigureVSCode |
| 34 | +call :ConfigurePreCommit |
| 35 | + |
| 36 | +echo running pre-commit checks on all Files |
| 37 | +pre-commit run -a |
| 38 | + |
| 39 | +:: Change back to the original directory |
| 40 | +cd /d %ORIGINAL_DIR% |
| 41 | + |
| 42 | +echo Script completed successfully. |
| 43 | +exit /b |
| 44 | + |
| 45 | +:ConfigureGit |
| 46 | +echo Configuring Git settings... |
| 47 | +git config --local commit.gpgsign true |
| 48 | +git config --local diff.tool meld |
| 49 | +git config --local diff.astextplain.textconv astextplain |
| 50 | +git config --local merge.tool meld |
| 51 | +git config --local difftool.prompt false |
| 52 | +git config --local mergetool.prompt false |
| 53 | +git config --local mergetool.meld.cmd "meld \"$LOCAL\" \"$MERGED\" \"$REMOTE\" --output \"$MERGED\"" |
| 54 | +git config --local core.autocrlf false |
| 55 | +git config --local core.fscache true |
| 56 | +git config --local core.symlinks false |
| 57 | +git config --local core.editor "code" |
| 58 | +git config --local alias.graph1 "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all" |
| 59 | +git config --local alias.graph2 "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all" |
| 60 | +git config --local alias.graph "!git graph1" |
| 61 | +git config --local alias.co checkout |
| 62 | +git config --local alias.st status |
| 63 | +git config --local alias.cm "commit -m" |
| 64 | +git config --local alias.pom "push origin master" |
| 65 | +git config --local alias.aa "add --all" |
| 66 | +git config --local alias.df diff |
| 67 | +git config --local alias.su "submodule update --init --recursive" |
| 68 | +git config --local credential.helper manager |
| 69 | +git config --local pull.rebase true |
| 70 | +git config --local push.autoSetupRemote |
| 71 | +git config --local init.defaultbranch master |
| 72 | +git config --local sequence.editor "code --wait" |
| 73 | +echo Git configuration applied successfully. |
| 74 | +goto :eof |
| 75 | + |
| 76 | +:ConfigurePreCommit |
| 77 | +echo Installing pre-commit tools into the Ubuntu running inside WSL2... |
| 78 | +wsl --exec bash -c "./wsl_install.bash" |
| 79 | +echo Setting pre-commit... |
| 80 | +pip3 install pre-commit |
| 81 | +pre-commit install |
| 82 | +echo Pre-commit done. |
| 83 | +goto :eof |
| 84 | + |
| 85 | +:ConfigureVSCode |
| 86 | +:: Check for VSCode installation and install extensions |
| 87 | +echo Checking for VSCode... |
| 88 | +where code >nul |
| 89 | +IF %ERRORLEVEL% NEQ 0 ( |
| 90 | + echo VSCode is not installed. Please install VSCode before running this script. |
| 91 | + pause |
| 92 | + exit /b |
| 93 | +) ELSE ( |
| 94 | + echo Installing the markdownlint VSCode extension... |
| 95 | + cmd /c code --install-extension davidanson.vscode-markdownlint |
| 96 | + IF %ERRORLEVEL% NEQ 0 ( |
| 97 | + echo Failed to install markdownlint extension. |
| 98 | + pause |
| 99 | + exit /b |
| 100 | + ) |
| 101 | + echo Installing the Markdown Preview Enhanced extension... |
| 102 | + cmd /c code --install-extension shd101wyy.markdown-preview-enhanced |
| 103 | + IF %ERRORLEVEL% NEQ 0 ( |
| 104 | + echo Failed to install Markdown Preview Enhanced extension. |
| 105 | + pause |
| 106 | + exit /b |
| 107 | + ) |
| 108 | + |
| 109 | + echo Installing GitHub Copilot... |
| 110 | + cmd /c code --install-extension GitHub.copilot |
| 111 | + IF %ERRORLEVEL% NEQ 0 ( |
| 112 | + echo Failed to install GitHub Copilot extension. |
| 113 | + pause |
| 114 | + exit /b |
| 115 | + ) |
| 116 | + |
| 117 | + echo Installing the Conventional Commits VSCode extension... |
| 118 | + cmd /c code --install-extension vivaxy.vscode-conventional-commits |
| 119 | + IF %ERRORLEVEL% NEQ 0 ( |
| 120 | + echo Failed to install Conventional Commits VSCode extension. |
| 121 | + pause |
| 122 | + exit /b |
| 123 | + ) |
| 124 | + |
| 125 | + echo Installing the GitLens VSCode extension... |
| 126 | + cmd /c code --install-extension eamodio.gitlens |
| 127 | + IF %ERRORLEVEL% NEQ 0 ( |
| 128 | + echo Failed to install GitLens VSCode extension. |
| 129 | + pause |
| 130 | + exit /b |
| 131 | + ) |
| 132 | + |
| 133 | +) |
| 134 | +goto :eof |
0 commit comments