Alex-D/dotfiles
À propos
Windows + WSL 2 Ubuntu + Windows Terminal + zsh + systemd + p10k + Docker + IntelliJ IDEA + GitBash with zsh
Systèmes et infrastructureProgression mesurée des étoiles
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
OriginalMy Windows 10 Setup & Dotfiles
Goals of this setup
- Working on Windows 10, on WSL 2 filesystem
- Having a visually nice terminal (Windows Terminal)
- zsh as my main shell
- Using Docker and Docker Compose directly from zsh
- Using IntelliJ IDEA directly from WSL 2
What's in this setup?
- Host: Windows 10 2004+
- Ubuntu via WSL 2 (Windows Subsystem for Linux)
- Terminal
- Windows: Windows Terminal, with light and dark themes
- macOS: Ghostty
- Systemd
- zsh
- git
- Docker
- Docker Compose
- Vite+
- node
- pnpm
- Go
- WSL Bridge: allow exposing WSL 2 ports on the network
Other guides
- GitBash with zsh, for better git performances on Windows filesystem
- Server
Setup WSL 2
- Enable WSL 2 and update the linux kernel (Source)
# In PowerShell as Administrator
# Enable WSL and VirtualMachinePlatform features
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# Download and install the Linux kernel update package
$wslUpdateInstallerUrl = "https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi"
$downloadFolderPath = (New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path
$wslUpdateInstallerFilePath = "$downloadFolderPath/wsl_update_x64.msi"
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($wslUpdateInstallerUrl, $wslUpdateInstallerFilePath)
Start-Process -Filepath "$wslUpdateInstallerFilePath"
# Set WSL default version to 2
wsl --set-default-version 2
Install common dependencies
Linux / WSL 2
#!/bin/bash
sudo apt update && sudo apt install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common \
git \
make \
tig \
tree \
zip unzip \
zsh
macOS
# Install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install dependencies
brew install \
gnupg \
tig \
tree
GPG key
If you already have a GPG key, restore it. If you did not have one, you can create one.
Restore
- On the old system, create a backup of a GPG key
gpg --list-secret-keysgpg --export-secret-keys {{KEY_ID}} > /tmp/private.key
- On the new system, import the key:
gpg --import /tmp/private.key
- Delete the
/tmp/private.keyon both side
Create
gpg --full-generate-key
Read GitHub documentation about generating a new GPG key for more details.
Setup Git
#!/bin/bash
# Set username and email for next commands
email="[email protected]"
username="Alex-D"
gpgkeyid="8FA78E6580B1222A"
# Configure Git
git config --global user.email "${email}"
git config --global user.name "${username}"
git config --global user.signingkey "${gpgkeyid}"
git config --global commit.gpgsign true
git config --global core.pager /usr/bin/less
git config --global core.excludesfile ~/.gitignore
# Generate a new SSH key
ssh-keygen -t rsa -b 4096 -C "${email}"
# Start ssh-agent and add the key to it
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa
# Display the public key ready to be copy pasted to GitHub
cat ~/.ssh/id_rsa.pub
# Setup Delta (see https://github.com/dandavison/delta)
DELTA_VERSION=$(curl -s https://api.github.com/repos/dandavison/delta/releases/latest | grep '"tag_name"' | cut -d'"' -f4)
curl -sLo /tmp/git-delta.deb "https://github.com/dandavison/delta/releases/download/${DELTA_VERSION}/git-delta_${DELTA_VERSION}_amd64.deb"
sudo dpkg -i /tmp/git-delta.deb
rm /tmp/git-delta.deb
git config --global core.pager /usr/bin/delta
Setup zsh
#!/bin/bash
# Clone the dotfiles repository
mkdir -p ~/dev/dotfiles
git clone [email protected]:Alex-D/dotfiles.git ~/dev/dotfiles
# WSL: Install Antibody and generate .zsh_plugins.zsh
curl -sfL git.io/antibody | sudo sh -s - -b /usr/local/bin
antibody bundle < ~/dev/dotfiles/zsh_plugins > ~/.zsh_plugins.zsh
# macOS: Install antidote and generate .zsh_plugins.zsh
brew install antidote
source /opt/homebrew/opt/antidote/share/antidote/antidote.zsh
antidote bundle < ~/dev/dotfiles/zsh_plugins > ~/.zsh_plugins.zsh
# Install Starship
# See: https://starship.rs/guide/#%F0%9F%9A%80-installation
# WSL
sudo apt install starship
# macOs
brew install starship
mkdir -p ~/.config
ln -sf ~/dev/dotfiles/starship.toml ~/.config/starship.toml
# macOs: remove the "last login" line
touch ~/.hushlogin
# Link custom dotfiles
ln -sf ~/dev/dotfiles/.ssh-config ~/.ssh/config
ln -sf ~/dev/dotfiles/.aliases.zsh ~/.aliases.zsh
ln -sf ~/dev/dotfiles/.zshrc ~/.zshrc
ln -sf ~/dev/dotfiles/.gitignore ~/.gitignore
# Link custom WSL config
sudo ln -sf ~/dev/dotfiles/wsl.conf /etc/wsl.conf
# Create .screen folder used by .zshrc
mkdir ~/.screen && chmod 700 ~/.screen
# Change default shell to zsh
chsh -s $(which zsh)
Setup GitHub CLI
#!/bin/zsh
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "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 > /dev/null
sudo apt update
sudo apt install gh
# macOS
brew install gh
Login gh command to GitHub via gh auth login
Docker
Setup Docker
#!/bin/zsh
# Add Docker to sources.list
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install tools
sudo apt update && sudo apt install -y \
docker-ce docker-ce-cli containerd.io
# Add user to docker group
sudo usermod -aG docker $USER
You can start Docker daemon via Systemd or via dcs alias.
Docker Compose
#!/bin/zsh
sudo 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 \")
sudo chmod +x /usr/local/bin/docker-compose
Vite+ (Node.js, pnpm, ...)
#!/bin/zsh
# Install Vite+
curl -fsSL https://vite.plus | bash
Go
WSL
#!/bin/zsh
goVersion=1.26.3
curl -L "https://golang.org/dl/go${goVersion}.linux-amd64.tar.gz" > /tmp/go${goVersion}.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf /tmp/go${goVersion}.linux-amd64.tar.gz
rm /tmp/go${goVersion}.linux-amd64.tar.gz
macOS
brew install go
Rust
macOS
brew install rustup
rustup-init
rustup completions bash > $(brew --prefix)/etc/bash_completion.d/rustup.bash-completion
IntelliJ IDEA
I use to launch IntelliJ IDEA from WSL 2 using XLaunch. JetBrains improved a lot on that, so now I can run IntelliJ from Windows and work in WSL 2.
Old Setup to run IntelliJ IDEA inside WSL
I run IntelliJ IDEA in WSL 2, and get its GUI on Windows via X Server (VcXsrv).
Setup VcXsrv
windowsUserProfile=/mnt/c/Users/$(cmd.exe /c "echo %USERNAME%" 2>/dev/null | tr -d '\r')
# Run VcXsrv at startup
cp ~/dev/dotfiles/config.xlaunch "${windowsUserProfile}/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup"
Install IntelliJ IDEA
#!/bin/zsh
# Install IDEA dependencies
sudo apt update && sudo apt install -y \
fontconfig \
libxss1 \
libnss3 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libgbm1 \
libpangocairo-1.0-0 \
libcups2 \
libxkbcommon0
# Create install folder
sudo mkdir /opt/idea
# Allow your user to run IDEA updates from GUI
sudo chown $UID:$UID /opt/idea
# Download IntelliJ IDEA
curl -L "https://download.jetbrains.com/product?code=IIU&latest&distribution=linux" | tar vxz -C /opt/idea --strip 1
Setup Windows Terminal
#!/bin/zsh
windowsUserProfile=/mnt/c/Users/$(cmd.exe /c "echo %USERNAME%" 2>/dev/null | tr -d '\r')
# Copy Windows Terminal settings
cp ~/dev/dotfiles/terminal-settings.json ${windowsUserProfile}/AppData/Local/Packages/Microsoft.WindowsTerminal_8wekyb3d8bbwe/LocalState/settings.json
WSL Bridge
When a port is listening from WSL 2, it cannot be reached.
You need to create port proxies for each port you want to use.
To 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.
#!/bin/zsh
windowsUserProfile=/mnt/c/Users/$(cmd.exe /c "echo %USERNAME%" 2>/dev/null | tr -d '\r')
# Get the hacky network bridge script
cp ~/dev/dotfiles/wsl2-bridge.ps1 ${windowsUserProfile}/wsl2-bridge.ps1
In order to allow wsl2-bridge.ps1 script to run, you need to update your PowerShell execution policy.
# In PowerShell as Administrator
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
PowerShell -File $env:USERPROFILE\\wsl2-bridge.ps1
Then, when port forwarding does not work between WSL 2 and Windows, run wslb from zsh:
#!/bin/zsh
wslb
Note: This is a custom alias. See .aliases.zsh for more details
Limit WSL 2 RAM consumption
#!/bin/zsh
windowsUserProfile=/mnt/c/Users/$(cmd.exe /c "echo %USERNAME%" 2>/dev/null | tr -d '\r')
cp ~/dev/dotfiles/.wslconfig ${windowsUserProfile}/.wslconfig
Note: You can adjust the RAM amount in .wslconfig file. Personally, I set it to 8 GB.
Install kubectl
#!/bin/zsh
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "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
sudo apt-get update
sudo apt-get install -y kubectl
Install AWS CLI
#!/bin/zsh
cd /tmp/aws-cli
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
cd -
rm -rf /tmp/aws-cli
Setup Git Filter Repo
#!/bin/zsh
git clone [email protected]:newren/git-filter-repo.git /tmp/git-filter-repo
cd /tmp/git-filter-repo
make snag_docs
sudo cp -a git-filter-repo $(git --exec-path)
sudo cp -a Documentation/man1/git-filter-repo.1 $(git --man-path)/man1
sudo cp -a Documentation/html/git-filter-repo.html $(git --html-path)
cd -
rm -rf /tmp/git-filter-repo
Explorer des projets similaires
Chargement…