Table of Contents

PowerShell Core: Creating PowerShell profile with Tux

Hey, my name is "Tux"! Did you ever wonder how you can customize most everything within your local user specific PowerShell Core installation?

Hey, my name is "Tux" and this tutorial will show you how you can create your own user specific PowerShell profile so you can get much more flexible and personalized.



First thoughts

It is assumed that you have already set up the according PowerShell installation on your Linux system. Please refer to this Tutorial if you need an example on how to set it up.


Start of tutorial

Start a new PowerShell session:

$ pwsh

Now you want to get the default path for your user specific PowerShell profile by executing the following command (Note: The output does not mean necessarily mean that there is already an existing PowerShell profile for your specific user account, it just does show where the profile is expected to be):

$profile

Now you can test if there is already an existing profile connected to the $profile variable:

Test-Path $profile

If the output value is false there is no existing PowerShell profile yet for your specific user.

In this case want to create your own specific PowerShell user profile:

New-Item -path $profile -type file -force


From now on you will find a folder inside your user specific home directory called ~/.config/powershell where you can configure customized and user specific PowerShell functions, aliases, environmental variables and many more options.
To do so just edit the profile:

$ nano $profile

Here you can customize your PowerShell user profile as you want.

Example PowerShell function

Example content for a PowerShell function called quit which deletes the whole user specific PowerShell command line history:
Function quit {
    Remove-Item (Get-PSReadlineOption).HistorySavePath
}

When you are finished save the file and quit the editor.

Note

After any customizations to the user specific PowerShell user profile it is necessary to start a new PowerShell session before you can use your currently configured new PowerShell options.


End of tutorial



Appreciate my work?
Buy me a coffee or PayPal