Windows Terminal: complete reference


Windows is the most popular PC Operating System in the world, and for good reason. Not only has Microsoft made the Operating system easy to use, but it has also blessed it with a gazillion of power-user-friendly features. Command Prompt, Windows Subsystem for Linux, and PowerShell were always good enough for advanced users. To make the whole command line programming system more streamlined, Microsoft released Windows Terminal. You can download and install the app from Microsoft Store.

Introduction

Windows Terminal is a terminal interface for command-line tools and shells, which allows users to put their favorite command-line applications under a single umbrella. It offers multi-tab support, personalized features — colored window, text formatting, and more — Unicode or UTF-8 character support, GPU-aided text rendering, and other noteworthy tools.

1. Productivity – Profiles

Windows Terminal lets you create multiple profiles for different shells. Essentially, you can configure these profiles in any way. I would cover some of the use cases to help you get started.

Steps to create new profile [more info]

  • Open the Windows Terminal application.
  • Click the drop-down button on the title bar.
  • Select the “Settings” option.
  • Click “Add new” option on the sidebar.
  • Type a name in the “Profile name” field.
  • Click the “Browse” button next to the Command Line field.
  • Select the CMD shell exe file and click “Open.”
  • Hit the “Save” button.
  • With that, you have added a new profile to the Windows Terminal.

Alternate, more advanced way is to click Open JSON file at the bottom left and edit the configuration file directly.

We would use the JSON file. Note that you might have to restart Windows Terminal to reflect changes on JSON. Each profile needs a unique GUID. You can either use the GUIDs exactly as follows or you can generate yours like following:

Generate GUID using PowerShell Core profile, showing my unique customization in Windows Terminal app

25+ Color Themes!

My code snippets would have references to these themes as an added bonus, if you would want to save countless hours creating and picking these color themes.

Subscribe to get access

Read more of this content when you subscribe today.

cmd.exe and PowerShell profiles

This probably is the most obvious one. Windows Terminal would come with this profile.

{
 "commandline": "cmd.exe",
 "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
 "hidden": false,
 "name": "Command Prompt"
},
{
 "commandline": "powershell.exe",
 "fontFace": "CaskaydiaCove NF",
 "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
 "hidden": false,
 "name": "Windows PowerShell"
}

PowerShell Core profile

PowerShell Core is a cross-platfrom (Windows, Linux and macOS) software. It has command-line shell, an associated scripting language and a framework for processing cmdlets. If you are new, please check out their home page.

{
 "commandline": "pwsh.exe",
 "fontFace": "CaskaydiaCove NF",
 "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
 "hidden": false,
 "name": "PowerShell Core",
 "source": "Windows.Terminal.PowershellCore",
 "tabTitle": "PowerShell Core",
 "colorScheme": "SMYCK"
}

Anaconda Environments

We can create a custom profile with command line arguments to start a profile with specific Anaconda virtual environment. In other words, you can very easily create different profiles or tabs, for each Anaconda environment you have.

Subscribe to get access

Read more of this content when you subscribe today.

SSH Profile

When I was using AWS EMR or, AWS EC2 I had to use SSH prompt along with PuTTY. For authentication we would use ppk file and enable dynamic port forwarding. In principle Windows 10 has built in SSH client but for some reason, I ended up using a command line utility called Plink – from the same publisher of PuTTy.

{
 "commandline": "C:\\instals\\plink.exe -ssh -i %USERPROFILE%\\Documents\\data\\my-key.ppk -D 8088 ec2-user@xx.xx.xx.xx:xx",
 "cursorShape": "vintage",
 "guid": "{fc51cff4-926b-4287-b1a2-fa2f23dc78e5}",
 "hidden": false,
 "icon": "%USERPROFILE%\\Pictures\\icons\\rhel8.png",
 "name": "AWS EC2 Red Hat (RHEL8)"
},
{
 "commandline": "C:\\instals\\plink.exe -ssh -i %USERPROFILE%\\Documents\\data\\my-key.ppk -D 8088 hadoop@yy.yy.yyy.yy:yy",
 "cursorShape": "vintage",
 "guid": "{f8f0b31d-3ab5-49c7-b455-89dbfea31d14}",
 "hidden": false,
 "icon": "%USERPROFILE%\\Pictures\\icons\\aws.ico",
 "name": "AWS EMR SSH"
}

