{"id":13821924,"url":"https://github.com/Alex-D/dotfiles","last_synced_at":"2025-05-16T15:31:42.590Z","repository":{"id":54602372,"uuid":"152086909","full_name":"Alex-D/dotfiles","owner":"Alex-D","description":"Windows + WSL 2 Ubuntu + Windows Terminal + zsh + systemd + p10k + Docker + IntelliJ IDEA + GitBash with zsh","archived":false,"fork":false,"pushed_at":"2024-10-17T23:11:40.000Z","size":132,"stargazers_count":200,"open_issues_count":1,"forks_count":28,"subscribers_count":10,"default_branch":"main","last_synced_at":"2024-11-14T16:05:27.942Z","etag":null,"topics":["docker","docker-compose","dotfiles","systemd","windows","wsl","wsl-ubuntu","zsh"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Alex-D.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Alex-D","patreon":"AlexandreDemode","custom":"https://paypal.me/demodealexandre"}},"created_at":"2018-10-08T13:43:00.000Z","updated_at":"2024-10-22T05:15:10.000Z","dependencies_parsed_at":"2024-11-07T16:01:07.869Z","dependency_job_id":"45c87a2f-38fe-4e61-a95f-26fe7be0fd05","html_url":"https://github.com/Alex-D/dotfiles","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alex-D%2Fdotfiles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alex-D%2Fdotfiles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alex-D%2Fdotfiles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alex-D%2Fdotfiles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alex-D","download_url":"https://codeload.github.com/Alex-D/dotfiles/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225436384,"owners_count":17474137,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","dotfiles","systemd","windows","wsl","wsl-ubuntu","zsh"],"created_at":"2024-08-04T08:01:34.189Z","updated_at":"2024-11-19T22:31:26.137Z","avatar_url":"https://github.com/Alex-D.png","language":"Shell","funding_links":["https://github.com/sponsors/Alex-D","https://patreon.com/AlexandreDemode","https://paypal.me/demodealexandre"],"categories":["Shell"],"sub_categories":[],"readme":"My Windows 10 Setup \u0026 Dotfiles\r\n==============================\r\n\r\nGoals of this setup\r\n-------------------\r\n\r\n- Working on Windows 10, on WSL 2 filesystem\r\n- Having a visually nice terminal (Windows Terminal)\r\n- zsh as my main shell\r\n- Using Docker and Docker Compose directly from zsh\r\n- Using IntelliJ IDEA directly from WSL 2\r\n\r\n\r\nWhat's in this setup?\r\n---------------------\r\n\r\n- Host: Windows 10 2004+\r\n  - Ubuntu via WSL 2 (Windows Subsystem for Linux)\r\n- Terminal: Windows Terminal\r\n- Systemd\r\n- zsh\r\n- git\r\n- Docker\r\n- Docker Compose\r\n- Node.js (using [Volta](https://volta.sh))\r\n  - node\r\n  - npm\r\n  - yarn\r\n- Go\r\n- IDE: IntelliJ IDEA, under WSL 2, used on Windows via VcXsrv\r\n- WSL Bridge: allow exposing WSL 2 ports on the network\r\n\r\n\r\nOther guides\r\n------------\r\n\r\n- [GitBash with zsh](git-bash/README.md), for better git performances on Windows filesystem\r\n- [Server](server/README.md)\r\n\r\n\r\n----------------------\r\n\r\n\r\nSetup WSL 2\r\n-----------\r\n\r\n- Enable WSL 2 and update the linux kernel ([Source](https://docs.microsoft.com/en-us/windows/wsl/install-win10))\r\n\r\n```powershell\r\n# In PowerShell as Administrator\r\n\r\n# Enable WSL and VirtualMachinePlatform features\r\ndism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart\r\ndism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart\r\n\r\n# Download and install the Linux kernel update package\r\n$wslUpdateInstallerUrl = \"https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi\"\r\n$downloadFolderPath = (New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path\r\n$wslUpdateInstallerFilePath = \"$downloadFolderPath/wsl_update_x64.msi\"\r\n$wc = New-Object System.Net.WebClient\r\n$wc.DownloadFile($wslUpdateInstallerUrl, $wslUpdateInstallerFilePath)\r\nStart-Process -Filepath \"$wslUpdateInstallerFilePath\"\r\n\r\n# Set WSL default version to 2\r\nwsl --set-default-version 2\r\n```\r\n\r\n- [Install Ubuntu from Microsoft Store](https://www.microsoft.com/fr-fr/p/ubuntu/9nblggh4msv6)\r\n\r\n\r\nInstall common dependencies\r\n---------------------------\r\n\r\n```shell script\r\n#!/bin/bash\r\n\r\nsudo apt update \u0026\u0026 sudo apt install -y \\\r\n    apt-transport-https \\\r\n    ca-certificates \\\r\n    curl \\\r\n    gnupg-agent \\\r\n    software-properties-common \\\r\n    git \\\r\n    make \\\r\n    tig \\\r\n    tree \\\r\n    zip unzip \\\r\n    zsh\r\n```\r\n\r\n\r\nGPG key\r\n-------\r\n\r\nIf you already have a GPG key, restore it. If you did not have one, you can create one.\r\n\r\n### Restore\r\n\r\n- On old system, create a backup of a GPG key\r\n  - `gpg --list-secret-keys`\r\n  - `gpg --export-secret-keys {{KEY_ID}} \u003e /tmp/private.key`\r\n- On new system, import the key:\r\n  - `gpg --import /tmp/private.key`\r\n- Delete the `/tmp/private.key` on both side\r\n\r\n### Create\r\n\r\n- `gpg --full-generate-key`\r\n\r\n[Read GitHub documentation about generating a new GPG key for more details](https://docs.github.com/en/github/authenticating-to-github/generating-a-new-gpg-key).\r\n\r\n\r\nSetup Git\r\n---------\r\n\r\n```shell script\r\n#!/bin/bash\r\n\r\n# Set username and email for next commands\r\nemail=\"contact@alex-d.fr\"\r\nusername=\"Alex-D\"\r\ngpgkeyid=\"8FA78E6580B1222A\"\r\n\r\n# Configure Git\r\ngit config --global user.email \"${email}\"\r\ngit config --global user.name \"${username}\"\r\ngit config --global user.signingkey \"${gpgkeyid}\"\r\ngit config --global commit.gpgsign true\r\ngit config --global core.pager /usr/bin/less\r\ngit config --global core.excludesfile ~/.gitignore\r\n\r\n# Generate a new SSH key\r\nssh-keygen -t rsa -b 4096 -C \"${email}\"\r\n\r\n# Start ssh-agent and add the key to it\r\neval $(ssh-agent -s)\r\nssh-add ~/.ssh/id_rsa\r\n\r\n# Display the public key ready to be copy pasted to GitHub\r\ncat ~/.ssh/id_rsa.pub\r\n```\r\n\r\n- [Add the generated key to GitHub](https://github.com/settings/ssh/new)\r\n\r\n\r\nSetup zsh\r\n---------\r\n\r\n```shell script\r\n#!/bin/bash\r\n\r\n# Clone the dotfiles repository\r\nmkdir -p ~/dev/dotfiles\r\ngit clone git@github.com:Alex-D/dotfiles.git ~/dev/dotfiles\r\n\r\n# Install Antibody and generate .zsh_plugins.zsh\r\ncurl -sfL git.io/antibody | sudo sh -s - -b /usr/local/bin\r\nantibody bundle \u003c ~/dev/dotfiles/zsh_plugins \u003e ~/.zsh_plugins.zsh\r\n\r\n# Link custom dotfiles\r\nln -sf ~/dev/dotfiles/.aliases.zsh ~/.aliases.zsh\r\nln -sf ~/dev/dotfiles/.p10k.zsh ~/.p10k.zsh\r\nln -sf ~/dev/dotfiles/.zshrc ~/.zshrc\r\nln -sf ~/dev/dotfiles/.gitignore ~/.gitignore\r\n\r\n# Create .screen folder used by .zshrc\r\nmkdir ~/.screen \u0026\u0026 chmod 700 ~/.screen\r\n\r\n# Change default shell to zsh\r\nchsh -s $(which zsh)\r\n```\r\n\r\n\r\nSetup GitHub CLI\r\n----------------\r\n\r\n```shell script\r\n#!/bin/zsh\r\n\r\ncurl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg\r\necho \"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main\" | sudo tee /etc/apt/sources.list.d/github-cli.list \u003e /dev/null\r\nsudo apt update\r\nsudo apt install gh\r\n```\r\n\r\nLogin gh command to GitHub via `gh auth login`\r\n\r\n\r\nDocker\r\n------\r\n\r\n### Setup Docker\r\n\r\n```shell script\r\n#!/bin/zsh\r\n\r\n# Add Docker to sources.list\r\ncurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg\r\necho \\\r\n  \"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \\\r\n  $(lsb_release -cs) stable\" | sudo tee /etc/apt/sources.list.d/docker.list \u003e /dev/null\r\n\r\n# Install tools\r\nsudo apt update \u0026\u0026 sudo apt install -y \\\r\n    docker-ce docker-ce-cli containerd.io\r\n\r\n# Add user to docker group\r\nsudo usermod -aG docker $USER\r\n```\r\n\r\nYou can start Docker daemon via [Systemd](#systemd) or via `dcs` alias.\r\n\r\n\r\nDocker Compose\r\n--------------\r\n\r\n```shell script\r\n#!/bin/zsh\r\n\r\nsudo curl -sL -o /usr/local/bin/docker-compose $(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep \"browser_download_url.*$(uname -s | awk '{print tolower($0)}')-$(uname -m)\" | grep -v sha | cut -d: -f2,3 | tr -d \\\")\r\nsudo chmod +x /usr/local/bin/docker-compose\r\n```\r\n\r\n\r\nNode.js\r\n-------\r\n\r\n```shell script\r\n#!/bin/zsh\r\n\r\n# Install Volta\r\nmkdir -p $VOLTA_HOME\r\ncurl https://get.volta.sh | bash -s -- --skip-setup\r\n\r\n# Install node and package managers\r\nvolta install node npm yarn\r\n```\r\n\r\n\r\nGo\r\n---\r\n\r\n```shell script\r\n#!/bin/zsh\r\n\r\ngoVersion=1.16.4\r\ncurl -L \"https://golang.org/dl/go${goVersion}.linux-amd64.tar.gz\" \u003e /tmp/go${goVersion}.linux-amd64.tar.gz\r\nsudo rm -rf /usr/local/go\r\nsudo tar -C /usr/local -xzf /tmp/go${goVersion}.linux-amd64.tar.gz\r\nrm /tmp/go${goVersion}.linux-amd64.tar.gz\r\n```\r\n\r\n[See official documentation](https://golang.org/doc/install)\r\n\r\n\r\nIntelliJ IDEA\r\n-------------\r\n\r\nI run IntelliJ IDEA in WSL 2, and get its GUI on Windows via X Server (VcXsrv).\r\n\r\n### Setup VcXsrv\r\n\r\n- [Install VcXsrv (XLaunch)](https://sourceforge.net/projects/vcxsrv/)\r\n\r\n```shell script\r\nwindowsUserProfile=/mnt/c/Users/$(cmd.exe /c \"echo %USERNAME%\" 2\u003e/dev/null | tr -d '\\r')\r\n\r\n# Run VcXsrv at startup\r\ncp ~/dev/dotfiles/config.xlaunch \"${windowsUserProfile}/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup\"\r\n```\r\n\r\n### Install IntelliJ IDEA\r\n\r\n```shell script\r\n#!/bin/zsh\r\n\r\n# Install IDEA dependencies\r\nsudo apt update \u0026\u0026 sudo apt install -y \\\r\n    fontconfig \\\r\n    libxss1 \\\r\n    libnss3 \\\r\n    libatk1.0-0 \\\r\n    libatk-bridge2.0-0 \\\r\n    libgbm1 \\\r\n    libpangocairo-1.0-0 \\\r\n    libcups2 \\\r\n    libxkbcommon0\r\n\r\n# Create install folder\r\nsudo mkdir /opt/idea\r\n\r\n# Allow your user to run IDEA updates from GUI\r\nsudo chown $UID:$UID /opt/idea\r\n\r\n# Download IntelliJ IDEA\r\ncurl -L \"https://download.jetbrains.com/product?code=IIU\u0026latest\u0026distribution=linux\" | tar vxz -C /opt/idea --strip 1\r\n```\r\n\r\n\r\nSetup Windows Terminal\r\n----------------------\r\n\r\n- [Download and install JetBrains Mono](https://www.jetbrains.com/mono/)\r\n- [Install Windows Terminal](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701)\r\n\r\n```shell script\r\n#!/bin/zsh\r\n\r\nwindowsUserProfile=/mnt/c/Users/$(cmd.exe /c \"echo %USERNAME%\" 2\u003e/dev/null | tr -d '\\r')\r\n\r\n# Copy Windows Terminal settings\r\ncp ~/dev/dotfiles/terminal-settings.json ${windowsUserProfile}/AppData/Local/Packages/Microsoft.WindowsTerminal_8wekyb3d8bbwe/LocalState/settings.json\r\n```\r\n\r\n\r\nWSL Bridge\r\n----------\r\n\r\nWhen a port is listening from WSL 2, it cannot be reached.\r\nYou need to create port proxies for each port you want to use.\r\nTo avoid doing than manually each time I start my computer, I've made the `wslb` alias that will run the `wsl2bridge.ps1` script in an admin Powershell.\r\n\r\n```shell script\r\n#!/bin/zsh\r\n\r\nwindowsUserProfile=/mnt/c/Users/$(cmd.exe /c \"echo %USERNAME%\" 2\u003e/dev/null | tr -d '\\r')\r\n\r\n# Get the hacky network bridge script\r\ncp ~/dev/dotfiles/wsl2-bridge.ps1 ${windowsUserProfile}/wsl2-bridge.ps1\r\n```\r\n\r\nIn order to allow `wsl2-bridge.ps1` script to run, you need to update your PowerShell execution policy.\r\n\r\n```powershell\r\n# In PowerShell as Administrator\r\n\r\nSet-ExecutionPolicy -ExecutionPolicy RemoteSigned\r\nPowerShell -File $env:USERPROFILE\\\\wsl2-bridge.ps1\r\n```\r\n\r\nThen, when port forwarding does not work between WSL 2 and Windows, run `wslb` from zsh:\r\n\r\n```shell script\r\n#!/bin/zsh\r\n\r\nwslb\r\n```\r\n\r\nNote: This is a custom alias. See [`.aliases.zsh`](.aliases.zsh) for more details\r\n\r\n\r\nLimit WSL 2 RAM consumption\r\n---------------------------\r\n\r\n```shell script\r\n#!/bin/zsh\r\n\r\nwindowsUserProfile=/mnt/c/Users/$(cmd.exe /c \"echo %USERNAME%\" 2\u003e/dev/null | tr -d '\\r')\r\n\r\n# Avoid too much RAM consumption\r\ncp ~/dev/dotfiles/.wslconfig ${windowsUserProfile}/.wslconfig\r\n```\r\n\r\nNote: You can adjust the RAM amount in `.wslconfig` file. Personally, I set it to 8 GB.\r\n\r\n\r\nInstall kubectl\r\n---------------\r\n\r\n```shell script\r\n#!/bin/zsh\r\n\r\nsudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg\r\necho \"deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main\" | sudo tee /etc/apt/sources.list.d/kubernetes.list\r\nsudo apt-get update\r\nsudo apt-get install -y kubectl\r\n```\r\n\r\n[Original documentation](https://master--kubernetes-io-master-staging.netlify.app/docs/tasks/tools/install-kubectl-linux/#install-using-native-package-management)\r\n\r\n\r\nInstall AWS CLI\r\n---------------\r\n\r\n```shell script\r\n#!/bin/zsh\r\n\r\ncd /tmp/aws-cli\r\ncurl \"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip\" -o \"awscliv2.zip\"\r\nunzip awscliv2.zip\r\nsudo ./aws/install\r\ncd -\r\nrm -rf /tmp/aws-cli\r\n```\r\n\r\n[Original documentation](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html)\r\n\r\n\r\nSetup Git Filter Repo\r\n---------------------\r\n\r\n```shell script\r\n#!/bin/zsh\r\n\r\ngit clone git@github.com:newren/git-filter-repo.git /tmp/git-filter-repo\r\ncd /tmp/git-filter-repo\r\nmake snag_docs\r\nsudo cp -a git-filter-repo $(git --exec-path)\r\nsudo cp -a Documentation/man1/git-filter-repo.1 $(git --man-path)/man1\r\nsudo cp -a Documentation/html/git-filter-repo.html $(git --html-path)\r\ncd -\r\nrm -rf /tmp/git-filter-repo\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlex-D%2Fdotfiles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAlex-D%2Fdotfiles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlex-D%2Fdotfiles/lists"}