Skip to content

Commit b325498

Browse files
authored
Merge pull request #7 from jimbrig/develop
Develop
2 parents 47baab3 + 0b6b2a3 commit b325498

23 files changed

+173
-0
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [unreleased]
5+
6+
### Bug Fixes
7+
8+
- Fix custom keeper commander functions
9+
10+
### Configuration
11+
12+
- Gpg changes due to using git native gpg now
13+
14+
### Documentation
15+
16+
- Release v1.1.0 Changelog
17+
18+
### Features
19+
20+
- Format config.json
21+
- Add keeper-commander functions
22+
- Avoid errors with oh-my-posh theme through erroraction flag
23+
- Silently continue for PSReadLine options
24+
- Tweak aliases
25+
- Add yq cli shell completion
26+
- Add custom dir
27+
- Add new launcher open functions
28+
429
## [1.1.0] - 2021-10-25
530

631
### Configuration

Custom/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
config.json filter=git-crypt diff=git-crypt
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Custom/Update-EveryModule.ps1

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
function Update-EveryModule {
2+
<#
3+
.SYNOPSIS
4+
Updates all modules from the PowerShell gallery.
5+
.DESCRIPTION
6+
Updates all local modules that originated from the PowerShell gallery.
7+
Removes all old versions of the modules.
8+
.PARAMETER ExcludedModules
9+
Array of modules to exclude from updating.
10+
.PARAMETER SkipMajorVersion
11+
Skip major version updates to account for breaking changes.
12+
.PARAMETER KeepOldModuleVersions
13+
Array of modules to keep the old versions of.
14+
.PARAMETER ExcludedModulesforRemoval
15+
Array of modules to exclude from removing old versions of.
16+
The Az module is excluded by default.
17+
.EXAMPLE
18+
Update-EveryModule -excludedModulesforRemoval 'Az'
19+
.NOTES
20+
Created by Barbara Forbes
21+
@ba4bes
22+
.LINK
23+
https://4bes.nl
24+
#>
25+
[cmdletbinding(SupportsShouldProcess = $true)]
26+
param (
27+
[parameter()]
28+
[array]$ExcludedModules = @(),
29+
[parameter()]
30+
[switch]$SkipMajorVersion,
31+
[parameter()]
32+
[switch]$KeepOldModuleVersions,
33+
[parameter()]
34+
[array]$ExcludedModulesforRemoval = @("Az")
35+
)
36+
# Get all installed modules that have a newer version available
37+
Write-Verbose "Checking all installed modules for available updates."
38+
$CurrentModules = Get-InstalledModule | Where-Object { $ExcludedModules -notcontains $_.Name -and $_.repository -eq "PSGallery" }
39+
40+
# Walk through the Installed modules and check if there is a newer version
41+
$CurrentModules | ForEach-Object {
42+
Write-Verbose "Checking $($_.Name)"
43+
Try {
44+
$GalleryModule = Find-Module -Name $_.Name -Repository PSGallery -ErrorAction Stop
45+
}
46+
Catch {
47+
Write-Error "Module $($_.Name) not found in gallery $_"
48+
$GalleryModule = $null
49+
}
50+
if ($GalleryModule.Version -gt $_.Version) {
51+
if ($SkipMajorVersion -and $GalleryModule.Version.Split('.')[0] -gt $_.Version.Split('.')[0]) {
52+
Write-Warning "Skipping major version update for module $($_.Name). Galleryversion: $($GalleryModule.Version), local version $($_.Version)"
53+
}
54+
else {
55+
Write-Verbose "$($_.Name) will be updated. Galleryversion: $($GalleryModule.Version), local version $($_.Version)"
56+
try {
57+
if ($PSCmdlet.ShouldProcess(
58+
("Module {0} will be updated to version {1}" -f $_.Name, $GalleryModule.Version),
59+
$_.Name,
60+
"Update-Module"
61+
)
62+
) {
63+
Update-Module $_.Name -ErrorAction Stop -Force
64+
Write-Verbose "$($_.Name) has been updated"
65+
}
66+
}
67+
Catch {
68+
Write-Error "$($_.Name) failed: $_ "
69+
continue
70+
71+
}
72+
if ($KeepOldModuleVersions -ne $true) {
73+
Write-Verbose "Removing old module $($_.Name)"
74+
if ($ExcludedModulesforRemoval -contains $_.Name) {
75+
Write-Verbose "$($allversions.count) versions of this module found [ $($module.name) ]"
76+
Write-Verbose "Please check this manually as removing the module can cause instabillity."
77+
}
78+
else {
79+
try {
80+
if ($PSCmdlet.ShouldProcess(
81+
("Old versions will be uninstalled for module {0}" -f $_.Name),
82+
$_.Name,
83+
"Uninstall-Module"
84+
)
85+
) {
86+
Get-InstalledModule -Name $_.Name -AllVersions
87+
| Where-Object { $_.version -ne $GalleryModule.Version }
88+
| Uninstall-Module -Force -ErrorAction Stop
89+
Write-Verbose "Old versions of $($_.Name) have been removed"
90+
}
91+
}
92+
catch {
93+
Write-Error "Uninstalling old module $($_.Name) failed: $_"
94+
}
95+
}
96+
}
97+
}
98+
}
99+
elseif ($null -ne $GalleryModule) {
100+
Write-Verbose "$($_.Name) is up to date"
101+
}
102+
}
103+
}

