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/linux/setup_powershell.shIf 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 it and install.
# using pre-created profiles
scripts/linux/setup_powershell.sh --theme 'powerline'
scripts/linux/setup_powershell.sh --theme 'nerd'
# examples of using oh-my-posh themes
scripts/linux/setup_powershell.sh --theme 'atomic'
scripts/linux/setup_powershell.sh --theme 'robbyrussell'You can remove all the resources installed with the above commands, by running:
scripts/linux/clean_pwsh.shYou can update oh-my-posh, PowerShell, and its modules, by running:
scripts/linux/update_powershell.sh-
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 }