diff --git a/README.md b/README.md index d10d90b..c84837f 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,24 @@ nix-config # Launch nix-config project tmux session #### Template Types: - **Basic**: Single directory (nvim + ai + git + shell) - **Content**: Code directory + separate content directory -- **Research**: Code directory + separate paper directory +- **Research**: Code directory + separate paper directory + optional remote server + +#### Research Template Remote Server Support: +The research template supports optional remote server connections with these features: +- **Remote Server Window**: Window 7 with dual horizontal panes for parallel remote work +- **Automatic Connection**: SSH to configured server with automatic directory navigation +- **Reconnect Alias**: Type `r` in any remote pane to easily reconnect after network drops +- **Configuration**: Add `server` and `remoteDir` fields to research projects + +**Example Configuration:** +```nix +mdshortcut = { + template = "research"; + # ... other fields ... + server = "aicloud"; # SSH host from ~/.ssh/config + remoteDir = "~/MDS"; # Remote directory path +}; +``` #### Adding New Projects: Edit `config/projects.nix` and run `hms` to rebuild configuration. diff --git a/config/projects.json b/config/projects.json index 19372d2..8d3196e 120000 --- a/config/projects.json +++ b/config/projects.json @@ -1 +1 @@ -/nix/store/xqkhnpdqqiczakpc94wg27fw3qgqjk85-home-manager-files/.config/nix/config/projects.json \ No newline at end of file +/nix/store/wra0kir8w2f9g6q6qmy8jwk585vbgavr-home-manager-files/.config/nix/config/projects.json \ No newline at end of file diff --git a/config/projects.nix b/config/projects.nix index 543d465..aaa8243 100644 --- a/config/projects.nix +++ b/config/projects.nix @@ -35,6 +35,8 @@ codePath = "/Users/yanlin/Documents/Projects/Material Design Shortcut/MDShortcut-dev"; paperPath = "/Users/yanlin/Documents/Projects/Material Design Shortcut/MDShortcut-paper"; description = "Material Design Shortcut research project"; + server = "aicloud"; + remoteDir = "~/MDS"; }; daki3 = { @@ -43,5 +45,15 @@ codePath = "/Users/yanlin/Documents/Projects/AI systems & infrastructure/Codes"; description = "DAKI3 course Demo code"; }; + + diffdismatter = { + template = "research"; + name = "DiffDisMatter"; + codePath = "/Users/yanlin/Documents/Projects/Inverse Design of Disordered Materials/DiffDisMatter-dev"; + paperPath = "/Users/yanlin/Documents/Projects/Inverse Design of Disordered Materials/mc-denoising-paper"; + description = "Inverse material design"; + server = "aicloud"; + remoteDir = "~/DiffDisMatter"; + }; }; } diff --git a/scripts/project-launcher.sh b/scripts/project-launcher.sh index 7140109..15ed63c 100755 --- a/scripts/project-launcher.sh +++ b/scripts/project-launcher.sh @@ -64,6 +64,8 @@ SESSION_NAME=$(echo "$PROJECT_CONFIG" | jq -r '.name') CODE_PATH=$(echo "$PROJECT_CONFIG" | jq -r '.codePath') CONTENT_PATH=$(echo "$PROJECT_CONFIG" | jq -r '.contentPath // empty') PAPER_PATH=$(echo "$PROJECT_CONFIG" | jq -r '.paperPath // empty') +SERVER=$(echo "$PROJECT_CONFIG" | jq -r '.server // empty') +REMOTE_DIR=$(echo "$PROJECT_CONFIG" | jq -r '.remoteDir // empty') # Launch appropriate template case "$TEMPLATE" in @@ -82,7 +84,11 @@ case "$TEMPLATE" in echo "Error: Research template requires paperPath" exit 1 fi - exec "$TEMPLATES_DIR/research.sh" "$SESSION_NAME" "$CODE_PATH" "$PAPER_PATH" + if [ -n "$SERVER" ] && [ -n "$REMOTE_DIR" ]; then + exec "$TEMPLATES_DIR/research.sh" "$SESSION_NAME" "$CODE_PATH" "$PAPER_PATH" "$SERVER" "$REMOTE_DIR" + else + exec "$TEMPLATES_DIR/research.sh" "$SESSION_NAME" "$CODE_PATH" "$PAPER_PATH" + fi ;; *) echo "Error: Unknown template '$TEMPLATE'" diff --git a/scripts/templates/research.sh b/scripts/templates/research.sh index 609d7d6..23bf039 100755 --- a/scripts/templates/research.sh +++ b/scripts/templates/research.sh @@ -1,14 +1,16 @@ #!/bin/bash -# Research workflow template - code + separate paper directory -# Usage: research.sh SESSION_NAME CODE_PATH PAPER_PATH +# Research workflow template - code + separate paper directory + optional remote server +# Usage: research.sh SESSION_NAME CODE_PATH PAPER_PATH [SERVER] [REMOTE_DIR] SESSION_NAME="$1" CODE_PATH="$2" PAPER_PATH="$3" +SERVER="$4" +REMOTE_DIR="$5" if [ -z "$SESSION_NAME" ] || [ -z "$CODE_PATH" ] || [ -z "$PAPER_PATH" ]; then - echo "Usage: $0 SESSION_NAME CODE_PATH PAPER_PATH" + echo "Usage: $0 SESSION_NAME CODE_PATH PAPER_PATH [SERVER] [REMOTE_DIR]" exit 1 fi @@ -41,6 +43,17 @@ tmux select-pane -t $SESSION_NAME:5.1 tmux new-window -t $SESSION_NAME:6 -n "paper-git" -c "$PAPER_PATH" tmux send-keys -t $SESSION_NAME:6 "gitui" C-m +# Create remote server window if server details are provided +if [ -n "$SERVER" ] && [ -n "$REMOTE_DIR" ]; then + tmux new-window -t $SESSION_NAME:7 -n "remote" -c "$CODE_PATH" + tmux send-keys -t $SESSION_NAME:7 "alias r='ssh $SERVER -t \"cd $REMOTE_DIR && exec \\\$SHELL\"'" C-m + tmux send-keys -t $SESSION_NAME:7 "ssh $SERVER -t 'cd $REMOTE_DIR && exec \$SHELL'" C-m + tmux split-window -t $SESSION_NAME:7 -v -c "$CODE_PATH" + tmux send-keys -t $SESSION_NAME:7.2 "alias r='ssh $SERVER -t \"cd $REMOTE_DIR && exec \\\$SHELL\"'" C-m + tmux send-keys -t $SESSION_NAME:7.2 "ssh $SERVER -t 'cd $REMOTE_DIR && exec \$SHELL'" C-m + tmux select-pane -t $SESSION_NAME:7.1 +fi + tmux select-window -t $SESSION_NAME:1 tmux attach-session -t $SESSION_NAME \ No newline at end of file