Custom/Update-PowerShell.ps1

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<#
2+
.SYNOPSIS
3+
This will both Install the latest release of PowerShell or update your current PowerShell.
4+
.DESCRIPTION
5+
This one-liner is provided by [Tyler Leonhardt](https://github.com/TylerLeonhardt). I have added some parameters to help customize the install of the .MSI
6+
.PARAMETER Preview
7+
Specifying this switch will install the latest preview version of PowerShell. Otherwise this will install / update the latest stable release.
8+
.PARAMETER Quiet
9+
Specifying this switch will install or update quietly with no gui popup, taking all defaults of the install. You need to run as admin to use this switch.
10+
.EXAMPLE
11+
PS> Update-Powershell -Preview
12+
13+
Description
14+
-----------
15+
This will update or install PowerShell with the latest Preview release.
16+
.EXAMPLE
17+
PS> Update-Powershell -Quiet
18+
19+
Description
20+
-----------
21+
This will update or install the latest General Release version of PowerShell.
22+
.NOTES
23+
No support for external package managers like chocolatey, scoop, or WinGet. Uses core MSI installer with flags.
24+
#>
25+
Function Update-PowerShell() {
26+
[CmdletBinding()]
27+
param(
28+
[switch] $Preview,
29+
[switch] $Quiet
30+
)
31+
if ($PSBoundParameters.ContainsKey('Preview')) { $PreviewOption = '-Preview' }
32+
if ($PSBoundParameters.ContainsKey('Quiet')) { $QuietOption = '-Quiet' }
33+
Invoke-Expression -Command "& {$(Invoke-RestMethod https://aka.ms/install-powershell.ps1)} -UseMSI $PreviewOption $QuietOption"
34+
}
File renamed without changes.
File renamed without changes.

Profile/functions.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# ----------
2+
# Launchers
3+
# ----------
4+
5+
Function Open-Todoist { start-process -PassThru 'C:\Users\jimmy\AppData\Local\Programs\todoist\Todoist.exe' }
6+
7+
Function Open-GitHub { start-process -PassThru 'https://github.com/' }
8+
9+
Function Open-Docker { start-process -PassThru 'C:\Program Files\Docker\Docker\frontend\Docker Desktop.exe' }
10+
111
# ---------------------------------
212
# PowerShell Core Profile Functions
313
# ---------------------------------

0 commit comments

Comments
 (0)