Score:2

Can't figure out how to add padding to left side of terminal in WSL 2 Ubuntu 20.04.5 (On Win11)

kg flag

Updated after user @NotTheDr01ds had great input but unfortunately it did not exactly accomplish what I was hoping to accomplish.

I installed WSL 2 and Ubuntu following directions from a class I'm taking and am setting up my terminal to be how I like it, set up my .bashrc's PS1 to my liking. Now I'm just trying to figure out how to add padding to the window as there is 1px between the edge of my monitor and the first char and it is visually distracting. Ubuntu terminal launched from Ubuntu 20.04 LTS

All the research I've done says this is the solution:

  • Add the following code to ~/.config/gtk-3.0/gtk.css:
     VteTerminal,
     TerminalScreen,
     vte-terminal {
         padding: 10px 10px 10px 10px;
         -VteTerminal-inner-border: 10px 10px 10px 10px;
     }

However, I don't have ~/.config/gtk-3.0/gtk.css and when I create it it doesn't do anything. I have a Z:\etc\gtk-3.0 which has two files; im-multipress.conf and settings, settings containing:

    [Settings]
      gtk-theme-name = Yaru
      gtk-icon-theme-name = Yaru
      gtk-sound-theme-name = Yaru
      gtk-icon-sizes = panel-menu-bar=24,24

https://learn.microsoft.com/en-us/windows/terminal/customize-settings/profile-appearance#padding shows that it is possible and that it should be accessible from a settings.json file, which I was able to find through the windows Terminal, however this only seems to affect my Ubuntu CLI when launched through the Terminal, my goal is to have this padding when launched from Ubuntu 20.04 LTS: Ubuntu terminal launched from Terminal

I am lost because the way the class had me set it up my working directory is Z:\home\jake_windows_11\ all the resources I've found are working with Windows terminal in their root. For reference my .bashrc file is in "Z:\home\jake_windows_11\" if that helps. My working directory for my class

I'm sure I left out important information so don't hesitate to probe for more information which I can update my post with, I've spent way to long on this already but I know it has to be possible so I'll keep trying till I find an answer that works. Any help is appreciated!

ChanganAuto avatar
us flag
There's no Ubuntu 12.04 for WSL, never was and never will be, "12.04" means April 2012 which preceeds WSL by several years. Probably you meant 22.04, isn't it? Please [edit] the question accordingly.
Jake avatar
kg flag
Yes I miss typed, thank you
Score:3
vn flag

Well there's a lot going on in this question! First, it's important to understand what terminal you are using with Ubuntu on WSL, and which terminals you aren't.

The first set of instructions you mention, for editing ~/.config/gtk-3.0/gtk.css, are for terminal applications that use the VTE Terminal Widget Library. Those are Linux applications. It's possible to use any of these inside Ubuntu on WSL; however, when you launch WSL itself, that's a Windows application.

I believe you realize this, since you progress to looking at Windows Terminal padding settings.

But I don't think you are using Windows Terminal either. It defaults (according to the doc you linked) to using 8px padding anyway.

The "1 pixel from the side" would indicate that you are using the old, old legacy Windows Console Host (conhost.exe) that was the default in Windows for 25 years or so until very recently. If you just installed Windows 11 22H2 on a new system, then Windows Terminal would be the default. Otherwise, Console Host is still the default.

Windows Terminal should, however, be installed automatically in Windows 11 now. Try to launch it by searching the start menu for Terminal. If not, install it from the Microsoft Store (if that link doesn't work, search for Windows Terminal there, by Microsoft).

Windows Terminal will automatically default to 8px padding, and it will automatically detect Ubuntu and create a profile for it.

Since you are on Windows 11, you can set it as the default terminal application as well so that running Ubuntu in the future will automatically use it.

You will then have access to Shift+Click the Settings menu, but there's no need to if you want to set the same padding on all sides -- You can do that directly by:

  • Opening the regular settings GUI
  • In the Profiles section, find the Defaults
  • Select Appearance
  • Change the Window -> Padding slider to your desired value.

If you would like to change just one side, I recommend first changing it through the GUI. Then you'll see the Padding section added to the settings.json, which will make it easier to find and edit.


Side-note #1:

I am lost because the way the class had me set it up my working directory is Z:\home\jake_windows_11\ all the resources I've found are working with Windows terminal in their root. For reference my .bashrc file is in "Z:\home\jake_windows_11\" if that helps.

Ugh. That's not good, for at least two reasons:

  • Performance of WSL2 on Windows drives is drastically reduced compared to having your home directory in the normal location, on the virtual ext4 filesystem that WSL2 provides.

    I'm assuming that you will be using VSCode, and it will create a server in your home directory. Every startup of VSCode will be slower as a result of this. VSCode is even going to give a warning when opening a project on the Windows drive.

  • The Windows drive is not POSIX compliant. Eventually, an application that you use may have issues with storing its configuration files (or other data) on the 9P (network) filesystem that WSL2 uses to connect to Windows drives.


Side note #2:

Stack Exchange said this wasn’t appropriate for their website so hopefully it’s appropriate here.

We definitely have a different set of rules here than Stack Overflow. I do agree that this wasn't appropriate there on Stack Overflow. I put together a WSL Tag Wiki there to try to give guidance on what types of WSL questions would be considered "Programming" and where to post if a question didn't meet this criteria.

As for whether it is appropriate here, yes. We do require that questions be about a currently supported, official Ubuntu release, which Ubuntu 20.04 on WSL is. While it's interesting that, ultimately, your question had to do with the Windows terminal application and nothing to do with Ubuntu -- You had no idea that was the case when you asked the question. And the instructions you were following were for Ubuntu (which you are using), and require someone with both Ubuntu and Windows experience to answer.

Would the question have been better on Super User? Sure - You would probably have found a larger pool of people there who could answer (and might have received an answer faster). There aren't too many of us here on AU that understand Windows Terminal and Windows Console Host, since they're not Ubuntu (or even Linux) applications. But again, you had no way of knowing that when you asked the question.

Jake avatar
kg flag
My fault I missed the second step 'set "Windows Terminal" as the Default terminal application setting'!
NotTheDr01ds avatar
vn flag
@Jake No worries - That's what I thought; just had to make sure!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.