Multiplatform Setup for Powershell

This article is part of a series about powershell in general and the multiplatform nature of Powershell-Core specifically.

  1. Powershell Everywhere
  2. Multiplatform Setup for Powershell

TLDR

Got to PsDevScripts on Github to find an easy entry to using powershell with whichever OS.

My Intentions

In the last article in this series I wrote mainly about the possibility of using powershell on multiple platforms. In no way I want to talk people into abandoning there tried and true setup and diving heads deep into powershell. I just wanted to talk about the advantages I see.

How to make the Entry easy

Many comments I got for the last article read something like I wanted to try pwsh for a long time but didn't find a good book(other resource) to start with. As for resources, I named some at the end of the last article.
In my opinion the easiest way of getting into a shell is just using it though. That's why I cleaned up my personal suite of setup scripts and helper modules I use on every system: PsDevScripts on Github
I will update this repository in the future as I myself go along with learning about powershell.

Parts of my Setup

Following is a little more detailed explanation to every part of this suite.

Installer Scripts

While cleaning up the repo I noticed that I would like to just start a single script and be done with it. Everybody that wants to try out this basic setup can just run InstallDefaultSetup.ps1.

Modules

For now I included the two modules that I always install on a new machine:

Module Description
posh-git Autocomplete for git commands
posh-docker Autocomplete for docker(-compose) commands
PowershellConfig.psm1 Functions to interact with your pwsh-config

Default Profile

# import all modules in this folder
Get-ChildItem -Filter "*.psm1" -File "~\Github\PsDevScripts" | ForEach-Object {Import-Module $_.FullName}

# activate modules you want always to be active
Import-Module -Force posh-git, posh-docker

# configure posh-git
$global:GitPromptSettings.DefaultPromptAbbreviateHomeDirectory = $true
$global:GitPromptSettings.BeforeText = '['
$global:GitPromptSettings.AfterText  = '] '

# additional functions that are machine specific

All this does it importing the installed modules into your session. I use the the term installed loosely here, as I also import modules included in my repository.
At the end there is a very basic configuration for posh-git just so your command prompt is a little bit cleaner when navigating through git repos.

Further Questions?

With the above setup you can get started with powershell and the git/docker based workflow I tend to follow.

Now I would be very much interested in questions that come to mind for someone reading about this setup. I would be happy to answer them in a future article or in a conversation on twitter, reddit or email.

Till next time.