NOTE: If you find yourself getting thinking you may have gotten way too far down into the weeds with this, you might want to consider a much less involved alternative: bash-git-prompt (that's what I'm now using on all my Linux machines).
To be clear, this gist will focus on Powerline for the Gnome terminal on Linux and for PowerShell Core on Windows 10, because those are the combinations I use in my daily work.
There are two different open source products that make it easier to implement Powerline for bash and PowerShell:
Oh My Bash for bash on Linux.
Oh My Posh for PowerShell.
The main difficulty I had in setting this up was in getting a font package that included the Powerline glyphs.
For on Ubuntu Linux 18.04 and forward I use the original powerline fonts as installed by the included install.sh
bash script.
For Oh My Posh on Windows 10, I also used the original powerline fonts (hey, it comes with a handy install.ps1
PowerShell script, after all).
As a result of all this, I'm now using "DejaVu Sans Mono for Powerline" as my console and editor font on both platforms.
- Install the original powerline fonts:
$ git clone https://github.com/powerline/fonts.git
$ cd fonts
$ bash install.sh
- Install Oh My Bash :
$ sh -c "$(curl -fsSL https://raw.github.com/ohmybash/oh-my-bash/master/tools/install.sh)"
- Set your preferred theme by editing
OSH_THEME=[theme name]
in your~/.bashrc
file and save.
OSH_THEME="powerline"
-
Re-launch Gnome terminal and change the font it uses to "DejaVu Sans Mono for Powerline Book". This is located under Edit... Preferences... Profiles... [Profile Name]... Text... Custom font. Then restart the terminal.
-
For the terminal in Visual Studio Code, go to File... Preferences... Settings... Text Editor... Font. Set it to "DejaVu Sans Mono for Powerline" and save.
Note that the procedure for Windows uses version 2 of Oh My Posh. The newer version 3 is still in beta and works completely differently.
- Make sure Windows Terminal and PowerShell Core have been installed from the Microsoft Store.
- Install the original powerline fonts:
PS> git clone https://github.com/powerline/fonts.git
PS> cd fonts
PS> pwsh install.ps1
- Launch Windows Terminal and execute the following commands:
PS> Install-Module posh-git -Scope CurrentUser
PS> Install-Module oh-my-posh -Scope CurrentUser
PS> Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck
- Edit (or create) the PowerShell $PROFILE file to append the lines that will invoke the shell generator:
PS> notepad $PROFILE
NOTE: Change your theme using Set-Theme
.
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme powerline
- Edit the Windows Terminal settings.json (you can get to this from the "Settings" in the Windows Terminal gui) to set "fontFace" to "DejaVu Sans Mono for Powerline", and save:
{
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell",
"source": "Windows.Terminal.PowershellCore",
"fontFace": "DejaVu Sans Mono for Powerline"
},
-
Close and re-launch Windows Terminal, and choose PowerShell Core (if it isn't your default shell).
-
For the terminal in Visual Studio Code, go to File... Preferences... Settings... Text Editor... Font. Set it to "DejaVu Sans Mono for Powerline" and save.