Skip to content

Instantly share code, notes, and snippets.

@tonylegrone
Forked from evantravers/README.md
Last active August 29, 2015 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonylegrone/9214231 to your computer and use it in GitHub Desktop.
Save tonylegrone/9214231 to your computer and use it in GitHub Desktop.

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
# -polka-
# this is for setting up a workspace in tmux
if [ $1 ]
then
TARGET_DIR=$(fasd -d $1)
else
# Fall back on current directory
TARGET_DIR=$(pwd)
fi
if [ $2 ]
then
TARGET_NAME=$2
else
# Fall back on target name generated from $TARGET_DIR
TARGET_NAME=$(basename "$TARGET_DIR" | tr "." "-")
fi
TMUX=
tmux new -d -s "$TARGET_NAME" -c "$TARGET_DIR"
tmux switchc -t "$TARGET_NAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment