If you are familiar with IDEs, you know how easy it is to switch between sessions. Open a project’s folder, and that’s it; you just opened a session that you can resume later on – even if you start working on other projects in between.

I’m using Neovim for most of my coding work, along with a terminal or two, usually one with Claude Code or Cursor Agent and another for executing various commands (running make commands, running tests, etc.).

I wanted to design a simple way to create sessions for each project that I’m working on. It would allow me to quickly switch from project to project and keep the state of the different terminals that I opened for each project.

To do that, I decided to use tmux with some configuration that I’m gonna walk you through.

Overview of the bash commands

  • tn or tn foo: Creates a new session at the root of the current folder. If no parameter is given, it takes the name of the root folder; otherwise, it calls it foo, as in the example.
  • ta foo: Attaches to a session named foo.
  • tks bar: Kills the session named bar.
  • ts: Opens a custom fzf session selector to quickly select the session I want to work with. I’ll talk about this in depth later.

Configuration and shortcuts

Most of the configuration is done in tmux. In my case, I like to have all my terminals displayed as tabs at the top of the terminal. I can easily switch between my panels with shortcuts, either by pressing cmd + shift + 1, 2, 3... or by iterating over them with cmd + tab. It’s up to you to decide on your favourite way to display the terminals (tabs, horizontal or vertical splits, etc.).

Switching between sessions: the ts command

The command is essentially a shortcut linking to this Bash function. By calling the fuzzy_tmux_sessions() function, you can select one of the open tmux sessions or type to filter them with fzf.

__tmux_fzf_get_session__() {
    session=$(tmux list-sessions -F "#{session_name}" | fzf --exit-0 --reverse --bind 'tab:toggle-down,btab:toggle-up' --border='rounded' --margin='20%' --tmux )
    echo "$session"
}

fuzzy_tmux_sessions() {
    [[ -n "$TMUX" ]] && change="switch-client" || change="attach-session"
    if [[ -n "$1" ]]; then
        if [[ "$1" == "-ask" ]]; then
            read -r -p "New tmux session name: " session_name
        else
            session_name="$1"
        fi
        tmux $change -t "$session_name" 2>/dev/null || \
            (tmux -f "$HOME/.tmux/tmux.conf" new-session -d -s "$session_name" && \
            tmux $change -t "$session_name");
        return
    fi
    session=$(eval __tmux_fzf_get_session__)
    if [[ -z "$session" ]]; then
        return
    else
        tmux $change -t "$session" || echo "No sessions found."
    fi
}

Conclusion

Without an IDE, using tmux and some simple Bash shortcuts can enable you to quickly keep track of your most recent projects. Go to a folder and type tn to open a new session in that folder, then start coding before exiting. You can resume it later with ts by typing the name of the folder and picking up where you left off.

This simple approach has given me a lot of comfort, as I find myself frequently switching between different repositories in some complex projects: Terraform, API source code, Databricks deployments, etc.

The only drawback of this method, which I should address at some point, is the lack of persistent sessions when I shut down my laptop. At the moment, all sessions disappear once you kill the tmux server. I may try to fix this someday, but I haven’t felt the urge so far.