From 7bef0ad9075c94c9e1c02732105dd0f10fe4897c Mon Sep 17 00:00:00 2001 From: Aminur Rahman Date: Thu, 24 Jul 2025 15:12:02 +0000 Subject: [PATCH 1/4] feat: Dotfiles multi-repo --- debug.sh | 2 ++ install.sh | 54 +++++++++++++++++++++++++++++++++++++------- test.code-workspace | 8 ------- test2.code-workspace | 8 ------- 4 files changed, 48 insertions(+), 24 deletions(-) create mode 100755 debug.sh delete mode 100644 test.code-workspace delete mode 100644 test2.code-workspace diff --git a/debug.sh b/debug.sh new file mode 100755 index 0000000..f949766 --- /dev/null +++ b/debug.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +gitpod_evars="${!GITPOD_*}" gp_evars="${!GP_*}"; for k in ${gitpod_evars:-} ${gp_evars:-}; do dargs+=(-e "${k}"); done; docker run "${dargs[@]}" --net=host --rm -v $PWD:/home/gitpod/.dotfiles -v /workspace:/workspace -v /ide:/ide -v /usr/bin/gp:/usr/bin/gp:ro -v /.supervisor:/.supervisor -v /var/run/docker.sock:/var/run/docker.sock --privileged -it gitpod/workspace-full bash -c 'trap "echo -e \"=== Run \033[1;32mexit\033[0m command to leave debug workspace\"; exec bash -li" EXIT ERR; echo "PROMPT_COMMAND=\"echo -n \\\"[debug-workspace] \\\"; \$PROMPT_COMMAND\"" >> $HOME/.bashrc; eval "$(gp env -e)"; dot_path="${HOME}/.dotfiles"; for s in install setup bootstrap; do if p="${dot_path}/${s}" && test -x "${p}" || p="${p}.sh" && test -x "${p}"; then set +m; "$p"; set -m; exit; fi; done; while read -r file; do rf_path="${file#"${dot_path}"/}"; target_file="${HOME}/${rf_path}"; target_dir="${target_file%/*}"; if test ! -d "$target_dir"; then mkdir -p "$target_dir"; fi; ln -sf "$file" "$target_file"; done < <(find "${dot_path}" -type f);' \ No newline at end of file diff --git a/install.sh b/install.sh index db69bc3..83a5b30 100755 --- a/install.sh +++ b/install.sh @@ -1,10 +1,48 @@ #!/usr/bin/env bash set -eux -( - if grep -q 'supervisor' /proc/1/cmdline; then { - gp ports await 23000 1>/dev/null - cd "${GITPOD_REPO_ROOT}" - code_wss=(*.code-workspace) - code -r "${DOTFILES_CODE_WORKSPACE:-${code_wss[-1]}}" - } fi -) & disown + +function add_folder_path() { + printf '{ "path": "%s" },\n' "${1}" +} + +function main() { + # Configure your addtional repos here + local additional_repos=( + "https://github.com/axonasif/test" + "https://github.com/axonasif/gearlock" + ) + + ###### No need to modify any logic below + ###### We can make the below non-blocking but then the IDE window may surprise the user + local repo_root="${GITPOD_REPO_ROOT}" + local workspaces_root=${repo_root%/*} + local code_ws; code_ws="$( + printf '%s\n' \ + '{' \ + '"folders": [' + + add_folder_path "${repo_root}" + for repo_url in "${additional_repos[@]}"; do { + local repo_clone_path="${workspaces_root}/${repo##*/}" + git clone --depth 1 "${repo_url}" "${repo_clone_path}" 1>&2 + add_folder_path "${repo_clone_path}" + } done + + printf '%s\n' \ + '],' \ + '}' + )" + + local ephemeral_code_ws_file=/tmp/multi-repo.code-workspace + printf '%s\n' "${code_ws}" > "${ephemeral_code_ws_file}" + + ( + if grep -q 'supervisor' /proc/1/cmdline; then { + gp ports await 23000 1>/dev/null + cd "${workspaces_root}" + code -r "${ephemeral_code_ws_file}" + } fi + ) & disown +} + +main "$@" diff --git a/test.code-workspace b/test.code-workspace deleted file mode 100644 index 5709732..0000000 --- a/test.code-workspace +++ /dev/null @@ -1,8 +0,0 @@ -{ - "folders": [ - { - "path": "." - } - ], - "settings": {} -} diff --git a/test2.code-workspace b/test2.code-workspace deleted file mode 100644 index 7371c09..0000000 --- a/test2.code-workspace +++ /dev/null @@ -1,8 +0,0 @@ -{ - "folders": [ - { - "path": "../" - } - ], - "settings": {} -} From b017fb3535e8948c304d2a50e5a75c46b2018e49 Mon Sep 17 00:00:00 2001 From: Aminur Rahman Date: Thu, 24 Jul 2025 15:17:50 +0000 Subject: [PATCH 2/4] Update readme --- README.md | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0820842..0f80779 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,30 @@ -# Dotfiles auto open (dot).code-workspace file +# Dotfiles Multi-Repository Workspace -This is a hack to auto open the available .code-workspace file in VS Code Web or Desktop +This dotfiles setup automatically creates a VS Code workspace that includes multiple repositories, allowing you to work with several related projects simultaneously in a single workspace. + +## How it works + +When you start a new Gitpod workspace, the `install.sh` script: + +1. **Configures additional repositories**: You can specify multiple GitHub repositories in the `additional_repos` array +2. **Clones repositories**: Automatically clones the specified repositories as siblings to your main dotfiles repository +3. **Creates dynamic workspace**: Generates a temporary `.code-workspace` file that includes all repositories as folders +4. **Opens multi-repo workspace**: Opens VS Code with all repositories accessible in a single workspace ## Quickstart 1. Fork this repository to your own account ([direct link](https://github.com/gitpod-samples/dotfiles.open_code_workspace/fork)) -2. Go to https://gitpod.io/user/preferences and scroll down. (You may replace `gitpod.io` with your own instance domain) -3. Copy your forked repo link and set it as **Dotfiles - Repository URL** and click on `Save`. -4. Create new workspace to see in action. +2. Edit the `install.sh` file and modify the `additional_repos` array to include your desired repositories: + ```bash + local additional_repos=( + "https://github.com/your-username/repo1" + "https://github.com/your-username/repo2" + # Add more repositories as needed + ) + ``` +3. Go to https://gitpod.io/user/preferences and scroll down. (You may replace `gitpod.io` with your own instance domain) +4. Copy your forked repo link and set it as **Dotfiles - Repository URL** and click on `Save`. +5. Create new workspace to see in action. ## Customization From 1ad2a37a459bddf7d320bc8fb3c2a856ad346352 Mon Sep 17 00:00:00 2001 From: Aminur Rahman Date: Thu, 24 Jul 2025 15:24:20 +0000 Subject: [PATCH 3/4] Fix some logic --- install.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 83a5b30..f784fb4 100755 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ set -eux function add_folder_path() { - printf '{ "path": "%s" },\n' "${1}" + printf '\t\t{ "path": "%s" },\n' "${1}" } function main() { @@ -19,17 +19,19 @@ function main() { local code_ws; code_ws="$( printf '%s\n' \ '{' \ - '"folders": [' + ' "folders": [' add_folder_path "${repo_root}" for repo_url in "${additional_repos[@]}"; do { - local repo_clone_path="${workspaces_root}/${repo##*/}" - git clone --depth 1 "${repo_url}" "${repo_clone_path}" 1>&2 + local repo_clone_path="${workspaces_root}/${repo_url##*/}" + if test ! -e "${repo_clone_path}/.git"; then { + git clone --depth 1 "${repo_url}" "${repo_clone_path}" 1>&2 + } fi add_folder_path "${repo_clone_path}" } done printf '%s\n' \ - '],' \ + ' ],' \ '}' )" From 740cb75b5ebeb1d6b3ed9f0dbae22f7ec3742686 Mon Sep 17 00:00:00 2001 From: Aminur Rahman Date: Thu, 24 Jul 2025 15:41:26 +0000 Subject: [PATCH 4/4] Add material icon extension recommendation --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index f784fb4..13a84b1 100755 --- a/install.sh +++ b/install.sh @@ -32,6 +32,7 @@ function main() { printf '%s\n' \ ' ],' \ + ' "settings": { "extensions": { "recommendations": [ "PKief.material-icon-theme" ] } }' \ '}' )"