Day 93 of #100DaysOfLearning
Shinya Yanagihara
Developer Productivity Specialist - Global Black Belt @ Microsoft
In order to make a clean break with the past, I did a clean install of Windows 11 and began to create a clean development environment from scratch.
Today we installed Windows Subsystem for Linux (WSL2) and then went as far as installing the Fish shell.
Here is what I did today.
1. Initial Setup
App Installer
If winget does not work, you should upgrade App Installer
Google Japanese IME
winget install Google.JapaneseIME
Keymap Configuration
WSL
WSL2 is a Windows Subsystem for Linux that allows access to Linux tools and applications directly from the Windows environment12. It offers the best of both worlds by allowing you to run Windows apps, like Visual Studio, alongside a Linux shell for easier command line access2. WSL2 uses a virtual machine, and uses a full Linux kernel built and shipped with Windows23. With WSL2, you can build docker images that paravirtualize your GPU4.
Prepare for installation
Run as Administrator PowerShell and enable the following features:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:HypervisorPlatform /all /norestart
And restart
Restart-Computer -Force
WSL Installation
wsl --install
Upgrade packages
sudo apt update && sudo apt upgrade
WSL Setup
Hostname
sudo vim /etc/wsl.conf
Add the followings:
[network]
hostname=wsl
Then you should shutdown WSL with PowerShell.
wsl --shutdown
Run your WSL again, now your configuration is enabled.
Other WSL Settings
SECTIONITEMSETTINGNOTEbootsystemdtrueEnable systemd supportnetworkhostname<YOUR_HOSTNAME>Hostname for your WSL InstanceinteropappendWindowsPathfalse / trueApped your Windows PATH or notuserdefault<YOUR_USERNAME>WSL Login Username
Terminal
Terminal settings:
Startup
Homebrew
Homebrew is an open-source software package manager that makes it easier to install software on macOS (Apple's operating system) and Linux. Basically, a package manager's job is to find and install the right software packages that will allow you to compile and run various apps/software on your specific operating system.
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/shinyay/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
sudo apt-get install build-essential
brew install gcc
brew doctor
Git
brew install git
git --version
git version 2.44.0
Git Global Configuration
git config --global user.name "shinyay" && \
git config --global user.email "<YOUR_MAILADDRESS>" && \
git config --global core.quotepath false && \
git config --global core.safecrlf true && \
git config --global core.autocrlf false && \
git config --global core.editor 'vim -c "set fenc=utf-8"' && \
git config --global color.diff auto && \
git config --global color.status auto && \
git config --global color.branch auto && \
git config --global fetch.prune true && \
git config pull.ff only
SSH Key for GitHub
Fine-grained personal access tokens
ssh-keygen
ssh-keygen -t ed25519 -C 'mail address for github'
cat $HOME/.ssh/id_ed25519.pub | clip.exe
SSH Keys on GitHub
VSCode
Visual Studio Code, often referred to as VSCode, is a free and open-source code editor optimized for building and debugging modern web and cloud applications. It supports various programming languages and comes with features like IntelliSense for smart completions based on variable types, function definitions, and imported modules, built-in Git commands, and debugging tools. It's highly customizable and extensible with various extensions. It's available on multiple platforms including Linux, macOS, and Windows.
winget search vscode
winget install Microsoft.VisualStudioCode
VSCode Extension
The Remote Development extension pack allows you to open any folder in a container, on a remote machine, or in the Windows Subsystem for Linux (WSL) and take advantage of VS Code's full feature set. Since this lets you set up a full-time development environment anywhere.
sudo apt-get install wget ca-certificates
The following extesions are also installed:
2. WSL Customization
WSL
Update and Upgrade packages.
sudo apt update && sudo apt upgrade
brew update && brew upgrade
领英推荐
Requred Packages Installation
Basic Packages
brew install zip unzip
Fontconfig
Fontconfig is a library designed to provide system-wide font configuration, customization and application access.
sudo apt-get install fontconfig
wslu
This is a collection of utilities for the Windows Subsystem for Linux (WSL), such as converting Linux paths to Windows paths or creating Linux application shortcuts on the Windows Desktop.
sudo apt-get install wslu
Commands list:
dpkg -L wslu | grep bin/
Git
Git Alias
List aliases:
git config --get-regexp ^alias\.
Alias for Alias list
git config --global alias.alias 'config --get-regexp ^alias\.'
git status
git config --global alias.st 'status --short
git log
git config --global alias.plog "log --pretty='format:%C(yellow)%h %C(green)%cd %C(reset)%s %C(red)%d %C(cyan)[%an]' --date=iso"
git config --global alias.glog "log --pretty='format:%C(yellow)%h %C(green)%cd %C(reset)%s %C(red)%d %C(cyan)[%an]' --date=format:'%c' --all --graph"
Commit Count
git config --global alias.count 'shortlog -e -s -n'
GitHub CLI
GitHub CLI, or gh, is a command-line interface to GitHub for use in your terminal or your scripts.
brew install gh
gh --version
gh version 2.46.0 (2024-03-20)
https://github.com/cli/cli/releases/tag/v2.46.0
GitHub Authentication
gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations on this host? SSH
? Upload your SSH public key to your GitHub account? $HOME/.ssh/id_ed25519.pub
? Title for your SSH key: GitHub CLI
? How would you like to authenticate GitHub CLI? Login with a web browser
Text editor program to use for authoring text
gh config set editor vim
Fish
Fish, or the "Friendly Interactive SHell", is a Unix shell designed with an emphasis on user-friendliness and interactive use. It was introduced in 2005 and has since gained a following due to its unique features, helpful defaults, and focus on a pleasant user experience.
Fish Install
brew install fish
Check the PATH for fish.
which fish
/home/linuxbrew/.linuxbrew/bin/fish
Write the PATH for fish to define the valid shell.
sudo sh -c "echo /home/linuxbrew/.linuxbrew/bin/fish >> /etc/shells"
Define fish as a Default Shell.
chsh -s /home/linuxbrew/.linuxbrew/bin/fish
Reboot WSL and check fish.
echo $SHELL
Define the PATH of brew on fish.
echo 'eval (/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >> $HOME/.config/fish/config.fish
Check brew doctor.
brew doctor
Fisher
Fisher is a plugin manager for the Fish shell. It lets you install, update, and remove plugins like a boss. You can take control of functions, completions, bindings, and snippets from the command line. Fisher's zero impact on shell startup keeps your shell zippy and responsive1. Fisher is 100% pure-Fish, making it easy to contribute or modify.
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher
fisher -v
fisher, version 4.4.4
Fish Theme - bobthefish
fisher install oh-my-fish/theme-bobthefish
bobthefish Configuration
vim $HOME/.config/fish/config.fish
set -g theme_display_git_master_branch yes
set -g theme_display_git yes
set -g theme_display_git_dirty yes
set -g theme_display_git_untracked yes
set -g theme_display_git_ahead_verbose yes
set -g theme_display_git_dirty_verbose yes
set -g theme_display_git_stashed_verbose yes
set -g theme_git_worktree_support no
set -g theme_use_abbreviated_branch_name no
set -g theme_display_vagrant no
set -g theme_display_docker_machine no
set -g theme_display_k8s_context no
set -g theme_display_hg no
set -g theme_display_virtualenv no
set -g theme_display_nix no
set -g theme_display_ruby no
set -g theme_display_nvm no
set -g theme_display_user ssh
set -g theme_display_hostname ssh
set -g theme_display_vi no
set -g theme_display_date yes
set -g theme_display_cmd_duration yes
set -g theme_title_display_process no
set -g theme_title_display_path yes
set -g theme_title_display_user no
set -g theme_title_use_abbreviated_path no
set -g theme_date_format "+%F %H:%M"
set -g theme_date_timezone Asia/Tokyo
set -g theme_avoid_ambiguous_glyphs yes
set -g theme_powerline_fonts yes
set -g theme_nerd_fonts no
set -g theme_show_exit_status yes
set -g theme_display_jobs_verbose yes
set -g default_user your_normal_user
set -g theme_color_scheme loght
set -g fish_prompt_pwd_dir_length 0
set -g theme_project_dir_length 1
set -g theme_newline_cursor yes
set -g theme_newline_prompt ''
Moralerspace font for bobthefish
mkdir download && cd download
curl -L -O https://github.com/yuru7/moralerspace/releases/download/v1.0.0/MoralerspaceHWJPDOC_v1.0.0.zip
curl -L -O https://github.com/yuru7/moralerspace/releases/download/v1.0.0/MoralerspaceHWNF_v1.0.0.zip
curl -L -O https://github.com/yuru7/moralerspace/releases/download/v1.0.0/MoralerspaceHW_v1.0.0.zip
curl -L -O https://github.com/yuru7/moralerspace/releases/download/v1.0.0/MoralerspaceJPDOC_v1.0.0.zip
curl -L -O https://github.com/yuru7/moralerspace/releases/download/v1.0.0/MoralerspaceNF_v1.0.0.zip
curl -L -O https://github.com/yuru7/moralerspace/releases/download/v1.0.0/Moralerspace_v1.0.0.zip
unzip MoralerspaceHWJPDOC_v1.0.0.zip
unzip MoralerspaceHWNF_v1.0.0.zip
unzip MoralerspaceHW_v1.0.0.zip
unzip MoralerspaceJPDOC_v1.0.0.zip
unzip MoralerspaceNF_v1.0.0.zip
unzip Moralerspace_v1.0.0.zip
sudo mkdir /usr/share/fonts/truetype/moralerspace
sudo cp MoralerspaceHWJPDOC_v1.0.0/*.ttf /usr/share/fonts/truetype/moralerspace/
sudo cp MoralerspaceHWNF_v1.0.0/*.ttf /usr/share/fonts/truetype/moralerspace/
sudo cp MoralerspaceHW_v1.0.0/*.ttf /usr/share/fonts/truetype/moralerspace/
sudo cp MoralerspaceJPDOC_v1.0.0/*.ttf /usr/share/fonts/truetype/moralerspace/
sudo cp MoralerspaceNF_v1.0.0/*.ttf /usr/share/fonts/truetype/moralerspace/
sudo cp Moralerspace_v1.0.0/*.ttf /usr/share/fonts/truetype/moralerspace/
sudo fc-cache -vf
fc-list | grep -i moralerspace
explorer.exe .
Then install *ttf.
Then delete downloaded fonts.
cd ..
rm -fr download
I used to install compilers and runtimes for various programming languages in the local environment of my PC, but this time I am planning to utilize Dev Containers to keep the local environment as clean as possible. This way, I can ensure the continuity and continuity of the development environment without any problems even if I move to a different PC in the future.
It will take some time to complete the environment at hand, but I hope to have it done by the end of this week.
But it is always fun to set up a new development environment, even if it is time consuming.