Skip to content

Instantly share code, notes, and snippets.

@haggen
Last active January 15, 2024 14:17
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save haggen/c6f98546ab1567b602e11467f32f9970 to your computer and use it in GitHub Desktop.
Save haggen/c6f98546ab1567b602e11467f32f9970 to your computer and use it in GitHub Desktop.
My Linux setup both on Ubuntu or WSL.
# starship prompt
# https://starship.rs/
eval "$(starship init zsh)"
# rtx runtime
# https://github.com/jdx/rtx
eval "$(rtx activate zsh)"
export PIPENV_VENV_IN_PROJECT=1
export VISUAL=vim
export EDITOR=vim
export PATH="$PATH:/mnt/c/Users/hagge/AppData/Local/Programs/Microsoft VS Code/bin:$HOME/Work/bin"
export CDPATH="$HOME/Work"
alias g=git
alias d=docker
alias c="docker compose"
alias clear="clear -x"
alias o=wslview
alias clip=/mnt/c/Windows/SysWOW64/clip.exe

My Linux setup

Works for Debian based distros, running both native and in WSL2.

  1. Run setup.sh with your user. Will require sudo.
  2. Install VSCode.
  3. Apply fixes and tweaks as required.

Fixes and tweaks

Cedilla (Linux)

Current US int. keyboard layout sets cedilla to AltGr+c but older versions used to have it as acute+c. This reverts this change:

echo "GTK_IM_MODULE=cedilla" | sudo tee -a /etc/environment

Docker iptables error on Ubuntu 22

Run:

sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy

See microsoft/WSL#6655.

#!/usr/bin/env sh
set -ue
# Update and install required software.
#
sudo bash -c 'apt update; apt upgrade -y'
sudo apt install git vim zsh build-essential curl rtx
# Change defaults.
#
sudo update-alternatives --set editor `which vim.basic`
# sudo sed -ei 's/(%sudo.+)ALL/\1NOPASSWD:ALL/' /etc/sudoers # UNTESTED!
# Install Docker.
#
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Setup vim.
# https://github.com/amix/vimrc
#
if ! test -d "$HOME/.vim_runtime"; then
git clone --depth=1 https://github.com/amix/vimrc.git "$HOME/.vim_runtime"
sh ~/.vim_runtime/install_basic_vimrc.sh
fi
# Setup tmux.
# https://github.com/gpakosz/.tmux
#
if ! test -d "$HOME/.tmux"; then
git clone https://github.com/gpakosz/.tmux.git "$HOME/.tmux"
ln -s -f "$HOME/.tmux/.tmux.conf" "$HOME/"
cp "$HOME/.tmux/.tmux.conf.local" "$HOME/"
fi
# Setup zsh and zprezto.
# https://github.com/sorin-ionescu/prezto
#
if ! test -d "$HOME/.zprezto"; then
which zsh || sudo apt-get install -y zsh
git clone --recursive https://github.com/sorin-ionescu/prezto.git "$HOME/.zprezto"
zsh -s <<-EOF
setopt EXTENDED_GLOB
for rcfile in $HOME/.zprezto/runcoms/^README.md(.N); do
ln -s \$rcfile $HOME/.\${rcfile:t}
done
EOF
sed -i "s/ 'prompt'/ 'syntax-highlighting' 'history-substring-search'/" "$HOME/.zpreztorc"
sed -i "s/\(zstyle ':prezto:module:prompt' theme\)/#\1/" "$HOME/.zpreztorc"
cat .zshrc >> ~/.zshrc
chsh -s "$(which zsh)" "$(id -un)"
fi
# Setup prompt.
# https://starship.rs/
#
if ! test -f "$HOME/.config/starship.toml"; then
curl -sS https://starship.rs/install.sh | sh
mkdir "$HOME/.config"
cp starship.toml "$HOME/.config/starship.toml"
fi
# Copy wsl.conf
#
sudo cp wsl.conf /etc/
"$schema" = 'https://starship.rs/config-schema.json'
command_timeout = 1000
[battery]
disabled = true
[character]
success_symbol = "[→](green bold)"
error_symbol = "[×](red bold)"
vimcmd_symbol = "[←](bold green)"
[git_commit]
tag_symbol = " tag "
[git_status]
deleted = "×"
[aws]
symbol = "aws "
[azure]
symbol = "az "
[bun]
symbol = "bun "
[c]
symbol = "c "
[cobol]
symbol = "cobol "
[conda]
symbol = "conda "
[crystal]
symbol = "cr "
[cmake]
symbol = "cmake "
[daml]
symbol = "daml "
[dart]
symbol = "dart "
[deno]
symbol = "deno "
[dotnet]
symbol = ".net "
[directory]
read_only = " ro"
[docker_context]
symbol = "docker "
[elixir]
symbol = "exs "
[elm]
symbol = "elm "
[fennel]
symbol = "fnl "
[fossil_branch]
symbol = "fossil "
[gcloud]
symbol = "gcp "
[git_branch]
symbol = "git "
[golang]
symbol = "go "
[gradle]
symbol = "gradle "
[guix_shell]
symbol = "guix "
[hg_branch]
symbol = "hg "
[java]
symbol = "java "
[julia]
symbol = "jl "
[kotlin]
symbol = "kt "
[lua]
symbol = "lua "
[nodejs]
symbol = "nodejs "
[memory_usage]
symbol = "memory "
[meson]
symbol = "meson "
[nim]
symbol = "nim "
[nix_shell]
symbol = "nix "
[ocaml]
symbol = "ml "
[opa]
symbol = "opa "
[os.symbols]
Alpaquita = "alq "
Alpine = "alp "
Amazon = "amz "
Android = "andr "
Arch = "rch "
Artix = "atx "
CentOS = "cent "
Debian = "deb "
DragonFly = "dfbsd "
Emscripten = "emsc "
EndeavourOS = "ndev "
Fedora = "fed "
FreeBSD = "fbsd "
Garuda = "garu "
Gentoo = "gent "
HardenedBSD = "hbsd "
Illumos = "lum "
Linux = "lnx "
Mabox = "mbox "
Macos = "mac "
Manjaro = "mjo "
Mariner = "mrn "
MidnightBSD = "mid "
Mint = "mint "
NetBSD = "nbsd "
NixOS = "nix "
OpenBSD = "obsd "
OpenCloudOS = "ocos "
openEuler = "oeul "
openSUSE = "osuse "
OracleLinux = "orac "
Pop = "pop "
Raspbian = "rasp "
Redhat = "rhl "
RedHatEnterprise = "rhel "
Redox = "redox "
Solus = "sol "
SUSE = "suse "
Ubuntu = "ubnt "
Unknown = "unk "
Windows = "win "
[package]
symbol = "pkg "
[perl]
symbol = "pl "
[php]
symbol = "php "
[pijul_channel]
symbol = "pijul "
[pulumi]
symbol = "pulumi "
[purescript]
symbol = "purs "
[python]
symbol = "py "
[raku]
symbol = "raku "
[ruby]
symbol = "rb "
[rust]
symbol = "rs "
[scala]
symbol = "scala "
[spack]
symbol = "spack "
[solidity]
symbol = "solidity "
[status]
symbol = "[x](bold red) "
[sudo]
symbol = "sudo "
[swift]
symbol = "swift "
[terraform]
symbol = "terraform "
[zig]
symbol = "zig "
[interop]
appendWindowsPath=false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment