Update all powershell code blocks to bash
Provides better highlighting with the version mdbook is using.
This commit is contained in:
parent
653a644408
commit
8a10e4f8e5
|
@ -4,12 +4,12 @@
|
|||
- `dotnet new list`
|
||||
- `dotnet new gitignore` adds a .gitignore to the current directory.
|
||||
|
||||
```powershell
|
||||
```bash
|
||||
# View .NET installed versions and information.
|
||||
dotnet --info
|
||||
```
|
||||
|
||||
```powershell
|
||||
```bash
|
||||
# Restore packages.
|
||||
dotnet restore
|
||||
|
||||
|
@ -17,7 +17,9 @@ dotnet watch run
|
|||
```
|
||||
|
||||
## Environment variables
|
||||
```powershell
|
||||
```bash
|
||||
# launchSettings.json can typically set these.
|
||||
# See https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-7.0#development-and-launchsettingsjson
|
||||
$Env:ASPNETCORE_ENVIRONMENT = "Development"
|
||||
$Env:NETCORE_ENVIRONMENT = "Development"
|
||||
```
|
||||
|
@ -27,7 +29,7 @@ The `ASPNETCORE_ENVIRONMENT` value overrides `DOTNET_ENVIRONMENT`.
|
|||
## Entity Framework Core Tools
|
||||
[CLI reference](https://docs.microsoft.com/en-us/ef/core/cli/dotnet).
|
||||
|
||||
```powershell
|
||||
```bash
|
||||
# Install a tool globally.
|
||||
dotnet tool install --global dotnet-ef
|
||||
|
||||
|
@ -42,7 +44,7 @@ dotnet tool search searchTerm
|
|||
```
|
||||
|
||||
## Add SQLite
|
||||
```powershell
|
||||
```bash
|
||||
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
|
||||
dotnet add package Microsoft.EntityFrameworkCore.Design
|
||||
```
|
||||
|
@ -93,7 +95,7 @@ using (var scope = app.Services.CreateScope()) {
|
|||
```
|
||||
|
||||
### Create Initial Migration
|
||||
```powershell
|
||||
```bash
|
||||
dotnet ef migrations add InitialCreate -o Data/Migrations
|
||||
dotnet ef database update
|
||||
```
|
||||
|
@ -101,7 +103,7 @@ dotnet ef database update
|
|||
## Example: .NET API with Angular Frontend and XUnit Testing
|
||||
This example sets up a new .NET webapi project with XUnit testing and an Angular frontend.
|
||||
|
||||
```powershell
|
||||
```bash
|
||||
# From repo root:
|
||||
dotnet new sln
|
||||
dotnet new webapi -o API
|
||||
|
@ -125,12 +127,12 @@ git commit -m "Add new Angular application"
|
|||
```
|
||||
|
||||
## Running via Windows Terminal
|
||||
```powershell
|
||||
```bash
|
||||
wt -d .\ --title 'Repo Root' `; nt -d .\client\ --title 'ng serve' `; split-pane -H -d .\API\ --title 'dotnet watch run' `; nt -d .\client\src\app\ --title 'ng g ...'`; nt -d .\client\ --title 'ng test' `; split-pane -H -d .\ --title 'dotnet test'
|
||||
```
|
||||
|
||||
### Alternatively
|
||||
```powershell
|
||||
```bash
|
||||
# From repo root:
|
||||
cd .\API\
|
||||
dotnet run
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Go
|
||||
|
||||
```powershell
|
||||
```bash
|
||||
# Initialize a new module.
|
||||
go mod init example.com/hello
|
||||
|
||||
|
@ -25,7 +25,7 @@ go install
|
|||
```
|
||||
|
||||
## Information
|
||||
```powershell
|
||||
```bash
|
||||
# Get Go's version.
|
||||
go version
|
||||
|
||||
|
@ -37,7 +37,7 @@ go env
|
|||
```
|
||||
|
||||
## Requirements
|
||||
```powershell
|
||||
```bash
|
||||
# Update go.mod to point a module to a local directory.
|
||||
go mod edit -replace example.com/greetings=../greetings
|
||||
|
||||
|
@ -49,7 +49,7 @@ go get .
|
|||
```
|
||||
|
||||
## Workspaces
|
||||
```powershell
|
||||
```bash
|
||||
# Initialize a workspace with an existing module.
|
||||
go work init ./hello
|
||||
|
||||
|
@ -58,13 +58,13 @@ go work use ./example
|
|||
```
|
||||
|
||||
## Utilities
|
||||
```powershell
|
||||
```bash
|
||||
# Generate a TLS/SSL cert. Get GOPATH from `go env`.
|
||||
go run 'C:\Program Files\Go\src\crypto\tls\generate_cert.go' --rsa-bits=2048 --host=localhost
|
||||
```
|
||||
|
||||
## Testing
|
||||
```powershell
|
||||
```bash
|
||||
# Get basic test coverage, per file.
|
||||
go test -cover ./...
|
||||
|
||||
|
|
|
@ -2,53 +2,53 @@
|
|||
|
||||
List all files with a particular extension in the current directory and its children, with results sorted by full file name.
|
||||
|
||||
```powershell
|
||||
```bash
|
||||
Get-ChildItem -Path .\ -Filter *.sln -Recurse -File | Select Fullname | Sort-Object Fullname
|
||||
```
|
||||
|
||||
List the 10 largest files in the current directory and subdirectories.
|
||||
```powershell
|
||||
```bash
|
||||
gci -r | sort Length -desc | select @{n="Length";e={$_.length}}, fullname -f 10
|
||||
```
|
||||
|
||||
Search Files.ps1
|
||||
```powershell
|
||||
```bash
|
||||
Get-ChildItem -Recurse -Include *.item | select-string "<term>"
|
||||
gci -r -i *.item | select-string "<term>"
|
||||
gci -r -i *.* -exclude *.dll,*.xml | select-string "<term>"
|
||||
```
|
||||
|
||||
Search with Git Grep.ps1
|
||||
```powershell
|
||||
```bash
|
||||
# Can only be run within a Git repository, but this will also search untracked files, as well as those that are tracked.
|
||||
git grep --untracked '<term>'
|
||||
```
|
||||
|
||||
## Environment variables
|
||||
Get all environment variables.
|
||||
```powershell
|
||||
```bash
|
||||
dir Env:
|
||||
```
|
||||
|
||||
Get environment variables at a certain scope.
|
||||
```powershell
|
||||
```bash
|
||||
[System.Environment]::GetEnvironmentVariables('User')
|
||||
[System.Environment]::GetEnvironmentVariables('Machine')
|
||||
```
|
||||
|
||||
Get a particular environment variable.
|
||||
```powershell
|
||||
```bash
|
||||
[Environment]::GetEnvironmentVariable("NAME_OF_VARIABLE")
|
||||
[Environment]::GetEnvironmentVariable("NAME_OF_VARIABLE", "Machine")
|
||||
[Environment]::GetEnvironmentVariable("NAME_OF_VARIABLE", "User")
|
||||
```
|
||||
|
||||
Set an environment variable
|
||||
```powershell
|
||||
```bash
|
||||
$Env:NAME_OF_VARIABLE = "value"
|
||||
```
|
||||
|
||||
Remove an environment variable
|
||||
```powershell
|
||||
```bash
|
||||
Remove-Item Env:\NAME_OF_VARIABLE
|
||||
```
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# PowerShell Profile
|
||||
|
||||
## Refresh PowerShell Profile
|
||||
```powershell
|
||||
```bash
|
||||
. $profile
|
||||
```
|
||||
|
||||
## My Windows PowerShell Profile
|
||||
```powershell
|
||||
```bash
|
||||
Import-Module posh-git
|
||||
Import-Module oh-my-posh
|
||||
Import-Module Terminal-Icons
|
||||
|
|
|
@ -5,7 +5,7 @@ For a CLI on Windows, [download](https://www.sqlite.org/download.html) sqlite-to
|
|||
## Import a tsv file into a new database.
|
||||
This assumes the tsv has a header row.
|
||||
|
||||
```powershell
|
||||
```bash
|
||||
.open files.sqlite3
|
||||
.mode tabs
|
||||
.import files.tsv files
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Visual Studio
|
||||
|
||||
Install particular NuGet package.ps1
|
||||
```powershell
|
||||
```bash
|
||||
# Installs a particular version of a package.
|
||||
# See http://stackoverflow.com/q/16126338/11912
|
||||
Install-Package jQuery -Version 1.10.2
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# Windows Terminal
|
||||
|
||||
Open a new Windows Terminal window.
|
||||
```powershell
|
||||
```bash
|
||||
wt
|
||||
```
|
||||
|
||||
Open a new tab in the current window.
|
||||
|
||||
```powershell
|
||||
```bash
|
||||
wt -w 0
|
||||
```
|
||||
|
|
|
@ -7,7 +7,7 @@ findstr /s "<term>" *.item
|
|||
```
|
||||
|
||||
## Battery reporting
|
||||
```powershell
|
||||
```bash
|
||||
# Generate a battery report.
|
||||
powercfg /batteryreport /output "C:\battery-report.html"
|
||||
|
||||
|
|
Loading…
Reference in New Issue