Updating README.md with current instructinos

This commit is contained in:
lksz 2020-10-02 13:04:17 -04:00
vecāks 2d2a7bba5d
revīzija eec4eb2cbe
1 mainīti faili ar 18 papildinājumiem un 34 dzēšanām

Parādīt failu

@ -6,41 +6,25 @@ The development of these is documented in my blog: https://blog.lksz.me
They are provided 'as is' for your review and for your reuse.
There is a [blog post](https://blog.lksz.me/keeping-track-of-everything/#-mypsscriptroot) about how to clone this repo and use it as your own.
The scripts all [assume](https://blog.lksz.me/functions-or-scripts/#myprofilecode) the code below is part of one of your $PROFILE files.
The code establishes the following variables:
* `$PathEnvDelimiter` - Linux/Unix it's `:`, while in Windows it's `;`
* `$MyPSModulePath` - Location to place personal Modules
* `$MyPSScriptRoot` - Location of personal Scripts.
The code also makes sure `$MyPSScriptRoot` is in the `$env:PATH` environment vairable, and finally it calls [`Reload-MyAliases`](https://blog.lksz.me/a-case-of-sensitivity/#myaliases) if it exists.
This envrionment can be installed using one the following options:
### The Short, yet safer way
```PowerShell
iwr https://lksz.me/pwsz | iex
```
$global:PathEnvDelimiter = $(if( $PSVersionTable.Platform -match 'unix' ) {':'} else {';'})
function Split-PathEnv {
param([string]$EnvPath)
$EnvPath -split $PathEnvDelimiter
}
$global:MyPSModulePath = Split-PathEnv $env:PSModulePath | Where-Object { $_ -match "^$(Resolve-Path ~)" }
This sets up the `$PROFILE` file, and initilizes the default dir, but nothing else is done.
Cloning the repo, is something you'll need to deal with on your own, or you can call the next line.
if( -not $MyPSModulePath ) {
$MyPSModulePath = Resolve-Path ~/powershell/Modules
if( -not (Test-Path $MyPSModulePath) ) {
New-Item -ItemType Directory -Path $MyPSModulePath -Force | Out-Null
}
$env:PSModulePath = "$MyPSModulePath$PathEnvDelimiter$env:PSModulePath"
}
$local:p = Split-PathEnv $env:PATH
$global:MyPSScriptRoot = Join-Path (Split-Path -Parent $MyPSModulePath) Scripts
if( -not (Test-Path $MyPSScriptRoot) ) {
New-Item -ItemType Directory -Path $MyPSScriptRoot -Force | Out-Null
}
$p = @($p[0], $MyPSScriptRoot) + $($p | Select-Object -Skip 1)
$env:PATH = $p -join $PathEnvDelimiter
Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { . $_.Name }
### The [prefered] Short, but with control option
```PowerShell
$sfw=1; iwr https://lksz.me/pwsz | iex; _setup [-sudo] [-Force] [-GitClone] [-GitURL <alternative git URL>] [-WhatIf] [-Confirm] [<CommonParameters>]
```
This will setup the `$PROFILE` file properly, and when the `-GitClone` switch is used, the git repo is cloned into `$MyPSScriptRoot`.
### The 'I don't trust one liners, what's going on ?!?' option
Follow the instructions in the initial [blog post](https://blog.lksz.me/keeping-track-of-everything/#-mypsscriptroot) which contains the steps for cloning and using the env as your own.
In the above one-liners, `https://lksz.me/pwsz` actually points to the [Setup-Profile.ps1] file, which means, that after you have the `Scripts` directory setup, you can all `Setup-Profile` to setup the `$PROFILE` file.