Add remote server support to research template

- Add server and remoteDir fields to research projects configuration
- Update project launcher to handle remote server parameters
- Enhance research template with remote server window (window 7)
- Add dual-pane remote SSH connections with auto-reconnect aliases
- Document remote server features in README with configuration examples

Features:
- Type 'r' in any remote pane to reconnect after network drops
- Automatic SSH connection and directory navigation
- Parallel remote work with dual panes
- Backwards compatible - optional server configuration

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Yan Lin 2025-07-27 18:01:20 +02:00
parent c3872475b5
commit 5b2d62ffa6
5 changed files with 54 additions and 6 deletions

View file

@ -181,7 +181,24 @@ nix-config # Launch nix-config project tmux session
#### Template Types: #### Template Types:
- **Basic**: Single directory (nvim + ai + git + shell) - **Basic**: Single directory (nvim + ai + git + shell)
- **Content**: Code directory + separate content directory - **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: #### Adding New Projects:
Edit `config/projects.nix` and run `hms` to rebuild configuration. Edit `config/projects.nix` and run `hms` to rebuild configuration.

View file

@ -1 +1 @@
/nix/store/xqkhnpdqqiczakpc94wg27fw3qgqjk85-home-manager-files/.config/nix/config/projects.json /nix/store/wra0kir8w2f9g6q6qmy8jwk585vbgavr-home-manager-files/.config/nix/config/projects.json

View file

@ -35,6 +35,8 @@
codePath = "/Users/yanlin/Documents/Projects/Material Design Shortcut/MDShortcut-dev"; codePath = "/Users/yanlin/Documents/Projects/Material Design Shortcut/MDShortcut-dev";
paperPath = "/Users/yanlin/Documents/Projects/Material Design Shortcut/MDShortcut-paper"; paperPath = "/Users/yanlin/Documents/Projects/Material Design Shortcut/MDShortcut-paper";
description = "Material Design Shortcut research project"; description = "Material Design Shortcut research project";
server = "aicloud";
remoteDir = "~/MDS";
}; };
daki3 = { daki3 = {
@ -43,5 +45,15 @@
codePath = "/Users/yanlin/Documents/Projects/AI systems & infrastructure/Codes"; codePath = "/Users/yanlin/Documents/Projects/AI systems & infrastructure/Codes";
description = "DAKI3 course Demo code"; 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";
};
}; };
} }

View file

@ -64,6 +64,8 @@ SESSION_NAME=$(echo "$PROJECT_CONFIG" | jq -r '.name')
CODE_PATH=$(echo "$PROJECT_CONFIG" | jq -r '.codePath') CODE_PATH=$(echo "$PROJECT_CONFIG" | jq -r '.codePath')
CONTENT_PATH=$(echo "$PROJECT_CONFIG" | jq -r '.contentPath // empty') CONTENT_PATH=$(echo "$PROJECT_CONFIG" | jq -r '.contentPath // empty')
PAPER_PATH=$(echo "$PROJECT_CONFIG" | jq -r '.paperPath // 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 # Launch appropriate template
case "$TEMPLATE" in case "$TEMPLATE" in
@ -82,7 +84,11 @@ case "$TEMPLATE" in
echo "Error: Research template requires paperPath" echo "Error: Research template requires paperPath"
exit 1 exit 1
fi 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'" echo "Error: Unknown template '$TEMPLATE'"

View file

@ -1,14 +1,16 @@
#!/bin/bash #!/bin/bash
# Research workflow template - code + separate paper directory # Research workflow template - code + separate paper directory + optional remote server
# Usage: research.sh SESSION_NAME CODE_PATH PAPER_PATH # Usage: research.sh SESSION_NAME CODE_PATH PAPER_PATH [SERVER] [REMOTE_DIR]
SESSION_NAME="$1" SESSION_NAME="$1"
CODE_PATH="$2" CODE_PATH="$2"
PAPER_PATH="$3" PAPER_PATH="$3"
SERVER="$4"
REMOTE_DIR="$5"
if [ -z "$SESSION_NAME" ] || [ -z "$CODE_PATH" ] || [ -z "$PAPER_PATH" ]; then 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 exit 1
fi 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 new-window -t $SESSION_NAME:6 -n "paper-git" -c "$PAPER_PATH"
tmux send-keys -t $SESSION_NAME:6 "gitui" C-m 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 select-window -t $SESSION_NAME:1
tmux attach-session -t $SESSION_NAME tmux attach-session -t $SESSION_NAME