How to configure a fancy terminal

My work machine changed a few times in the past 6 months: I went from a Dell running Ubuntu to a MacBook running macOS and back to Windows with now a Lenovo ... sheesshhh! The hardest part for sure was the muscle/brain memory when I had to switch from doing Ctrl + C (Ubuntu) to Command + C (MacOS) back to Ctrl + C (Windows) using a Microsoft Sculpt keyboard that doesn't have a Command button (it's the windows button in this case). Why Steve Jobs!?! Why I cannot create/edit the shortcuts to do what I want in a easily manner!?!

Anyway, I was happy with the terminal configuration/setup I had in my Ubuntu but since I have done that without proper backup/documentation what happened when I got the Mac? I had to start a new configuration/setup. No backup/documentation as well there when I migrated to the Windows PC so I decided to stop this recurring google search "how to configure a terminal" and document here in this post a How to configure a fancy terminal (if you are interested, if not, hopefully it will save me time next time I have go to this process again 😁)

In case you are wondering, Yes. Perhaps I should have called the post How to configure a fancy terminal (in MY view with my preferences) since it is a very opinionated way of doing it based on what I like the most.

Windows comes with PowerShell and Command Prompt (cmd) and they serve for running the commands you need initially to install other tools and you forget about them. Same thing you always did with Internet Explorer (IE), you use it to download Chrome and never open IE again. Ok, Ok, to be fair PowerShell has evolved a lot but I still prefer Zsh.

You can do whatever you want with Ubuntu so I recall I installed Zsh, set it as default and made the necessary configurations. Zsh is the default in Mac so it was just configuring it. Now, with Windows, how can I run Zsh and make it as default?

The answer goes around two main things: Installing Windows Terminal. Installing and configuring Windows Subsystem for Linux (WSL) so that you can install and configure Zsh there.

Once that is done, we can make some tweaks to Zsh so it becomes a Fancy terminal. Finally, configure WSL (which will be Zsh by default) with the Apps that somehow uses a terminal. In my case, the main one is Visual Studio Code.

Installing Windows Terminal

Windows Terminal is an Application that can be found at Microsoft Store (link). You can install it from there or just open PowerShell (please always do so by running with 'Run as Administrator' option) and do some command magic!

Well, not that simple... to install it via command we will need a Package Manager. Windows does have a few package managers, the one I use/like the most is Chocolatey and you can see their installation instructions here. If you are a Mac (or Linux) user you probably use Homebrew commands to install packages in a MacOS (or Linux) so choco will do the same trick as brew in this case.

(I'm now craving for a beer and also a chocolate. What have you done people that give those names to things!)

So, step one: Copy and paste the following command to install Chocolatey and run it in PowerShell:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

After that we can run:

choco install microsoft-windows-terminal

Add your Y to agree when requested and Success! You now have Windows terminal and a decent Package Manager installed for Windows.

Installing Windows Subsystem for Linux (WSL)

keep the same PowerShell with Admin open and run the following:

wsl --install

This command will enable the features necessary to run WSL and install Ubuntu as a default. You can change that later if you prefer others distributions.

Prompts for you to add a name, password, etc, wait, reboot required OK and Ta-dã! We are ready to roll! Bye Bye PowerShell!

WSL... check... ✔

Configuring the Windows Terminal and WSL

The first thing you need to do is to install a decent font that will work great with your terminal. That is a system wide thing so pick one that you like from Nerd Fonts and install in your operating system.

If you read the Time to make something that looks good post you probably know that I like Roboto so for my terminal I clicked on the do the RobotoMono Nerd Font download button:

RobotoMono font

To install the fonts in Windows you have to:

Extract the zip files to a folder, select all files, Right click on all selected files and click on "Install for all users"

Windows Font Install

Font... check... ✔

Time to do some basic configuration on Windows Terminal. Open your newly installed Windows Terminal and right click at the top to go to the Settings:

WSL Settings

Let's make a few configurations here:

Startup: Select Ubuntu as the Default Profile

Startup

Defaults: Run this profile as Administrator and right there let's dive deep on appearance

Defaults

Appearance: Change the Font and the font size.

Appearance

Oh cool I can change the appearance for a specific Profile so let me change the color for PowerShell to Campbell Powershell to create a visual difference from my WSL default terminal:

PowerShell color

Windows Terminal... check... ✔

Installing Zsh and making the default shell

If you are a Linux user, you can start here! (Well, the font step is also a requirement from the block above so do that too but for your operating system)

Time to configure Zsh. Open the Windows terminal (hopefully your default is now Ubuntu like mine) and run:

sudo apt install zsh

Verify if was installed

zsh --version

now change Zsh so that it becomes the default in WSL:

chsh -s $(which zsh)     

Close the Windows terminal open again. Zsh will ask you for some options, I selected the one to create the file .zshrc with a comment and Exit (option 0 if I recall) and run:

$SHELL --version

If you get a response like that: zsh 5.8 (x86_64-ubuntu-linux-gnu) congratulations!

Zsh Default

Zsh as default... check... ✔

Tweaking Zsh

If you are a MacOS user, you can start here! (Font font font! Don't forget to install the font)

There are several ways to customize the terminal prompt. If you are a PowerShell, Bash and Zsh user and want to maintain visual consistency between all of them there are a few options like Starship or Oh My Posh that does exactly that: a cross-shell prompt customizer. From the ones I tried, I really liked a theme that was created for Oh My Zsh (the drawback is that it only works with Zsh).

Let's install Oh My Zsh:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

You can chose a Theme or just use the same one I use: Powerlevel10k. Run the following:

git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k

Time to set the Theme in .zshrc file. Run the following command to open VS Code to edit the file (why the heck would you use VIM? do you like pain?):

code .zshrc

or if you prefer nano:

nano .zshrc

Add the following to .zshrc file: ZSH_THEME="powerlevel10k/powerlevel10k" and save the file:

Zsh Theme

Finally, I got so used to the autocomplete / autosuggestion that I was using in Zsh that is almost impossible to go back and not have it. To do so, go back to Windows Terminal and run the following command:

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Now add the plugin to the .zshrc file. Edit the file again with VS Code:

code .zshrc

Locate plugins part at the file and add the zsh-autosuggestions and save it:
plugins=(
git
zsh-autosuggestions)

Zsh plugins

Close the terminal and open again to configure powerlevel10k with autosuggestions now!

Zsh configured... check... ✔

I think this "onboarding" in Powerlevel10k is what I liked the most and why I recommend it. Don't like the rainbow style? That´s ok people are indeed different and the initial setup will guide you to selecting what you like the most:

Zsh Powerlevel10k onboarding

If you want to re-run the configuration wizard just type:

p10k configure

And we are done here [1]!

Configuring VS Code

Oh wait, I lied. I forgot about one little but important thing. You will notice that VS Code will have your terminal just like you configured except... the font. The icons won't load and the experience will not be the same so we have to fix that:

VS Code Font error

At least, it is a simple fix: Open VS Code, click on Settings and find the terminal.integrated.fontFamily setting and update to the font you installed in step 1, in my case I have to update to 'RobotoMono Nerd Font':

VS Code font setting

Final Step, change the default terminal to WSL in VS Code:

VS Code default

VS Code configured... check.. ✔

Resources

I told in the beginning that I had to google "how to configure a terminal" multiple times to get the above How to that works for me and I like. To do so I have used/was inspired/got information from the following videos mostly:

And..... we are done here [2]

Finally! OMG that was a long post

Here is the final result with a git example with the visual tips my terminal now provide:

Final Result

Leave a Comment

Your email address will not be published. Required fields are marked *