Skip to content

Instantly share code, notes, and snippets.

@ivawzh
Last active April 17, 2023 06:02
Show Gist options
  • Save ivawzh/57b012e5495c58028bb544bd8b3d894f to your computer and use it in GitHub Desktop.
Save ivawzh/57b012e5495c58028bb544bd8b3d894f to your computer and use it in GitHub Desktop.
Windows sub-system bash setup

New way

  1. Install "Windows terminal" from Microsoft store
  2. install WSL: wsl --install https://learn.microsoft.com/en-us/windows/wsl/install#update-to-wsl-2
  3. Change default tab to Ubuntu: Settings -> Startup -> Default Profile -> Ubuntu
  4. Install Code by running in terminal: $ code
  5. set up github access: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent?platform=linux
  6. Install Homebrew https://linux.how2shout.com/install-brew-on-wsl-windows-subsystem-for-linux/. And make sure follow the Next steps instruction.
  7. Install zsh: $ brew install zsh. Start zsh on every terminal session start: sed -i '$a\\n# Start oh-my-zsh\nif test -t1; then\n exec zsh\nfi' .profile
  8. Install ohmyzsh $ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  9. Configure ohmyzsh https://blog.joaograssi.com/windows-subsystem-for-linux-with-oh-my-zsh-conemu/#configuring-zshoh-my-zsh
  10. Install nvm: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash. And then follow instructions.
  11. Install yarn2: corepack enable https://yarnpkg.com/getting-started/install

Old way

  1. Install WSL
  2. Set to use WSL2
  3. Download ubuntu via Windows Store
  4. Open ubuntu and setup a non-root account
  5. Set default distro to the newly installed ubuntu
  6. Go to ubuntu, and follow guide from https://gist.github.com/coltenkrauter/608cfe02319ce60facd76373249b8ca6
  7. edit /etc/resolv.conf to have nameserver 8.8.8.8 instead of the existing nameserver 172.24.0.1
  8. edit /etc/wsl.conf to have [network] generateResolvConf = false
  9. Run
    git config --global --unset http.proxy
    git config --global --unset https.proxy
    

ConEmu task

* task parameter: -icon "%USERPROFILE%\AppData\Local\lxss\bash.ico"
* command: %windir%\system32\bash.exe -cur_console:p
sudo apt-get update
sudo apt-get install build-essential curl git python-setuptools ruby

install linux brew

PATH="$HOME/.linuxbrew/bin:$PATH" ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)"

vi ~/.bashrc

# Linux-brew

export PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"

install oh-my-zsh

sudo apt-get install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

vi ~/.bashrc
#  start oh-my-zsh
zsh

vi ~/.zshrc
# start from code_bases folder
cd ~/code_bases

install node

brew install nvm
mkdir ~/.nvm

Add the following to ~/.bash_profile or your desired shell
configuration file:

export NVM_DIR="$HOME/.nvm"
. "/home/ivawzh/.linuxbrew/opt/nvm/nvm.sh"

nvm install v4.3.2

install yarn package manager

sudo apt-key adv --keyserver pgp.mit.edu --recv D101F7899D41F3C3
echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt-get update && sudo apt-get install yarn

Add export PATH="$PATH:$HOME/.yarn/bin" to your profile (this may be in your .profile, .bashrc, .zshrc, etc.)

Chruby

brew install chruby

vi ~/.zshrc

plugins=(git, aws, chruby, ruby, rake, node)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment