In this tutorial, we aim to bring life to our boring old Azure Cloud Shell by adding a colorful Git prompt. Kinda like this one!
I have another post in which we style PowerShell and WSL (Bash) that is located here:
Windows Git Prompt for WSL (Bash) and PowerShell
Michael Crump ・ Jan 21 '20 ・ 4 min read
For those new to Azure Cloud Shell? Azure Cloud Shell is a browser-based shell experience to manage and develop Azure resources.
Let's do this!
0.) Open Azure Cloud Shell and select Bash.
1.) Notice that Git is already installed, so you can type git
from the Bash prompt.
2.) Notice also that GoLang is also installed, so you can type go
from the Bash prompt.
Go is a tool for managing Go source code.
Usage:
go command [arguments]
...
Kind of cool isn't it? So why am I asking you to type git
and go
and the reason for that is because we'll be using both of these to setup our colorful Git prompts.
3.) We need to add Powerline for a beautiful and useful low-latency prompt for your shell, written in go.
go get -u github.com/justjanne/powerline-go
4.) Edit ~/.bashrc
with VS Code or Nano (ex. code ~/.bashrc or nano ~/.bashrc) and add the following information (source
GOPATH=$HOME/go
function _update_ps1() {
PS1="$($GOPATH/bin/powerline-go -error $?)"
}
if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
5.) Install a compatible Font for your browser.
6.) Open up your Browser's font settings For Chrome, and change the Fixed Width Font line to the font we used installed.
Restart the browser and head back over to Azure Cloud Shell and navigate inside of a repository and you should see the new colorful Git prompt!
BONUS: Visual Studio Code Integration
0.) Add the Azure Account Extension or search from VS Code to install it easily.
1.) Log in to Azure (it will open a new web browser)
2.) Click the Settings (Gear icon) at the bottom of Visual Studio Code and click Settings again and add the font to your Editor: Font Family
Menlo, Monaco, 'Courier New', monospace, Delugia Nerd Font
3.) Open the command palette and type Azure: Open Bash in Cloud Shell
. This will connect you to your Cloud Shell instance running in Azure and you should see your new colorful Git prompt.
Finished!
Did you like this? I streamed this live on Twitch. Follow me for upcoming developer streams.
Stream Replay
- Watch on Twitch and follow for more live-coding sessions Available for 60 days
Stay connected with me on various social platforms for daily software development news.
Top comments (0)