One Action, Multiple Terminal Windows Running Stuff
Many developers rely on multiple terminal windows for managing various development tasks. Think npm run start
, Docker containers, Rails servers, and Webpack – all running concurrently. This isn't inherently bad, but it can be cumbersome. Remembering commands and arranging the terminal environment efficiently can be a challenge. Personally, I prefer split panes over tabs, though tabs work fine for separate projects.
Seeking solutions on Twitter yielded several options:
-
tmux: This was the most popular suggestion. It creates virtual panes within a single terminal session, allowing simultaneous execution of different commands. Its versatility is impressive, and its use in a new dev environment by my CodePen co-founder further validated its capabilities.
tmuxinator
offers improved configuration management for tmux. -
kitty: Described by one user as a more advanced tmux alternative, kitty supports custom layouts and startup commands.
-
Native Terminal Apps: Each operating system offers native solutions:
- macOS: iTerm2 excels at split panels and session management, though lacks built-in command triggering for pre-defined layouts. The default macOS Terminal also supports tabs and splitting, but feels less robust.
- Linux: Terminator is a popular choice.
- Windows: The default Windows Terminal provides pane support.
-
npm Task Runners: Tools like
concurrently
andnpm-run-all
streamline running multiple npm scripts. However, they're limited to npm scripts and don't inherently support separate pane output, making them better suited for short-running tasks. While you could create npm scripts for other commands, the output management remains a limitation.
As a macOS user, I focused on iTerm2 solutions. While lacking built-in command-triggered layouts, iTerm2's scriptability proved useful. While AppleScript support is being phased out in favor of Python, AppleScript currently works well.
Here's an AppleScript example:
iTerm2 AppleScript
tell application "iTerm" tell current window create window with default profile tell current session of current tab set name to "run.sh" write text "cd '/Users/chriscoyier/GitHub/CPOR'" write text "./run.sh" end tell create tab with default profile tell current session of current tab set name to "Rails" write text "cd '/Users/chriscoyier/GitHub/CPOR'" write text "nvm use" write text "yarn" write text "bundle install" write text "yarn run rails" end tell create tab with default profile tell current session of current tab set name to "webpack" write text "cd '/Users/chriscoyier/GitHub/CPOR'" write text "nvm use" write text "yarn" write text "yarn run dev" end tell (* split vertically - requires further investigation *) (* tell application "System Events" to keystroke "d" using command down *) (* delay 1 *) (* split horizontally - requires further investigation *) (* tell application "System Events" to keystroke "d" using {shift down, command down} *) (* delay 1 *) (* moving panes - requires permission *) (* tell application "System Events" to keystroke "]" using command down *) end tell end tell
This script successfully launches the desired processes in separate tabs. The commented-out sections represent attempts at programmatic pane splitting, which require further exploration. The reliance on keystrokes feels less elegant, and investigating Python-based scripting for more direct control is a future goal. The lack of easy compilation into a standalone app is also noteworthy.
Another macOS option is Alfred, a powerful workflow automation tool capable of managing complex terminal setups.
The above is the detailed content of One Action, Multiple Terminal Windows Running Stuff. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

It's out! Congrats to the Vue team for getting it done, I know it was a massive effort and a long time coming. All new docs, as well.

With the recent climb of Bitcoin’s price over 20k $USD, and to it recently breaking 30k, I thought it’s worth taking a deep dive back into creating Ethereum

I had someone write in with this very legit question. Lea just blogged about how you can get valid CSS properties themselves from the browser. That's like this.

The other day, I spotted this particularly lovely bit from Corey Ginnivan’s website where a collection of cards stack on top of one another as you scroll.

I'd say "website" fits better than "mobile app" but I like this framing from Max Lynch:

There are a number of these desktop apps where the goal is showing your site at different dimensions all at the same time. So you can, for example, be writing

If we need to show documentation to the user directly in the WordPress editor, what is the best way to do it?

Questions about purple slash areas in Flex layouts When using Flex layouts, you may encounter some confusing phenomena, such as in the developer tools (d...
