Enhance a line in Linux Terminal

The greatest performance improvement of all is when a system goes from not-working to working.

William Gibson

Terminal (whatever you choose – zsh, fish or basic bash) is an essential tool In Linux for being more productive. Built-in Terminal is powerful and very configurable/extendable. As a developer, besides using CLI to manipule files/content/text, you will be using some kind of source control to record changes. I’ll use git in this example. If you don’t have git installed, you can easily add it via terminal with

 sudo apt install git

Working on a complex projects with different branches of the solution, you can easily have challenges with keeping up with all the switching between branches, changes, folders, etc.. Small distraction, quick fingers and you can easily push changes to forbidden branch. It happens and that brings additional unneccessary work.

Wouldn’t be nice to be able to graphically see in the terminal in the repository/directory, where you are and what is the error?

Status lines and prompts

There are many variations of status lines/prompts online. I first read about it on Scott Hanselman blog to enhance the terminal experience in WSL and Powershell. Plain terminals have great functionalities, but visual aids can boost your productivity big time.

By following Scott Hanselman instructions (which are quite easy to follow), you can get up to speed with justjanne/powerline-go status line in few minutes and without a sweat.

Snippet from Scott Hanselman blog:

sudo apt install golang-go
go get -u github.com/justjanne/powerline-go

I’ll point out few things to expedite the setup:

+ you’ll need to install the go language (more info about programming language here) and download the source from GitHub. If you don’t add the GO folder to the PATH variable, you’ll get below error. Go command enables you to fetch, build, and install packages, commands, and run tests.

Go is not in the PATH

In order to add golang to the path, you need to modify .bashrc file (it is hidden – hence the dot). Open favorite editor and add go path to the GOPATH environment variable. I’ll just use nano as this is a simple task to do.

nano ~/.bashrc

Add path for golang to enable terminal to be go aware (by default go is installed in home folder) – GOPATH=~/go and confirm changes with ALT+X and pressing Y.

Confirming changes

With that step finished, you are now able to use go command.

Go command

Repeat the install command in the instructions:

 go get -u github.com/justjanne/powerline-go 

+ test, if everything works as expected. Create a new folder mkdir test.

mkdir test

Cd into test and create a git repository with git init, create a file, add to repository and commit changes.

cd test
git init
touch file1
git add .
git commit -m "init"

When you check the folder (if you type cd .. and then cd test to go back), no visual changes are present. Why not? We didn’t specify, what’s need to happen in the terminal on startup. We need to modify the .bashrc file to define, what to run, how and when (it is stated on Hanselman blog which line to copy).

Bash terminal specification

Code snippet from Hanselman blog:

function _update_ps1() {
    PS1="$($GOPATH/bin/powerline-go -error $?)"
if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then

With that out of the window, still no changes in the terminal. Terminal didn’t picked up any changes. We need to re-run the terminal window for changes to be visible.

powerline activated

+ fix problem with fonts to define what to be shown on the powerline. You’ll need powerline fonts. I’ll use pre-patched fonts for powerline – repository of predefined fonts specifically for powerline. In Linux Mint you can install it via apt (for other distributions, here are the instructions):

 sudo apt-get install fonts-powerline 

Restart the terminal and you should see visual changes:

Powerline fonts

If you go to the folder test (which we created earlier and added few files to the git for testing), you should see the following as expected:

icons restored

If you installed top-down Guake terminal, the powerline works there as well:

Guake terminal with powerline


Powerline is a nice visual addition to already powerful terminal. I didn’t see any performance penalties or challenges with execution so far. It improves the development and traversing folders/repositories visual more appealing, makes you being less error prone and on the end more productive.