Splitting a terminal window on the Mac so logs and commands sit side by side
A build is running and the log needs watching. A server is up and a curl has to hit it. A migration is halfway through and the query to check it should not wait for the prompt to come back. The obvious move is to cut the terminal window in half and put one thing on each side, which is why the search happens. The disappointment usually follows about ten seconds later, because the shortcut that looks like it does this in the app that ships with macOS does not do quite what the name suggests.
There are four separate answers here, and they solve different versions of the problem. One is built into Terminal. One is built into macOS and has nothing to do with terminals. One requires a different terminal app. One runs inside the shell and survives the window being closed entirely. Picking correctly takes about a minute once the differences are clear.
What Command-D does in the app that ships with macOS
Apple documents the shortcut in the Terminal user guide under the heading for working with Terminal windows and tabs. The entry reads: split window into two panes, Command-D. The matching entry below it reads: close split pane, Shift-Command-D. The menu items carry the same names, Split Pane and Close Split Pane.
What Apple does not document anywhere in that guide is a way to run two commands at once inside a single Terminal window. The guide's answers to running more than one thing are elsewhere: Command-N for a new window, Command-T for a new tab, Control-Command-N and Control-Command-T for a new window or tab carrying the same command as the current one. That silence is the reason the question keeps getting asked on Apple's own discussion boards and on Stack Exchange, and the reason the answers there send people to tabs, to separate windows, or to a different terminal app.
So the honest description of Command-D is this. It divides one window into two panes. If the goal is to look at output that has already scrolled past while continuing to type, that division is useful. If the goal is a second prompt, the pane is not where it comes from, and no amount of pressing Command-D will produce one.
Two more shortcuts from the same list are worth having in the hand before moving on, because they do the job that most people were really after. Control-Tab moves to the next tab. Control-Shift-Tab moves to the previous one. On a laptop with one screen, flipping between a build tab and a query tab with one keystroke is faster than any layout, and it costs nothing to set up.
Tabs, windows, and the window group that reopens the whole layout
Terminal's real multi-shell story is tabs and windows, and it has one feature that almost nobody uses and that fits this problem better than splitting does.
Window groups save an arrangement. Set up the windows the way the work wants them, position them on screen, give each one its profile and its tabs, then choose Window, then Save Windows as Group. Name it. Two checkboxes matter at that moment. One restores the commands that are safe to run without confirmation when the group opens. The other, labelled to use the window group when Terminal starts, makes that layout the thing Terminal opens with from then on.
Reopening is Window, then Open Window Group, then the name. Groups are managed in Terminal settings under Window Groups, where they can also be removed, imported or exported. The exported file ends in .terminal, which means a layout can be carried to another Mac or kept in a dotfiles repository alongside everything else.
For a machine where the same three terminals get opened every morning, in the same corners of the screen, pointed at the same directories, this is a better answer than any split. The layout stops being something to rebuild.
Tiling two terminal windows, which is a macOS feature rather than a terminal feature
Once the second shell lives in a second window, arranging the pair is the operating system's job, and macOS got much better at it recently. The window tiling shortcuts are documented on their own page in the Mac user guide, and they work on any app, Terminal included.
Fn-Control-Left Arrow moves the active window to the left half of the desktop. Fn-Control-Right Arrow moves it to the right half. Fn-Control-Up Arrow and Fn-Control-Down Arrow do the top and bottom halves, which is the better orientation for terminals, since a shell needs width more than it needs height. Fn-Control-F fills the desktop with the active window. Fn-Control-R returns a tiled window to the size it had before it was tiled.
The pair shortcuts are the ones that save real time here. Fn-Control-Shift-Left Arrow puts the active window on the left half and the second window on the right half in one press. Fn-Control-Shift-Up Arrow does the same thing stacked, active window on top, second window below. Two terminal windows, one keystroke, no dragging.
The same layouts are available by holding the pointer over the green button in the top-left corner of a window, where they appear under Move and Resize for the active window and under Fill and Arrange for several windows at once, and in the menu bar under Window, then Move and Resize, grouped as Halves, Quarters and Arrange.
This is the answer for the specific case of a log on one side and a prompt on the other, when both are ordinary Terminal windows and neither needs to survive a disconnect.
Terminal apps where a pane really is a second session
If the split has to happen inside one window, with two live prompts, the app has to be replaced. iTerm2 is the long-standing choice on macOS and its documentation is explicit about what a pane is: a tab is divided into rectangular panes, each of which is a different terminal session.
The shortcuts are worth noting because they collide with the one from the section above. In iTerm2, Command-D divides the current session vertically and Command-Shift-D divides it horizontally. Moving between panes is Command-Option and an arrow key, or Command-[ and Command-] to cycle. Command-Shift-Return maximises the current pane, hiding the others in that tab, and pressing it again brings them back. That last one matters more than it sounds, because a pane that was useful at a glance is usually too small to debug in.
The muscle memory clash is real and worth naming. The same keystroke that gives a scrollback pane in one app gives a second shell in the other.
tmux, for when the session has to outlive the window
Splitting inside the terminal app still ties the work to the app. Close the window, lose the panes. tmux moves the split one level down, into a program that runs on the machine and keeps running when nothing is attached to it.
The prefix key is Control-B by default, pressed and released before the next key. Control-B then the percent sign splits the current pane into two side by side. Control-B then a double quote splits it into two stacked one above the other. Each split can be split again, so any arrangement is reachable. Control-B and an arrow key moves between panes, Control-B then o moves to the next pane by number, and Control-B then z temporarily zooms one pane to fill the whole window, with a second press restoring the rest.
The part that makes tmux different in kind rather than degree is detaching. Control-B then d detaches, leaving everything inside still running. Later, tmux attach reconnects to it. The laptop can sleep, the SSH connection can drop, the terminal app can be quit and reopened, and the build is still going. For anything running on a remote machine, this is the answer, and the split panes come along as a side effect.
Which one fits which problem
| Approach | Two live prompts in one window | Survives closing the window | Set up in | Needs a different app |
|---|---|---|---|---|
| Terminal Command-D pane | No | No | One keystroke | No |
| Terminal tabs, Control-Tab to switch | Yes, one visible at a time | No | One keystroke | No |
| Two windows plus Fn-Control-Shift-Left | Two windows, side by side | No | One keystroke | No |
| Terminal window group | As many as saved | Reopens the layout | A few minutes, once | No |
| iTerm2 panes | Yes | No | One keystroke | Yes |
| tmux | Yes | Yes | A short learning curve | No, runs in any terminal |
Read down the first column and the shape of the decision appears. Most people searching for a split terminal want row three or row five. People working against a remote machine want row six and will not be satisfied by anything above it.
When the other half of the screen is not a terminal
There is a version of this problem that none of the above solves well. The thing that needs to sit beside the prompt is not a log. It is a dashboard, a ticket, a chat where someone is waiting for the deploy, an admin panel that has to be refreshed after the migration runs. The terminal split is being reached for because it is the only splitting tool in the hand, and then half of the split gets given to a browser window that is now competing for the same screen.
That is a window layout problem wearing a terminal costume. Tiling handles the simple version: Fn-Control-Left Arrow for the terminal, Fn-Control-Right Arrow for the browser, done. The version that tiling does not handle is having eight of those web tools, each needing its own account, each needing to be one keystroke away rather than one hunt away.
That is the gap a browser that keeps each web app in its own window is built for, and a small number of them now carry a real shell inside. One approach puts a login shell one keystroke away from the app pane, running on a real pty, with a separate shell per app that starts in the folder that app's work lives in. The relevant part for this question is not the shell itself but the arrangement: the terminal stops being a window to arrange against the other windows, because it already sits beside the thing it is being run for. The built-in terminal page covers what that looks like in practice, and workspaces covers the per-app separation it depends on.
What to change first
Start with the cheapest fix that matches the real problem. If two prompts are needed on one screen today, open a second Terminal window and press Fn-Control-Shift-Left Arrow. If the same layout gets rebuilt every morning, spend five minutes on a window group. If work happens on a remote machine, learn six tmux keys and stop losing sessions.
If the second pane keeps being filled with a browser rather than a shell, the layout problem is not in the terminal, and moving the web apps into a browser that keeps each one in its own window fixes more of it than any split will. SpaceDeck is one place to see how a real shell and the web apps it serves can share a window.
Frequently asked questions
Does Command-D give me a second shell in Terminal on macOS?
Apple's Terminal shortcut list describes Command-D as splitting the window into two panes and Shift-Command-D as closing the split pane. The guide documents no way to run two commands at once in a single Terminal window. For a second prompt, use Command-T for a new tab or Command-N for a new window, or use a terminal app whose panes are separate sessions.
What is the fastest way to get two terminal windows side by side?
Open the second window with Command-N, then press Fn-Control-Shift-Left Arrow. That moves the active window to the left half of the desktop and the second window to the right half in one keystroke. Fn-Control-Shift-Up Arrow does the same thing stacked, which usually reads better for terminal output since each shell keeps full width.
Why do Command-D and Command-Shift-D behave differently in iTerm2?
iTerm2 uses Command-D to divide the current session vertically and Command-Shift-D to divide it horizontally, and its documentation states that each pane is a different terminal session. The same keystroke therefore produces a pane in one app and a second shell in the other, which is the single most common source of confusion when switching between them.
Do I need tmux if my terminal app already splits into panes?
Only if the work has to survive losing the window. Panes inside a terminal app disappear with the app. A tmux session keeps running on the machine after Control-B then d detaches from it, and tmux attach picks it back up later. For anything long-running on a remote server, that outweighs the convenience of the app's own splits.
Can a terminal sit beside a web app instead of another terminal?
Yes, and for most day-to-day work that is the more useful pairing. macOS window tiling handles it for two windows with Fn-Control-Left Arrow and Fn-Control-Right Arrow. When several web tools are involved and each needs its own account, a browser that keeps each app in its own window, with a shell available beside them, removes the arranging step entirely.