Make Terminal Powerfull Using Oh-My-Posh
Programmers use a command-line interface (CLI) to issue text-commands to the Operating System (OS), instead of clicking on a Graphical User Interface (GUI). This is because command-line inerface is much more powerful and flexible than the graphical user interface.
The Terminal application is a command-line Interface (or shell). By default, the Terminal in Ubuntu and macOS runs the so-called bash shell, which supports a set of commands and utilities; and has its own programming language for writing shell scripts.
Oh My Posh
Oh My Posh is a custom prompt engine for any shell that has the ability to adjust the prompt string with a function or variable.- Colors: Oh My Posh enables you to use the full color set of your terminal by using colors to define and render the prompt.
- Customizable: Easily adjust existing themes or create your own. From standard segments all the way to custom implementations.
- Portable: No matter which shell you’re using, or even how many, you can carry the configuration from one shell and/or machine to another for the same prompt everywhere you work.
Installation
Windows
Need have powershell 7
, download at Microsoft Store or install on official website.
Install oh-my-posh
from winget.
|
|
or Manual installation
|
|
This installs a couple of things:
oh-my-posh.exe
- Windows executablethemes
- The latest Oh My Posh themes
Linux
Recommend using zsh
shell instead of bash
. Install oh-my-posh
by manual download.
|
|
or using Homebrew
|
|
Font Installation
Install nerd fonts
from official website. And set nerd fonts
on terminal profile.
Configuration
Windows
Create powershell user profile $PROFILE
.
|
|
We will be got an output C:\Users\user\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
. This is our $PROFILE
location to be edited.
Create new file on C:\Users\user\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
. For my device i like use 1_shell
theme.
|
|
Linux
Add this below line on .zshrc
file to load oh-my-posh
theme engine. Because i use WSL
i can directly load from powershell at /mnt/c/Users/Maverick/AppData/Local/Programs/oh-my-posh/themes
directory. If not have themes yet can download first from GitHub here.
|
|
Usually i don’t like use transient prompt
so i need to remove this line.
|
|
Then execute source .zshrc
or just close and reopen terminal. Oh My Posh already installed if looks like
Powerful Plugin
Windows
Install Terminal-Icons
Module to show if directory or files
|
|
Install z
module, it can be used directly jump in some folder.
|
|
Install PSReadLine
to auto suggestion or auto completion from history command line.
|
|
Update powershell profile C:\Users\user\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
. I added function which
like on Linux command line to find where the program directory.
|
|
Linux
Clone zsh-autosuggestions
and zsh-syntax-highlightings
|
|
Install jump shell
from snap
, on my case I use Ubuntu-20.04
. Jump integrates with your shell and learns about your navigational habits by keeping track of the directories you visit. It gives you the most visited directory for the shortest search term you type.
|
|
Install ruby gem
and colorls
to beautify list directory.
|
|
Finally, update .zshrc
profile to load configuration.
|
|