Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
christianlechne
Active Contributor
12,036

Introduction


Looking at the hands-on SAP Dev episodes (as of 3rd of January 2020 live stream and recordings are available via YouTube) of dj.adams.sap you will become aware that the terminal is getting quite some attention: how to configure it to fit your needs, what add-ons to install to get work done more efficiently from the command line, what fonts to use and so on. I absolutely agree that the focus on the terminal will continue to rise. So, it makes sense to get some cozy environment there set up for you. However, as far as I have seen most of the tips and tricks focus on MacOS and Linux as this is what is used in the episodes. One might even get the impression that DJ is not the biggest fan of Windows and the options you have there, but maybe I am wrong and one day DJ puts his MacBook aside, switches to a Surface Laptop and enjoys Windows 10 with WSL2 (this would probably be the same day when hell freezes over).

Anyway, I think there are some developers out there who use Windows for their development and they also want to have a cozy terminal environment in Windows 10. The intention of this blog is to give them a solid start to achieve this goal.

Step 1 – Install Windows Terminal


First things first – you need a terminal. Windows itself comes with the command prompt and the PowerShell. But there is a better way to start your journey: The Windows Terminal app. The app is free, and you can install it directly from Windows Store:



It serves as your central entry point embracing all the shells on your system (and on Azure – which is not in scope of this blog). In addition, it contains a very simple way to configure the look and feel of the different shells on your system.

Attention: The Windows Terminal is available as of Windows 10 Version 18362.0. You can check your version by executing the command "winver" on your system that gives you some output like this:



Before we start configuring the Windows Terminal, we will first install the “successor” of PowerShell namely PowerShell Core.

Step 2 – Install PowerShell Core


PowerShell Core is available on GitHub (open source and under MIT license): https://github.com/PowerShell/PowerShell

In the GitHub Readme area, you find the.msi files you need for the installation:



Download the fitting one and install it on your system. The shells available on your system are automatically added to your Windows Terminal app, so no further configuration necessary.

You can start the Windows Terminal app and access PowerShell Core via the selection menu:



Probably you want to rearrange the entries and set PowerShell Core as default. To achieve this, go to the “Settings” entry in the menu which will open the configuration file. It is a simple JSON file:



The JSON file represents your personal configuration that is mixed up with a default configuration. In case you mess something up here, the default configuration will take over, so little chance to corrupt up your terminal.

The sequence of the entries in the configuration file defines the sequence of the entries in the drop-down menu in the Windows Terminal, so arrange it as you like. The default profile is determined via the GUID of the corresponding profile. Enter the one you prefer in the “defaultProfile” attribute. Save the file after you made your changes and you are done. The changes are picked up immediately.

As you can see from the screenshot above, I have activated the Windows Linux Subsystem (WSL) on my machine and installed Ubuntu as Linux. The Terminal also picks up this shell automatically, so you really have one central entry point for all your shells.

Okay, so now we have installed a terminal app as central entry point for your shells, we have installed a future-proof shell aka PowerShell Core and configured the terminal app a bit. What can we do next? What about some custom fonts?

Step 3 – Install Fonts: Cascadia-Code and Delugia Nerd Font


Fonts make a big difference when working with editors and shells, so you should use one that supports you. I use a ligature-friendly font published by Microsoft called Cascadia Code (OpenSource; OFL Licence).

What does “ligature-friendly” mean? Basically, this means that multiple characters are combined into one. The following screenshot shows what this means. On the left-hand side you see a classical text editor with standard non-ligature font. On the right-hand side, you see the same letters magically merged:



