-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0869b7e
commit 3eb8f20
Showing
6 changed files
with
135 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM mcr.microsoft.com/devcontainers/base:ubuntu | ||
# https://learn.microsoft.com/en-us/powershell/scripting/install/install-ubuntu?view=powershell-7.4 | ||
COPY bootstrap.ps1 bootstrap.ps1 | ||
RUN apt-get update \ | ||
&& apt-get install -y wget apt-transport-https software-properties-common \ | ||
&& wget -q https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb \ | ||
&& dpkg -i packages-microsoft-prod.deb \ | ||
&& rm packages-microsoft-prod.deb \ | ||
&& apt-get update \ | ||
&& apt-get install -y powershell \ | ||
&& pwsh -File bootstrap.ps1 | ||
COPY profile.ps1 /opt/microsoft/powershell/7/profile.ps1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.psresourceget/install-psresource?view=powershellget-3.x | ||
# https://devblogs.microsoft.com/powershell/psresourceget-is-generally-available/ | ||
# https://github.com/PowerShell/PSResourceGet | ||
# https://hub.docker.com/_/microsoft-powershell | ||
# https://devblogs.microsoft.com/powershell/powershellget-in-powershell-7-4-updates/ | ||
# http://dahlbyk.github.io/posh-git/ | ||
$ErrorActionPreference = 'Stop' | ||
#$ProgressPreference = 'SilentlyContinue' | ||
#Set-PSResourceRepository -Name PSGallery -Trusted:$true -Scope AllUsers | ||
#Install-PSResource -RequiredResourceFile ./.devcontainer/RequiredResourceFile.psd1 | ||
# PSResourceGet is brand new, posh-git installation is giving me trouble. Not sure if it's a mistake on my part | ||
# or bug with PSResourceGet or posh-git. Leaving it like this for now. | ||
# Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | ||
# Install-Module posh-git -Scope CurrentUser -Force | ||
Install-PSResource -TrustRepository -Scope AllUsers -RequiredResource @{ | ||
'Microsoft.PowerShell.PSResourceGet' = @{ | ||
version = '1.0.2' | ||
repository = 'PSGallery' | ||
} | ||
'Pester' = @{ | ||
version = '5.4.0' | ||
repository = 'PSGallery' | ||
} | ||
'InvokeBuild' = @{ | ||
version = '5.10.2' | ||
repository = 'PSGallery' | ||
} | ||
'PSScriptAnalyzer' = @{ | ||
version = '1.21.0' | ||
repository = 'PSGallery' | ||
} | ||
'platyPS' = @{ | ||
version = '0.12.0' | ||
repository = 'PSGallery' | ||
} | ||
'posh-git' = @{ | ||
version = '1.1.0' | ||
repository = 'PSGallery' | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/powershell | ||
{ | ||
"name": "PowerShell", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"customizations": { | ||
// Configure properties specific to VS Code. | ||
"vscode": { | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"terminal.integrated.defaultProfile.linux": "pwsh" | ||
}, | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"ms-vscode.powershell", | ||
"ryanluker.vscode-coverage-gutters", | ||
"DavidAnson.vscode-markdownlint", | ||
"eriklynd.json-tools", | ||
"redhat.vscode-xml", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Write-Host 'Loading profile...' -ForegroundColor Cyan | ||
Import-Module posh-git | ||
# PSReadline | ||
Set-PSReadLineOption -PredictionSource History | ||
Set-PSReadLineOption -Colors @{ InlinePrediction = '#2F7004' } #green | ||
Set-PSReadLineOption -PredictionViewStyle ListView #you may prefer InlineView | ||
# Custom prompt function | ||
function prompt { | ||
<# | ||
.SYNOPSIS | ||
Custom prompt function. | ||
.EXAMPLE | ||
[2022-JUL-30 21:18][..project-starters\aws\aws-backup-automation][main ≡] | ||
>> | ||
#> | ||
$global:promptDateTime = [datetime]::Now | ||
$Global:promptDate = $global:promptDateTime.ToString('yyyy-MMM-dd').ToUpper() | ||
$Global:promptTime = $global:promptDateTime.ToString('HH:mm') | ||
# truncate the current location if too long | ||
$currentDirectory = $executionContext.SessionState.Path.CurrentLocation.Path | ||
$consoleWidth = [Console]::WindowWidth | ||
$maxPath = [int]($consoleWidth / 4.5) | ||
if ($currentDirectory.Length -gt $maxPath) { | ||
$currentDirectory = '..' + $currentDirectory.SubString($currentDirectory.Length - $maxPath) | ||
} | ||
$global:promptPath = $currentDirectory | ||
|
||
$InGitRepo = Write-VcsStatus | ||
if ($InGitRepo) { | ||
Write-Host "[$global:promptDate $global:promptTime]" -ForegroundColor Green -NoNewline | ||
Write-Host "[$global:promptPath]" -ForegroundColor Magenta -NoNewline | ||
Write-Host $InGitRepo.Trim() -NoNewline | ||
"`r`n>>" | ||
} | ||
else { | ||
Write-Host "[$global:promptDate $global:promptTime]" -ForegroundColor Green -NoNewline | ||
Write-Host "[$global:promptPath]" -ForegroundColor Magenta -NoNewline | ||
"`r`n>>" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# https://code.visualstudio.com/docs/devcontainers/tips-and-tricks#_resolving-git-line-ending-issues-in-containers-resulting-in-many-modified-files | ||
* text=auto eol=lf | ||
*.{cmd,[cC][mM][dD]} text eol=crlf | ||
*.{bat,[bB][aA][tT]} text eol=crlf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"ms-vscode.PowerShell", | ||
"ryanluker.vscode-coverage-gutters", | ||
"DavidAnson.vscode-markdownlint" | ||
] | ||
} | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"ms-vscode.PowerShell", | ||
"ms-vscode-remote.remote-containers", | ||
"ryanluker.vscode-coverage-gutters", | ||
"DavidAnson.vscode-markdownlint", | ||
"eriklynd.json-tools", | ||
"redhat.vscode-xml", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} |