Git bash profile

If you have installed git bash, you can also create a profile for it.

{
 "commandline": "%USERPROFILE%\\AppData\\Local\\Programs\\Git\\bin\\bash.exe --cd-to-home",
 "cursorShape": "vintage",
 "guid": "{848fe68a-c7ab-4123-bbbc-bd24c792ca29}",
 "hidden": false,
 "icon": "%USERPROFILE%\\AppData\\Local\\Programs\\Git\\mingw64\\share\\git\\git-for-windows.ico",
 "name": "git bash"
}

Ubuntu Linux profile

If you have not already, follow these steps for installing Linux subsystem in Windows 10 and downloading a Linux distribution like Ubuntu from Microsoft Store: https://itsfoss.com/install-bash-on-windows/

{
 "colorScheme": "Ubuntu",
 "cursorColor": "#DD4814",
 "cursorShape": "filledBox",
 "fontFace": "Cascadia Mono",
 "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
 "hidden": false,
 "name": "Ubuntu-20.04",
 "source": "Windows.Terminal.Wsl",
 "icon": "%USERPROFILE%\\Pictures\\icons\\Ubuntu.ico",
 "useAcrylic": true,
 "acrylicOpacity": 0.85
}

2. Personalize – Oh my posh!

There is a very good chance that you have heard about this module.

Scott Hansekman’s YouTube video on how to set up Oh my posh

After you have completed the steps in the video above, and got it to work, you could download the themes and preview them using the following command. More documentation is available at: https://ohmyposh.dev/docs/.

$ Get-PoshThemes

If you are interested, you can download my very own custom theme for free at: https://gist.github.com/aarshtalati/085b9f757acb61242bbe8bd7c5829243.

Install PySpark on Linux


You probably have heard about it, wherever there is a talk about big data the name eventually comes up. In layman’s words Apache Spark is a large-scale data processing engine. Apache Spark provides various APIs for services to perform big data processing on it’s engine. PySpark is the Python API, exposing Spark programming model to Python applications. In my previous blog post, I talked about how set it up on Windows in my previous post. This time, we shall do it on Red Hat Enterprise Linux 8 or 7. You can follow along with free AWS EC2 instance, your hypervisor (VirtualBox, VMWare, Hyper-V, etc.) or a container on almost any Linux distribution. Commands we discuss below might slightly change from one distribution to the next.

Like most of my blog posts, my objective is to write a comprehensive post on real world end to end configuration, rather than talking about just one step. On Red Hat 7, I ran into a problem. I solved this problem without having to solve it.

The Author

Environment

  • Linux (I am using Red Hat Enterprise Linux 8 and 7)
  • Java
  • Hadoop
  • Spark
  • Anaconda or pip based virtual python environment

I have broken out the process into steps. Please feel free to skip a section as you deem appropriate.

Table of Contents

Continue reading “Install PySpark on Linux”

Up and running with PySpark on Windows


If you, too, are coming from an R (or Python/Pandas) environment like me, you would feel highly comfortable processing CSV files with R or Python/Pandas. Whether you are using time series sensory data, random CSV files, or something else, R and Pandas can take it! If you can step away from R and Python/Pandas mindset, Spark really goes to a great length to make me feel welcome as an R and Python Pandas user.

These last days I have been working extremely closely with AWS EMR. I am not talking about creating a couple of trivial notebooks with a 5×5 data frame containing fruit names. The data set I am working with is 10s of gigs stored away in the cloud. The data is far from clean. I need to create an ETL pipeline to retrieve historical information. Which I would use to train my machine learning models. The predictive analysis on the new incoming data with machine learning – how am I doing it is probably a post (or series of posts) for a later date, probably. Today, I want to get you up and running with PySpark in no time!

Why am I writing this post?

