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.
-
-
Save tonylegrone/9214231 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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