Skip to content

Commit e14ad42

Browse files
committed
Integrate tmuxinator better with code projects
1 parent 5dd6d9c commit e14ad42

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

scripts/tmux/mktmuxinator

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#! /bin/sh
2+
3+
OUT_NAME=.tmuxinator.yml
4+
5+
if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$1" = "help" ]; then
6+
cat <<EOF
7+
$ mktmuxinator
8+
Create a $OUT_NAME in a code project for use with 'tp'
9+
EOF
10+
exit
11+
fi
12+
13+
cwd=$(pwd)
14+
project=${cwd##*/}
15+
16+
cat <<EOF >$OUT_NAME
17+
name: $project
18+
root: $cwd
19+
windows:
20+
- vim: vim
21+
- zsh
22+
layout: 278d,151x33,0,0[151x12,0,0,35,151x20,0,13,36]
23+
# tmux list-windows
24+
panes:
25+
- nwb
26+
-
27+
EOF
28+
29+
echo "Wrote $OUT_NAME"
30+
$EDITOR $OUT_NAME

scripts/tmux/tp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
PROJECT_DIR=$HOME/Downloads/fs/project
44
DIR=`dirname $0`
5+
CODE_DIR="$HOME/code"
6+
CODE_TMUXINATOR_FILE=".tmuxinator.yml"
57

68
if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$1" = "help" ]; then
79
cat <<EOF
@@ -28,8 +30,18 @@ if tmux list-sessions 2>/dev/null | cut -d: -f1 | grep "^$PROJECT$" >/dev/null;
2830
exit 0
2931
fi
3032

33+
is_code_project() {
34+
if [ -d "$CODE_DIR/$PROJECT" ] && [ -f "$CODE_DIR/$PROJECT/$CODE_TMUXINATOR_FILE" ]; then
35+
true
36+
else
37+
echo "No $CODE_TMUXINATOR_FILE file in $CODE_DIR/$PROJECT"
38+
echo "You can add it with: mktmuxinator"
39+
false
40+
fi
41+
}
42+
3143
case $PROJECT in
3244
main) tmuxinator start main -p $DIR/tmuxinator.yml;;
33-
*) tmuxinator start $PROJECT -p $PROJECT_DIR/$PROJECT/tmux.yml;;
45+
*) is_code_project && tmuxinator start $PROJECT -p $CODE_DIR/$PROJECT/$CODE_TMUXINATOR_FILE;;
3446
esac
3547

0 commit comments

Comments
 (0)