There already is a plethora of blogs after blogs, and forums after forums on Spark and PySpark on the internet about how to install PySpark on Windows. These are mainly focused on setting up just PySpark. But what if I want to use Anaconda or Jupyter Notebooks or do not wish to use Oracle JDK? This post picks up where most other content lack. In this post, I want to help you connect the dots and save a lot of time, agony, and frustration. Regardless, you are new to Windows, Spark/PySpark, or development in general.

This process is as easy as ABC!

Benefit

The main benefit of following the approach I suggest in my blog post is, that you do not have to install anything (for the most part) and you can switch Spark, Hadoop, Java versions in seconds!

Let’s get started!

Continue reading “Up and running with PySpark on Windows”

Create/Update dictionary form list


There is a straight forward way to update an existing or empty directory from given a list of keys. In the first example below, we update dict only with keys, which were not already present. Notice that the key ‘a’ did get change and ‘z’ did not get deleted – they were left alone. The second example, basically initializes an empty dict object. Whereas, the third example creates a new dict object which did not exist before.

Continue reading “Create/Update dictionary form list”

Restarting ALSA Audio


Follow these steps:

sudo /etc/init.d/alsa-utils stop
sudo alsa force-reload
sudo /etc/init.d/alsa-utils start

When I was running openSUSE  11.1 in previous decade, sometimes the ALSA sound diver throws an error while playing some video with VLC media player. The solution was, just to restart the ALSA sound driver by running the following command as super-user:

/etc/init.d/alsasound restart

Virtual Box boot from USB


You may want to do this for a number of reasons, you may have a bootable USB thumb-drive / USB flash drive / USB stick (whatever you call it) containing Live CD, installation image etc. before you actually use it on your computer, or may be you don’t want to use that bootable USB on your computer, whatever that case might be.

Linux

Following are the 3 different methods you could use.

Method # 1: Create a pointer to your USB

I am using Ubuntu 18.04 LTS, but it could be any Linux OS/distro/flavor. If you have a bootable USB that you want to boot your VM from, go ahead and insert it.

First you need to find the logical device for your removable USB flash drive. One way to do it is to use lshw command (ls for hardware, get it?) It is recommended that you run this command as a super-user (sudo) otherwise “your output may be incomplete or inaccurate, you should run this program as super-user” warning would be displayed, which makes sense. If you need more information on lshw, including installation and basic usage, see this project website or this article.

Here is the raw command which shots of how KDE used to look like back in the day, in openSUSE 11.1 – this was the first ever Linux distro which got me hooked with Linux. To put things in perspective, openSUSE’s current version is 15.0 😉 will output EVERYTHING:

# "sudo lshw" shows everything
$ sudo lshw -class volume -disable TEST -notime

And look for the entry associated with your hard drive’s label. Alternatively, following commands much more concise if you know what you are looking for:

$ sudo lshw -businfo -disable TEST | grep volume

In my case, from the first command above, it was /dev/sdb1.

Next, Continue reading “Virtual Box boot from USB”

[4/4] Docker: Front-end development w/ Java, SpringBoot MVC & RESTful Web API


Today we are going to talk about adding front end user interface to our application, from scratch. We can add the front end to our application using something called view resolvers. Our options are Apache Tiles, JavaServer Pages (JSP), etc. there are many other options, as well. Spring Boot supports FreeMarker templates, Groovy Templates and Themyleaf via “AutoConfiguration”, as the first class citizens. As the name suggests, we should not need to do a whole lot to get going with one of these. In this video we would be looking at Thymeleaf. I find it easy to use and feature rich at the same time. Thymeleaf is mostly HTML. Finally, we will talk about Web JARs & How to add Branding to our web application, using responsive web design. Continue reading “[4/4] Docker: Front-end development w/ Java, SpringBoot MVC & RESTful Web API”

SpringBoot: Debug faster


Tired of rebuilding your Spring Boot web application every time you change your HTML markup or Java class? Thanks to IntelliJ IDEA and SpringBoot DevTools, you can easily code and debug faster without wasting time rebuilding your application over and over again. The solution discussed here would run your project as soon as your code change, and it would refresh your Thymeleaf HTML templates for the front end without even having to rebuild the project.

The actual work required to configure your project is not much. All, in all, you need to Continue reading “SpringBoot: Debug faster”