A Practical Terminal-Based Development Environment

2 weeks ago 2

Modern development often involves managing multiple processes simultaneously. Between a backend server, a frontend build process, a database, and version control, it's easy to spend the first few minutes of any session just getting the workspace configured.

Over time, I've developed a setup that prioritizes automation and consistency. The goal is to reduce the manual steps required to start working. My current workflow is based almost entirely in the terminal, using tmuxp to manage sessions and a few carefully chosen tools for coding, file management, and version control.

The Foundation: Automated Sessions with tmuxp

Many terminal users are familiar with tmux for managing multiple shell sessions. I use a tool called tmuxp to automate the setup of these sessions. It uses a configuration file to define all the windows, panes, and startup commands for a project.

This means that instead of manually opening tabs, navigating to directories, and starting servers each time, I can define the entire workspace once in a YAML file.

Defining a Workspace in YAML

Here is a simplified tmuxp.yml configuration for a standard web project:

session_name: my-project windows: - window_name: 1-Editor panes: - shell_command: - cd code/project/ - hx . - window_name: 2-Backend panes: - shell_command: - cd code/project/api - npm run dev - window_name: 3-Frontend panes: - shell_command: - cd code/project/web - npm run dev - window_name: 4-Git panes: - shell_command: - cd code/project/ - gitui - window_name: 5-Files panes: - shell_command: - cd code/project/ - yazi - window_name: 6-AI panes: - shell_command: - cd code/project/ - gemini

The bashrc Alias

To make this easily accessible, I add a simple alias to my .bashrc or .zshrc file that links a short command to the project's configuration.

alias project="tmuxp load ~/projects/my-project/.tmuxp.yml"

Now, to begin working, I just run the project command. The alias tells tmuxp to load the configuration, and my terminal session is built automatically, with servers starting and the editor opening in the correct directories. This small alias streamlines the process of starting a work session considerably.

With the session automated, the next step is the set of tools used within each tab. I prefer tools that are designed for the terminal to maintain a consistent, keyboard-driven workflow.

Tab 1: The Editor - helix

My primary editor is Helix, a modal text editor that operates on a "selection first, then action" paradigm. This means you select the text you want to modify, and then you choose the action to perform on it.

A few reasons I use it:

Built-in LSP: It comes with out-of-the-box support for the Language Server Protocol (LSP), providing code intelligence features like autocomplete and diagnostics without extensive configuration.

Multiple Selections: It handles multiple cursors and selections as a core feature, which is useful for refactoring.

Tab 2 & 3: Backend and Frontend Servers

These tabs are straightforward. Tab 2 is dedicated to the backend server (e.g., a Node.js API), and Tab 3 runs the frontend development server (e.g., Vite). The tmuxp configuration starts these automatically. I use these tabs to monitor logs and check for compilation errors, keeping their outputs separate and organized.

Tab 4: Git Operations - gitui

For a long time, this tab was simply a clean shell for running standard Git commands. My workflow involved git status, git add, and git commit typed out manually, and it served me well. It kept everything inside the terminal, which was the main goal.

Recently, however, I switched to gitui, a terminal-based user interface for Git. It offers a more visual and interactive way to manage version control without the weight of a full GUI application. It allows me to see diffs clearly, stage individual lines or files with single keystrokes, and browse commit history much more efficiently. It's an upgrade that has sped up my commit process significantly while keeping me in the terminal.

Tab 5: File Management - yazi

For file operations like moving, renaming, or just browsing the directory structure, I use yazi. It's a terminal file manager with built-in previews that lets me manage files without having to interrupt my editor. It's useful for quick operations that might otherwise feel clumsy with standard shell commands.

Tab 6: AI Assistant - Gemini CLI

This tab is a dedicated shell for the Gemini CLI. Having direct access to a command-line AI assistant is useful for a number of tasks without leaving the terminal.

For example, I might use it to:

  • Generate a shell command for a specific task.
  • Get a brief explanation of a code snippet from another file.
  • Ask for help with syntax or programming concepts.

Integrating this into a dedicated tab makes it a low-friction way to get quick assistance.

How It All Works Together

The main benefit of this setup is how the tools integrate into a single workflow. Minimizing the need to switch between different applications is a primary goal.

A Typical Workflow

A common task might look like this:

  • Run project to start the session.
  • Work on code in Tab 1 (Helix).
  • After saving, glance at Tab 2 (Backend) and Tab 3 (Frontend) to confirm the servers have reloaded without errors.
  • If I need clarification on a library function, I switch to Tab 6 (Gemini CLI) to ask a question.
  • Once the feature is complete, I move to Tab 4 (gitui).
  • I visually review the changes, stage the necessary files or lines with a few keystrokes, and open the commit dialog.
  • After writing my message, I confirm the commit, all within the gitui interface.
  • If I need to reorganize some files, I can quickly do so in Tab 5 (yazi) before amending the commit.

The entire process takes place within the terminal, which helps maintain focus on the task at hand.

Conclusion

This setup is the result of gradual refinement to build a more consistent and focused development process. The specific tools aren't as important as the underlying principle: use automation to configure your workspace and choose tools that minimize context switching.

If you find yourself spending too much time setting up your environment, I'd encourage you to try tmuxp. Defining your workspace in a configuration file is a small investment that can make the start of every coding session a little more efficient.

Read Entire Article