4

This is the exact same issue found here: https://unix.stackexchange.com/questions/165154/changing-the-spacing-between-files-in-ls

When you run the command ls -G or CLICOLOR=1; ls the spacing in the output gets squished.

These images demonstrate what's going on (taken from the old thread):

Running ls when CLICOLOR is unset or set to 0: <code>ls</code> when <code>CLICOLOR</code> is unset or set to 0

Running ls -G: <code>ls -G</code>

This happens in any terminal emulator (terminal.app, iterm, kitty) and any shell (bash, zsh).

As the commenter points out in the previous thread, this is caused by ls -G setting f_notabs=1. From the source file https://opensource.apple.com/source/file_cmds/file_cmds-242/ls/ls.c.auto.html:

    if (f_color) {
        /*
         * We can't put tabs and color sequences together:
         * column number will be incremented incorrectly
         * for "stty oxtabs" mode.
         */
        f_notabs = 1;
        ...

Is there any way to fix this? I can't find any information on this since 2014.

Obviously this isn't the end of the world, but ls is one of the most frequently called shell commands and being able to have both color and nice spacing makes things easier to read. I am surprised there seems to be very little written about this as I would expect it to impact a large number of people.

1

If your using Terminal or iTerm you can go to preferences and look for option to change fonts. For iTerm its shown in the image below.

enter image description here

If you click on the change font button you get the following pane.

enter image description here

As you can see in this image there are sliders to adjust the character spacing. you can spread the characters out on the iTerm windows.

  • Yes, I am aware that option exists in the terminal menu, but it doesn't have anything to do with the issue I'm suggesting. All that does is increase the width of each cell in the terminal. It does not change in any way how many whitespace characters are printed. On the other hand, the issue I had is with the number of whitespace characters printed. Specifically, when you run ls -G it outputs fewer whitespace characters than ls because it changes tabs to a single space. – Tristan Apr 14 at 3:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .