Skip to content

Instantly share code, notes, and snippets.

@evantravers
Last active August 29, 2015 13:56
Show Gist options
  • Save evantravers/9191527 to your computer and use it in GitHub Desktop.
Save evantravers/9191527 to your computer and use it in GitHub Desktop.
This creates a simple workspace in tmux

Workspace in tmux

I like to work using a separate tmux session for each active project/folder that I'm juggling. This script will either create or attach to a project based on it's name, using fasd to jump to the directory directly. The project will be named based on the basename of the folder, for easy switching using TMUX-s.

#!/bin/bash
# this is for setting up a workspace in tmux
TARGET_DIR=$(fasd -d $@)
TARGET_NAME=$(basename "$TARGET_DIR")
TMUX=
tmux new -d -s "$TARGET_NAME" -c "$TARGET_DIR"
tmux switchc -t "$TARGET_NAME"
@tonylegrone
Copy link

Periods are illegal in session names. My project folders are usually domain names and cause this script to fail.

Changing line 6 to the following avoids the issue:

TARGET_NAME=$(basename "$TARGET_DIR" | tr "." "-")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment