Skip to content

Instantly share code, notes, and snippets.

@pvguerra
Last active December 4, 2022 23:09
Show Gist options
  • Save pvguerra/427f04db2ba0fc21eba108f71ae4dee9 to your computer and use it in GitHub Desktop.
Save pvguerra/427f04db2ba0fc21eba108f71ae4dee9 to your computer and use it in GitHub Desktop.
Ubuntu 20.04 for Devs

ubuntu-dev

A readme with some steps needed to configure a clean Ubuntu 20.04 environment for development:

Update & Upgrade

sudo apt update && sudo apt upgrade

Git

sudo apt install git-all

Git Flow (optional)

Git Flow

git-flow are a set of git extensions to provide high-level repository operations for Vincent Driessen's branching model.

sudo apt-get install git-flow

Terminal Enhancements (optional, but recommended)

ZSH & Oh My ZSH! 💻

ZSH is a highly customizable shell.

sudo apt install zsh

Oh-My-ZSH is an open source, community-driven framework for managing your ZSH configuration.

curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh; zsh

**If it don’t show you the message “Shell changed.” just before the Oh My ZSH logo, maybe the script wasn’t able to change your default shell. In that case, you can manually change it using:

sudo usermod --shell $(which zsh) <your_username>

If you just open another terminal tab it will still using your older shell, but the next time you login in your system it will be ZSH already.

Zsh Syntax Highlighting basically it make the command green if typed right, red if doesn’t, and underline existent folders/files.

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

ZSH Auto Suggestions

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Now add zsh-syntax-highlighting and zsh-autosuggestions in your plugins list. To enable a plugin, you just need to open the file ~/.zshrc add it in the plugins=(...) line.

plugins=( git apt zsh-syntax-highlighting zsh-autosuggestions )

FZF Fuzzy Finder.

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && ~/.fzf/install

Answer “y” to all questions. Now you can use Ctrl+T to search for files, like in your editor!

Or you can now search for commands in your history too using Ctrl+R!

Fonts

Nerd Fonts

An “iconic font aggregator”, will some of the most popular monospaced fonts patched to support icons! Go to the Downloads section in their site and pick your favorite. Try Fonts. Now extract it and move the files into yours fonts folder (something like ~/.fonts or ~/.local/share/fonts):

mkdir ~/.fonts && cd ~/.fonts unzip ~/Downloads/<the_chosen_font>.zip

And now changed to it in your terminal (something like Preferences->Appearance->Font).

Powerlevel10k

Powerlevel10k. A theme that supports icons and A LOT of customization, besides saving you some repetitive commands like git status because it show will some info about your project/system already

NVM

Install NodeJS with NVM

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

source ~/.bashrc

Add in your ~/.zshrc the following:

export NVM_DIR=~/.nvm [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

source ~/.zshrc

nvm list-remote

nvm install v14

node -v

PHP 🐘

sudo add-apt-repository -y ppa:ondrej/php sudo apt update sudo apt install php7.4 or (5.6, 7.1, ...)

Switch from PHP 7.x to PHP 5.x

sudo a2dismod php7.2

To activate the new configuration, you need to run:

systemctl restart apache2

sudo a2enmod php5.6

Set PHP 7.4 as default version

sudo update-alternatives --set php /usr/bin/php7.4

Alternatively, you can run the following command to set which system wide version of PHP you want to use by default.

sudo update-alternatives --config php

Composer 🎶

📓 Documentation

curl -sS https://getcomposer.org/installer -o composer-setup.php

Install Composer

Laravel 8

📓 Documentation

$ composer global require "laravel/installer"

sudo apt install php-mbstring php-xml php-pgsql php-curl

If Zsh: export PATH="$HOME/.composer/vendor/bin:$PATH"

laravel new project_name

PostgreSQL 13.1 🐘

📓 Documentation

sudo apt install postgresql postgresql-contrib

After installation don't forget to execute:

service postgresql start

To check status:

service postgresql status

To stop:

service postgresql stop

Access via terminal:

sudo -u postgres psql

Mysql 8

sudo apt install mysql-server

For fresh installations of MySQL, you’ll want to run the DBMS’s included security script. This script changes some of the less secure default options for things like remote root logins and sample users.

sudo mysql_secure_installation

SSH

Aliases ZSH

# Bash
alias zsho="nano ~/.zshrc"
alias zshr="source ~/.zshrc"
alias dev="cd /home/pauloguerra/Development"

# Git
alias gb="git branch"
alias gs="git status"
alias go="git checkout"
alias ga="git add -A"
alias gc="git commit"
alias gp="git push origin"
alias gu="git pull origin"
alias gm="git merge"
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

# Git Flow
alias gffs="git flow feature start"
alias gfff="git flow feature finish"
alias gfrs="git flow release start"
alias gfrf="git flow release finish"

# PHP
alias phpconfig="sudo update-alternatives --config php"

# Laravel
alias pa="php artisan"
alias pas="php artisan serve"
alias tinker="php artisan tinker"
alias pam="php artisan migrate"
alias pamfs="php artisan migrate:fresh --seed"
alias pamm="php artisan make:model"

# Composer
alias cda="composer dump-autoload"
alias cu="composer update"

# Django
alias pym="python manage.py"
alias pymr="python manage.py runserver"
alias pymmm="python manage.py makemigrations"
alias pymmgt="python manage.py migrate"
alias pymcsu="python manage.py createsuperuser"

# Services
alias pgsql-start="sudo service postgresql start"
alias redis-start="sudo service redis-server start"
alias mysql-start="sudo service mysql start"
alias wsl-up="~/Development/Scripts/wsl-services.sh start"
alias wsl-down="~/Development/Scripts/wsl-services.sh stop"
alias wsl-restart="~/Development/Scripts/wsl-services.sh restart"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment