loading...

Playing with Windows Terminal

jacoby profile image Dave Jacoby Originally published at jacoby.github.io on ・5 min read

I have been a WSL user for some time, and also someone keen on hacking my Bash prompt, which has lead me to find that Windows Terminal has lagged for some time on Gnome Terminal for Unicode support, which means that, for example, if you want icons to tell you that you’ve had several cups of coffee, your laptop battery is low, or your Git repo’s status is that of smiling poo, they just wouldn’t show up well on Windows.

There were places that were okay. They worked fine with the Cygwin terminal and the Git Bash that was derived from it, and I recall that PuTTY handled things well (but now that you can SSH from PowerShell and CMD prompts, I never open it anymore), but the built-in terminals were basically unchanged from NT and maybe before.

Rich Turner would know, because he wrote the … well, blog series … on the history of terminals in Windows, which lead to the release of the new Windows Terminal. You can download it from the MS Store now, and unlike some other favorite toys, you don’t have to be Fast Track Windows Insider. So let me show you around!

Pretty

I’m starting with the WSL prompt, because, as a Linux guy, I’ve done much more work with my Bash prompt customization. So far, that is.

WSL Terminal Tab

I point out a few things here. The coffee cup emoji (☕) indicating the cups I’ve consumed that day. Also, the computer emoji (💻) indicating that I don’t have packages to add, and the battery (🔋), which doesn’t mean much because the term is on my desktop, but would indicate battery charge level. Also, I try to use Taskwarrior and the check (✔) signifies that I have no tasks outstanding. And all of it shows up in the new Windows Terminal, which was not always true.

I’ll also mention that I’m using Fira Code, a font that supports ligatures, and it shows <= as one character, not two.

You can’t see it from the screen capture, but the cyberpunk image is an animated GIF, that is animated behind the text.

Cyberpunk.gif

I consider this a big thing, because I wrote a tool to set your Windows background image, and that only accepts JPEG.

This configuration is specific to the kind of term you’re opinging, so if you want a PowerShell terminal, it looks different.

PowerShell Terminal Tab

Configuration

Shortened, the configuration file in C:\Users\you\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState\profiles.json looks like this:

{
  "globals": {},
  "profiles": [],
  "schemes": []
}

And is available with ctrl-, or under Settings.

(Color) Schemes

Back to front, schemes are color schemes, and look like this:

{
  "background": "#0C0C0C",
  "black": "#0C0C0C",
  "blue": "#0037DA",
  "brightBlack": "#767676",
  "brightBlue": "#3B78FF",
  "brightCyan": "#61D6D6",
  "brightGreen": "#16C60C",
  "brightPurple": "#B4009E",
  "brightRed": "#E74856",
  "brightWhite": "#F2F2F2",
  "brightYellow": "#F9F1A5",
  "cyan": "#3A96DD",
  "foreground": "#CCCCCC",
  "green": "#13A10E",
  "name": "Campbell",
  "purple": "#881798",
  "red": "#C50F1F",
  "white": "#CCCCCC",
  "yellow": "#C19C00"
}

As you can see, it’s taking the names of default colors, plus foreground, background, etc., and putting a name to them.

Campbell is the out-of-the-box scheme, but you can change that and you can change these, in…

Profiles

{
  "acrylicOpacity": 0.5,
  "background": "#012456",
  "backgroundImage": "ms-appdata:///roaming/dotty-me.jpg",
  "backgroundImageOpacity": 0.25,
  "closeOnExit": true,
  "colorScheme": "Campbell",
  "commandline": "powershell.exe",
  "cursorColor": "#00FF00",
  "cursorShape": "bar",
  "fontFace": "Consolas",
  "fontSize": 10,
  "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
  "historySize": 9001,
  "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
  "name": "Windows PowerShell",
  "padding": "0, 0, 0, 0",
  "snapOnInput": true,
  "startingDirectory": "%USERPROFILE%",
  "useAcrylic": false
}

This is the profile for PowerShell, and I have customized it some. background is background color, and you jump to backgroundImage to set an image.

Dotty Me

But, of course, you want to see the text over your image, so backgroundImageOpacity is a float between 0 and 1 setting how much is there, which allows you to read text over it.

Valid cursorShape values are bar, emptyBox, filledBox, underScore, and vintage. Thanks, Donovan Brown!.

Evidently, Acrylic is a way to make a terminal translucent; the background is viewable through, but not in focus. This is where useAcrylic and acrylicOpacity fit in, but I have yet to make them work.

There’s a lot of Windows short-hand stuff here. ms-appdata:///roaming/ means C:\Users\you\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState. %USERPROFILE% is a long and complex way of writing ~ and the startingDirectory field it sets doesn’t do much for starting wsl, so the hack is to make your commandLine ask for "wsl.exe ~ -d Ubuntu-18.04". And then there’s the unique identifier, or guid. This is used primarily to indicate which choice comes up when you open WT, in …

Globals

    "globals": {
      "alwaysShowTabs": true,
      "defaultProfile": "{7c51c86f-d763-44fc-b952-e04d5922f631}",
      "initialCols": 120,
      "initialRows": 30,
      "keybindings": [{
        "command": "closeTab",
        "keys": [
          "ctrl+w"
        ]
      }, {
        "command": "OTHERS",
        "keys": [
          "plenty"
        ]
      }],
      "requestedTheme": "system",
      "showTabsInTitlebar": true,
      "showTerminalTitleInTitlebar": true
    }

Most of these seem to not do much, especially everything with Tab in the key. defaultProfile is what decides which of your choices come up when you open a tab or create a window, and that is set by that profile’s guid, and these GUIDs seem unique to the project, so your Ubuntu-18.04 GUID just might be mine.

Issues

Personally, I would love for the big array of keybindings to be at the top level, not stuck in the middle of the globals, but I’m not in position to change that.

On Linux, I use a transparent terminal set to about 30%, so you can see the Desktop (including other windows) through the terminal. It is mostly a “this is so cool” thing, but on occasion it has proved helpful. I would love the transparent/translucent backgrounds that Acrylic promises, but I have yet to make them work. I’m not generally the big fan of terminal-specific backgrounds, but I am enjoying them while I wait.

I would love to have some way to, when opening a term, be able to choose WSL Ubuntu or WSL Fedora or PowerShell ISE (As Admin), rather than creating a tab for it once it’s open, and the Admin powers part is not started to be solved yet, as far as I can tell.

You’ll notice the LONG tab which shows the location of the PowerShell executable, and that, instead, my Ubuntu tab says jacoby@Lion: ~, this is because I have tamed my $PS1 so it contains the string \[\033]0;\u@\h: \w\007\], which tells the computer that every time the prompt is written to set \u@\h: \w, or username@hostname: current_working_directory, as the terminal title, which, in this case, is tab title. Such magic must exist with PowerShell, but I have yet to dive deeply and understand such things. The default is so ugly, I’m going to have to.

The lack of emoji and Unicode characters has been my big annoyance with Windows for a while, and this release really fixes that. I’ll have to spend some time changing settings and my workflow to make this really fit my use, but I’m very happy with the new terminal and can hardly wait for improvements.

If you have any questions or comments, I would be glad to hear it. Ask me on Twitter or make an issue on my blog repo.

Posted on by:

jacoby profile

Dave Jacoby

@jacoby

Long time computer user. Long time programmer.

Discussion

pic
Editor guide
 
 

Thanks. They've made drastic changes done I blogged, but I think for the better.