From de7981555efa1c20d6c5fb5a3655d9d5a0eafde1 Mon Sep 17 00:00:00 2001 From: Belal Elsabbagh Date: Wed, 19 Feb 2025 09:22:47 +0200 Subject: [PATCH] added project --- project.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 project.sh diff --git a/project.sh b/project.sh new file mode 100755 index 0000000..bb58559 --- /dev/null +++ b/project.sh @@ -0,0 +1,35 @@ +#!/bin/zsh + +# Check if a directory path is provided +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Resolve the absolute path and directory name +DIR_PATH=$(realpath "$1") +DIR_NAME=$(basename "$DIR_PATH") + +# Check if the directory exists +if [ ! -d "$DIR_PATH" ]; then + echo "Error: Directory '$DIR_PATH' does not exist." + exit 1 +fi + +# Create or attach to a tmux session named after the directory +SESSION_NAME="$DIR_NAME" +tmux new-session -d -s "$SESSION_NAME" -c "$DIR_PATH" + +# Window 1: Open nvim +tmux rename-window -t "$SESSION_NAME:1" "nvim" +tmux send-keys -t "$SESSION_NAME:1" "nvim" C-m + +# Window 2: Terminal in the directory +tmux new-window -t "$SESSION_NAME:2" -n "terminal" -c "$DIR_PATH" + +# Window 3: Lazygit +tmux new-window -t "$SESSION_NAME:3" -n "lazygit" -c "$DIR_PATH" +tmux send-keys -t "$SESSION_NAME:3" "lazygit" C-m + +# Attach to the session +tmux attach-session -t "$SESSION_NAME"