All Projects → Alex-D → Dotfiles

Alex-D / Dotfiles

Windows + WSL 2 Ubuntu + Windows Terminal + zsh + p10k + Docker + IntelliJ IDEA

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Dotfiles

Dotfiles Win
🙈 oh-my-zsh on bash on windows configuration files
Stars: ✭ 167 (+209.26%)
Mutual labels:  zsh, hyper, wsl, dotfiles
Castle Winbuntu
Homesick Castle for use on WSL.
Stars: ✭ 87 (+61.11%)
Mutual labels:  zsh, wsl, dotfiles
dotfiles
Dotfiles & Developer Environment. Supports Ubuntu2004+, macOS Catalina+, Windows 10 w WSL
Stars: ✭ 30 (-44.44%)
Mutual labels:  dotfiles, zsh, wsl
Cfgs
My personal configs
Stars: ✭ 14 (-74.07%)
Mutual labels:  zsh, dotfiles
Dockerized lara
Build your Laravel App with Redis - Mongodb - MariaDB - Nginx - php7 - zsh
Stars: ✭ 9 (-83.33%)
Mutual labels:  zsh, docker-compose
Dotfiles
My dotfiles, mainly Ubuntu and OSX stuff
Stars: ✭ 12 (-77.78%)
Mutual labels:  zsh, dotfiles
Wsl Docker Git Setup
Shell script to configure Windows Subsystem for Linux (WSL) & Ubuntu on Windows to use docker and docker-compose as well as a git-enabled prompt
Stars: ✭ 23 (-57.41%)
Mutual labels:  wsl, docker-compose
Dotfiles
my hidden config files
Stars: ✭ 27 (-50%)
Mutual labels:  zsh, dotfiles
Dotfiles
`~/dotfiles` to setup my dev env on macOS based around `neovim` and `tmux`
Stars: ✭ 20 (-62.96%)
Mutual labels:  zsh, dotfiles
Dotfiles
📦 My Configs and Dotfiles
Stars: ✭ 31 (-42.59%)
Mutual labels:  zsh, dotfiles
Dotfiles
Colourful & robust configuration files and utilities for Mac, Linux and BSD
Stars: ✭ 1,006 (+1762.96%)
Mutual labels:  zsh, dotfiles
Dotfiles
🔘 neovim, zsh, tmux, iTerm2, macOS dotfiles
Stars: ✭ 7 (-87.04%)
Mutual labels:  zsh, dotfiles
Dotfiles
My dotfiles 💻 🔨
Stars: ✭ 25 (-53.7%)
Mutual labels:  zsh, dotfiles
Dotfiles
🌸 Aesthetic OpenboxWM Environment (Completed Setup)
Stars: ✭ 873 (+1516.67%)
Mutual labels:  zsh, dotfiles
Dotfiles
My personal dotfiles
Stars: ✭ 24 (-55.56%)
Mutual labels:  zsh, dotfiles
Dotconfig
Development environment setup
Stars: ✭ 27 (-50%)
Mutual labels:  zsh, dotfiles
Dotfiles
Configs 🤘🤘🤘
Stars: ✭ 39 (-27.78%)
Mutual labels:  zsh, dotfiles
Dotfiles
This is my dotfiles.
Stars: ✭ 41 (-24.07%)
Mutual labels:  zsh, dotfiles
Dotfiles
dotfiles for my macOS & Linux environments ⌨️
Stars: ✭ 46 (-14.81%)
Mutual labels:  zsh, dotfiles
Dotfiles
My dotfiles
Stars: ✭ 19 (-64.81%)
Mutual labels:  zsh, dotfiles

My Windows 10 Setup & Dotfiles

Goals of this setup

  • Working on Windows 10
  • 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)
    • Docker Desktop
  • Terminal: Windows Terminal
  • Shell: zsh
    • git
    • docker (works with Docker Desktop)
    • docker-compose (works with Docker Desktop)
  • Node.js (using Volta)
    • node
    • npm
    • yarn
  • IDE: IntelliJ IDEA, under WSL 2, used on Windows via VcXsrv
  • WSL Bridge: allow exposing WSL 2 ports on the network

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

#!/bin/bash

sudo apt update && sudo apt install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common \
    git \
    make \
    tig \
    tree \
    zsh

GPG key

If you already have a GPG key, restore it. If you did not have one, you can create one.

Restore

  • On old system, create a backup of a GPG key
    • gpg --list-secret-keys
    • gpg --export-secret-keys {{KEY_ID}} > /tmp/private.key
  • On new system, import the key:
    • gpg --import /tmp/private.key
  • Delete the /tmp/private.key on 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 zsh

#!/bin/zsh

# Clone the dotfiles repository
mkdir -p ~/dev/dotfiles
git clone [email protected]:Alex-D/dotfiles.git ~/dev/dotfiles

# 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

# Link custom dotfiles
ln -sf ~/dev/dotfiles/.aliases.zsh ~/.aliases.zsh
ln -sf ~/dev/dotfiles/.p10k.zsh ~/.p10k.zsh
ln -sf ~/dev/dotfiles/.zshrc ~/.zshrc
ln -sf ~/dev/dotfiles/.gitignore ~/.gitignore

# Create .screen folder used by .zshrc
mkdir ~/.screen && chmod 700 ~/.screen

# Change default shell to zsh
chsh -s $(which zsh)

Docker

Install Docker Desktop

  • Install Docker Desktop
  • Make sure that the "Use the WSL 2 based engine" option is checked in Docker Desktop settings

Setup Docker CLI

#!/bin/zsh

# Add Docker to sources.list
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
versionCodename=$(cat /etc/os-release | grep VERSION_CODENAME | cut -d= -f2)
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(versionCodename) stable"

# Install tools
sudo apt update && sudo apt install -y \
    docker-ce

# Add user to docker group
sudo usermod -aG docker $USER

Node.js

#!/bin/zsh

# Install Volta
mkdir -p $VOLTA_HOME
curl https://get.volta.sh | bash -s -- --skip-setup

# Install node and package managers
volta install node npm yarn

IntelliJ IDEA

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

# 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')

# Avoid too much RAM consumption
cp ~/dev/dotfiles/.wslconfig ${windowsUserProfile}/.wslconfig

Note: You can adjust the RAM amount in .wslconfig file. Personally, I set it to 8 GB.

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
cp -a git-filter-repo $(git --exec-path)
cp -a Documentation/man1/git-filter-repo.1 $(git --man-path)/man1
cp -a Documentation/html/git-filter-repo.html $(git --html-path)
cd -
rm -rf /tmp/git-filter-repo

Setup GitBash

git config --global core.sshCommand "ssh -i \\\\\\\\wsl$\\\\Ubuntu\\\\home\\\\ademode\\\\.ssh\\\\id_rsa"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].