brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: tabs -4 makes the terminal show tab characters four columns wide

Terminal
~/tips/tip-terminal-tabs-width

tabs -4

Changes how wide tab characters look in your terminal for cat and less.

Code indented with tabs looks wildly spread out when you cat it, because terminals put a tab stop every eight columns. That is a terminal setting you can change.

The tabs command sends the escape codes that clear the tab stops and set new ones. For a stop every four columns:

tabs -4
cat Makefile

The file stays exactly as it was. Only the way the terminal draws a tab character changes, for every program that just prints text, like cat, grep and diff. I like it for Makefiles and Go code, which use real tabs.

To go back to the standard eight:

tabs -8

To make it stick, put tabs -4 in your ~/.zshrc or ~/.bashrc. It needs TERM to be set, which it always is in an interactive terminal, so keep it out of scripts that may run under cron.

Programs that draw the screen themselves ignore it. vim uses its own tabstop, less has -x4, and git diff goes through a pager. A new window starts with the default eight again, which is why the line belongs in your shell config.

Further reading: tabs(1) Linux manual page, tabs man page (macOS)

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link