Skip to content

Instantly share code, notes, and snippets.

@CumpsD
Last active March 10, 2019 02:59
Show Gist options
  • Save CumpsD/c5aa35caf62276eb83f093edad06b3a0 to your computer and use it in GitHub Desktop.
Save CumpsD/c5aa35caf62276eb83f093edad06b3a0 to your computer and use it in GitHub Desktop.
Bash on Ubuntu on Windows setup

Bash on Windows config

example prompt

Powerline Fonts

git clone https://github.com/powerline/fonts.git  
cd fonts  
./install.sh
# Using Powershell ISE run: C:\Users\<username>\AppData\Local\lxss\home\<ubuntu username>\fonts\install.ps1
# On newer systems this could also be at C:\Users\<username>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState
cd ..
rm -rf fonts/
# Set properties of Console window, opacity 90%, select a "for powerline" font

General Tools

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get -y autoremove && sudo apt-get -y autoclean && sudo apt-get install -y htop build-essential git unzip gnupg2 graphviz

Preserve sudo path

sudo visudo
# Comment env_reset and secure_path

Bash-it

git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it
~/.bash_it/install.sh
nano .bashrc
# export BASH_IT_THEME='powerline'
source .bashrc
bash-it show completions
bash-it enable completion awscli docker docker-compose gh git packer terraform vagrant vault

Packer

wget https://releases.hashicorp.com/packer/1.2.1/packer_1.2.1_linux_amd64.zip
sudo unzip packer_1.2.1_linux_amd64.zip -d /usr/local/packer/
rm packer_1.2.1_linux_amd64.zip
echo "export PATH=\$PATH:/usr/local/packer" | sudo tee --append /etc/profile > /dev/null
source /etc/profile
packer version

Terraform

wget https://releases.hashicorp.com/terraform/0.11.7/terraform_0.11.7_linux_amd64.zip
sudo unzip terraform_0.11.7_linux_amd64.zip -d /usr/local/terraform/
rm terraform_0.11.7_linux_amd64.zip
echo "export PATH=\$PATH:/usr/local/terraform" | sudo tee --append /etc/profile > /dev/null
source /etc/profile
terraform version

Nomad

wget https://releases.hashicorp.com/nomad/0.7.1/nomad_0.7.1_linux_amd64.zip
sudo unzip nomad_0.7.1_linux_amd64.zip -d /usr/local/nomad/
rm nomad_0.7.1_linux_amd64.zip
echo "export PATH=\$PATH:/usr/local/nomad" | sudo tee --append /etc/profile > /dev/null
source /etc/profile
nomad version

Go

wget https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz
rm go1.9.2.linux-amd64.tar.gz
echo "export PATH=\$PATH:/usr/local/go/bin" | sudo tee --append /etc/profile > /dev/null
source /etc/profile
go version

.NET Core

sudo apt-get install libunwind8
wget https://download.microsoft.com/download/2/E/C/2EC018A0-A0FC-40A2-849D-AA692F68349E/dotnet-sdk-2.1.105-linux-x64.tar.gz
sudo mkdir /usr/local/dotnet
sudo tar -C /usr/local/dotnet -xzf dotnet-sdk-2.1.105-linux-x64.tar.gz
rm dotnet-sdk-2.1.105-linux-x64.tar.gz
echo "export PATH=\$PATH:/usr/local/dotnet" | sudo tee --append /etc/profile > /dev/null
source /etc/profile
sudo dotnet --version

.NET Core Completions

nano ~/.bash_it/completion/custom.completion.bash
#!/bin/bash
# bash parameter completion for the dotnet CLI

_dotnet_bash_complete()
{
  local word=${COMP_WORDS[COMP_CWORD]}
  local dotnetPath=${COMP_WORDS[1]}

  local completions=("$(dotnet complete --position ${COMP_POINT} "${COMP_LINE}")")

  COMPREPLY=( $(compgen -W "$completions" -- "$word") )
}

complete -f -F _dotnet_bash_complete dotnet

AWS CLI

sudo apt-get install python-pip 
pip install --upgrade pip
pip install --upgrade --user awscli 
aws --version
aws configure --profile <profilename>

FPM & Deb-S3

nano ~/.bash_it/lib/custom.bash
if which ruby >/dev/null && which gem >/dev/null; then
    PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH"
fi
sudo apt-get install ruby-dev
gem install --user-install fpm
gem install --user-install deb-s3
ruby --version
fpm --version

Node

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs build-essential

Ansible

sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible
@koenmetsu
Copy link

After aws cli install, add ~/.local/bin to PATH

@VanHuychemG
Copy link

If installing ansible fails with the following error:

$ sudo apt-add-repository ppa:ansible/ansible
Ansible is a radically simple IT ....

http://ansible.com/
More info: https://launchpad.net/~ansible/+archive/ubuntu/ansible
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keybox '/tmp/tmpie82hu2o/pubring.gpg' created
gpg: connecting dirmngr at '/home/geert/.gnupg/S.dirmngr' failed: IPC connect call failed
gpg: keyserver receive failed: No dirmngr
Failed to add key.

Add the following line to /etc/apt/sources.list:
deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main

Then run these commands:

$ sudo curl -sL "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x93C4A3FD7BB9C367" | sudo apt-key add
$ sudo apt-get update
$ sudo apt-get install ansible

@VanHuychemG
Copy link

VanHuychemG commented Jul 13, 2018

Possible error ImportError: cannot import name 'main' when running pip install --upgrade --user awscli

The bug is found in pip 10.0.0.
In linux you need to modify file: /usr/bin/pip from:

from pip import main
if __name__ == '__main__':
    sys.exit(main())

to this:

from pip import __main__
if __name__ == '__main__':
    sys.exit(__main__._main())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment