This is PowerShell on Linux configuration guide, to provide a streamlined and convenient experience to not only install and set up the PowerShell with optimized default settings and oh-my-posh prompt theme, which is a cross-platform and cross shell, prompt theme engine.
Profile, theme, and aliases/functions are being installed globally, so the configuration is preserved also when running as sudo.
Datetime formatting is set to respect ISO-8601, if you prefer other settings, you can remove the following line from the profile.ps1:
[Threading.Thread]::CurrentThread.CurrentCulture = 'en-SE'
and remove --time-style=long-iso
parameter from ls aliases/functions in the _aliases_common.ps1 file.
All scripts are intended to be run from the repository root folder. To install and configure PowerShell on Linux, just run the command:
scripts/macos/setup_powershell.sh
If you have PowerLine/Nerd fonts installed, you can run the script with --theme
parameter, for the nicer command prompt. There are two additional pre-created profiles in the repository: powerline
and nerd
, using powerline and nerd fonts accordingly, but you can also specify any oh-my-posh theme from Themes | Oh My Posh and the setup_omp.sh script will automatically download and install it.
# using pre-created profiles
scripts/macos/setup_powershell.sh --theme 'powerline'
scripts/macos/setup_powershell.sh --theme 'nerd'
# examples of using oh-my-posh themes
scripts/macos/setup_powershell.sh --theme 'atomic'
scripts/macos/setup_powershell.sh --theme 'robbyrussell'
-
Aliases/Functions - PowerShell treats aliases differently than bash - you cannot alias command with additional parameters - for this you need to create a function. It breaks autocompletion, so all aliases defined in the function are not aware of the possible arguments. Another issue is that you cannot create a function named the same as the aliased command, for that you need to use env command like this:
function ip { $input | & /usr/bin/env ip --color=auto @args }