As PowerShell Core the font is available on GitHub (https://github.com/microsoft/cascadia-code). To install the font, download the .ttf file form GitHub (https://github.com/microsoft/cascadia-code/releases) and install it via double-click on the downloaded file and press the install button:



You can use the font in your preferred editor, in my case Visual Studio Code. For Visual Studio Code you must make sure that beside selecting the font itself in your settings you also must set the “fontLigatures” attribute to true:



You can now also use the font in Windows Terminal, however if you want to follow along the next step in this blog you must install a patched version of Cascadia Code as there is one short-coming: Cascadia Code does not support “Nerd Fonts” which are special glyphs needed in step 4 of this blog. To overcome this issue you can patch Cascadia Code yourself (see e.g. Patching The New Cascadia Code To Include Powerline Glyphs And Other Nerd Fonts) or you use a patched version provided by the community. I used Delugia Nerd Font that is available at GitHub under https://github.com/adam7/delugia-code/releases.The installation procedure is the same as for Cascadia Code.

Now we are ready to go and can add the font in the Windows Terminal settings in the “fontFace” attribute as shown in the screenshot below for the PowerShell Core:



Remark: this is your environment so if you are not happy with this font, use the one that fits you best, you can easily configure your terminal the way you want it to be.

We now have a nice font in our shell and our editor, let us go one step further and make the shell prompt a bit shinier and more useful.

Step 4 – Install Oh-My-Posh


Currently your shell prompt probably looks something like this:



Wouldn’t it be cool to have a bit more information (like on which git branch you are when this directory contains a .git file) a bit more colors, a failed command indication, so basically something like this:



Then it is time to install Oh-My-Posh in your PowerShellCore. Prerequisite is to have Git for Windows installed. Follow along the installation instructions given in the Oh-My-Posh GitHub repo https://github.com/JanDeDobbeleer/oh-my-posh#installation and you are done. Read the instructions carefully, otherwise you might stumble over a non-existing $PROFILE file – maybe this happened to the writer of this blog.

Remark: As you can see Oh-My-Posh makes use of some special glyphs basically the Nerd Fonts that are currently not supported with Cascadia Code. This is the reason why we used the Delugia Nerd Font. Probably Cascadia Code will be enhanced with this capability as some feature requests are open on that. (see https://github.com/microsoft/cascadia-code/issues?utf8=%E2%9C%93&q=is%3Aissue+Nerd+)

As for the fonts: you can now play around with the theming and the colors as you like. Oh-My-Posh is easy to configure and adapt to your wishes.

Another spice-up action done for your terminal, so what more do we need more? Maybe a package manager for the command line?

Step 5 – Install AppGet as package manager


If you are working with MacOS or Linux a package manager is available out of the box. Unfortunately, this is not the case for Windows, so you must install one. The most prominent one is Chocolatey. You can install it via one line in your PowerShell as described here: https://chocolatey.org/install

I never really got used to it (no idea why), that is why I want to draw your attention to an alternative that I personally like more: AppGet

If you want to give it a try you download and execute the installer and you are done. After that you can install any of the available packages (https://appget.net/packages) via a simple command:
appget install <package_name>

So package manager done, what can we do more to make our CLI life more comfortable? What about a HTTP client?

Step 6 – Install HTTPie


Probably you use Postman as HTTP client to interact with REST APIs. You can also make use of the command line to do that. The most know HTTP client probably is curl, but maybe you also want to look at alternatives. And here comes a quite nice one called HTTPie.



Its installation is straightforward, the only prerequisite is that you have Python installed on your machine (which means executing “appget install python”).

Again, it is a question of your personal preferences which HTTP client you prefer, however I would highly recommend trying out this one.

With that I would say that this is enough as a starter to accommodate your terminal on Windows.
But there is one more thing, maybe you also have WSL up and running and want to have the same features there as you have in the PowerShell Core now.

What about WSL(2) … well we got you covered


If you are using WSL (1 or 2) the corresponding shell is available in your Windows Terminal app after installation of your Linux image and you can configure its appearance (fonts etc.) as we did for PowerShell Core.

If you want to use the powerline-like output in your WSL prompt you can use, well, Powerline ?

You can go for vanilla Powerline that is available in the Debian/Ubuntu repositories. This is really vanilla-style, so you have some configuration work ahead. As I am a lazy bone I went forpowerline-go which gives you a decent pre-configuration. The following steps are necessary for the installation:
sudo apt install golang-go
go get -u github.com/justjanne/powerline-go

The execution of the second command took quite some time in my case, so be patient. After that you must edit your ~/.bashrc:
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

The first line is only necessary if you do not yet have a GOPATH defined.

And here we go for the WSL:



Finally, HTTPie is also only one command away:
 sudo apt-get install httpie

That’s it for the WSL shell on your Windows machine, feature pair with PowerShell Core.

Closing Remarks


The terminal is getting more in more in focus also for developers in the “classical” SAP ecosystem. This blog should give you a jump-start in setting up your terminal and shells on Windows which sometimes does not get as much love from my perspective.

There are for sure a lot more things out there, that I did not cover here. In case you have more tools, you think make sense in this area feel free to post them in the comment section of this blog.

References


I had a lot of inspiration (or should I say Copy&Paste templates) for the stuff written down in this blog, so here are my sources:

The basics of customizing your Windows Terminal is summarized in the blog  https://www.howtogeek.com/426346/how-to-customize-the-new-windows-terminal-app/ by Josh Hendrickson. In case you want to have baby Yoda watch your action in the shell this blog:


So may the Terminal be with you!

14 Comments
qmacro
Developer Advocate
Developer Advocate
Awesome post Christian - I hope this inspires others to get their terminal on. And yes, "hell freezing over" is about the right timescale for me and Windows 😉
rsletta
Contributor
YES! Great blog post! ?

Windows has really entered a new era, with Windows 10 and WSL(2). I'm primarily a macOS user, but due to troubles using my company issued Macbook Pro, I switched to a Lenovo Thinkpad X1 and Windows 10.

This has lead me to experiment on HOW I will make my day to day development life as comfortable as possible, and boy did I get a surprise. My last attempt at working on Windows was a couple of years ago, when my current Macbook Pro had to be services. IT provided me with a temporary machine, an old HP "something" on Windows 7. It was the longest two weeks of my developer career. But I have an ear to the ground, and have followed the development in the Windows camp closely. And to sum it up, at the moment I feel that I've got the best of both worlds. (disclaimer: this is in the coorporate context, where I'm dependant on running Windows for some tasks).

I'm still waiting for WSL2 on my company machine, but I got myself a private Lenovo Yoga C740 to experiment on, waiting for Apple to release a 14" MBP. On that I'm running WSL2 with Ubuntu, Windows Terminal preview, VS Code (with remote extension for WSL), and Docker (on WSL).

Sorry for the rambling. I guess I might have a small blog post on the Windows dev env of the future in me after all. ?
nabheetscn
SAP Champion
SAP Champion
Great stuff christian.lechner, i was looking for such thing for a long time. Thank you!


dj.adams.sap is now chromeOS fan?



christianlechne
Active Contributor
Looking forward to your blog post about your Windows environment. I absolutely agree on the way Windows evolved - especially looking forward to GA of WSL2, the insider preview is quite promising.
christianlechne
Active Contributor
Great  that you liked it. But you know what they say at Microsoft, since they started developing a Linux Kernel for WSL2: Hell freezes over every other day at Microsoft 😉
martin_E
Active Contributor
Funny ... I remember saying something similar about MVS & BAL and green screens (well, green on black)
Former Member
0 Kudos
Hi Christian,

if i didn't experience 3 recent BSOD crashes on 2 different laptops (from the same vendor, nevertheless), i would have voted yes for WSL, but now my feet are really cold and in the cloud dumb terminals are just fine by me.

happy linuxing in Windows (or is it an oxymoron?).

greg
christianlechne
Active Contributor
0 Kudos
That's bad. I am running it on a surface 3pro (Win10 2004; WSL 1 and 2) and a Intel nuke (Win10 1909 WSL 1). Not a single issue so far except for a temporary problem with VS Code and remote support (which is okay as it was a windows insider build).
pierre_dominique2
Contributor
Thanks rsletta for mentioning WSL during dj.adams.sap stream. I installed it right away and this is so much better than the windows command line! I had heard about WSL but never had the opportunity to try it before.
pierre_dominique2
Contributor
Thanks christian.lechner for this post. I have been using Mac OS for the past 8 years and recently had to switch back to Windows at work.These tips are gonna make it so much easier to work with Windows!
christianlechne
Active Contributor
0 Kudos
Happy to hear that!
hendrik174
SAP Mentor
SAP Mentor
hi Christian,

finally I got my Windows updated to a version supporting the Terminal and now I'm quite happy with the features and thanks to your links, I'm learning a lot and its fun 🙂

Great blog! Thanks for writing it up!

Hendrik
christianlechne
Active Contributor
Hi Hendrik,

thanks for the nice feedback.
Here a blog that might come handy, when you start working with the new Terminal as it is feature complete now and waiting for the first release:
https://www.hanselman.com/blog/ItsTimeForYouToInstallWindowsTerminal.aspx

Best regards

Christian
0 Kudos
//FYI

Found interesting training session on Powershell and how to administrate SAP using Powershell.

 

https://www.youtube.com/watch?v=l-PAs2gYLr8&t=2s

 

Rajendra
Labels in this area