Skip to content

Instantly share code, notes, and snippets.

@richard-scott
Last active November 22, 2018 13:42
Show Gist options
  • Save richard-scott/bb924032d253c4339001d4bb3196af63 to your computer and use it in GitHub Desktop.
Save richard-scott/bb924032d253c4339001d4bb3196af63 to your computer and use it in GitHub Desktop.
Download GitHub Repos for KiCad
Installation
------------
1. Create a KiCad folder somewhere on your system, and then create a shortcut to that folder in your $HOME folder.
2. Download "update-kicad-repos.ps1" and move to your KiCad folder e.g. C:\Program Files\KiCad
3. Download "update-kicad-repos.xml" and import as a new task in Task Scheduler.
4. Select for the task to run whether user is logged on or not.
5. Setup a trigger (otherwise it won't automatically run).
6. Click OK and enter the password for the current user.
7. Find "Update KiCad Repos" in the list, right click and click Run.
8. Look in the target folder you created in step #1, and there should be new files.
9. Update your library paths as required in KiCad.
$repos = @()
$repos += "https://github.com/KiCad/kicad-symbols.git"
$repos += "https://github.com/KiCad/kicad-footprints.git"
$repos += "https://github.com/KiCad/kicad-packages3D.git"
$repos += "https://github.com/KiCad/kicad-packages3D-source.git"
$repos += "https://github.com/KiCad/kicad-templates.git"
$repos += "https://github.com/sparkfun/SparkFun-KiCad-Libraries.git"
$repos += "https://github.com/digikey/digikey-kicad-library.git"
$repos += "https://github.com/SchrodingersGat/KiBoM.git"
function cd_link($target)
{
if($target.EndsWith(".lnk"))
{
$sh = new-object -com wscript.shell
$fullpath = resolve-path $target
$targetpath = $sh.CreateShortcut($fullpath).TargetPath
set-location $targetpath
}
else {
set-location $target
}
}
if ((Test-Path -Path "$HOME\KiCad.lnk"))
{
cd_link "$HOME\KiCad.lnk"
}
else
{
exit
}
foreach ($repo in $repos) {
if (-Not (Test-Path -Path (Split-Path -Leaf $repo).split('\.')[-2]))
{
Invoke-Expression "& git clone --no-tags --depth 1 $repo" 2>&1 | Out-Null
}
}
Get-ChildItem . -Attributes Directory,Directory+Hidden -ErrorAction SilentlyContinue -Include ".git" -Recurse | ForEach {
cd $(Split-Path -Parent $_)
Invoke-Expression "& git pull" 2>&1 | Out-Null
}
if (-Not (Test-Path -Path "$HOME\AppData\Roaming\kicad"))
{
New-Item -Path "$HOME\AppData\Roaming\kicad" -ItemType directory
}
cd_link "$HOME\KiCad.lnk"
if ((Test-Path -Path "kicad-symbols/sym-lib-table"))
{
Copy-Item "kicad-symbols/sym-lib-table" -Destination "$HOME\AppData\Roaming\kicad\sym-lib-table" -Force
}
if ((Test-Path -Path "kicad-footprints/fp-lib-table"))
{
Copy-Item "kicad-footprints/fp-lib-table" -Destination "$HOME\AppData\Roaming\kicad\fp-lib-table" -Force
}
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<Actions Context="Author">
<Exec>
<Command>powershell.exe</Command>
<Arguments>-ExecutionPolicy Bypass -NoLogo -File "C:\Program Files\KiCad\update-kicad-repos.ps1"</Arguments>
</Exec>
</Actions>
</Task>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment