Skip to content

Instantly share code, notes, and snippets.

@marcelocg
Last active June 3, 2019 22:14
Show Gist options
  • Select an option

  • Save marcelocg/1d2ce554776e409b22b891489ea86622 to your computer and use it in GitHub Desktop.

Select an option

Save marcelocg/1d2ce554776e409b22b891489ea86622 to your computer and use it in GitHub Desktop.

Configure a Recently Installed Linux

System Proxy Configuration

$ sudo nano /etc/profile
# Add username:password@ befor the IP address if you need authentication, e.g if using NTLM proxy
export http_proxy=http://192.168.146.1:3128 
export https_proxy=http://192.168.146.1:3128
# This is the default IP for a VMWare host that is running CNTLM on port 3128
# Use IP 192.168.56.1 if using Oracle VirtualBox

Proxy for Apt

$ sudo nano /etc/apt/apt.conf
Acquire::http::Proxy "http://192.168.146.1:3128";
Acquire::https::Proxy "http://192.168.146.1:3128";

Proxy for Git

$ git config --global http.proxy http://192.168.146.1:3128
$ git config --global https.proxy http://192.168.146.1:3128

VirtualBox Shared Folder Permission

If you are using Oracle VirtualBox with shared host folders, you need to give your guest Linux user the necessary permissions to read/write to those folders.

$ sudo adduser $USER vboxsf

Install PostgreSQL

First, import the repository key:

$ curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Then configure apt to use the correct packages for your distribution:

$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
$ sudo apt update

Ok, ready to install everything PostgreSQL:

$ sudo apt install postgresql postgresql-contrib postgresql-client pgadmin4

Further information on post install configuration can be found here

Configure Terminal for Development

* `NeoVim` as a better alternative to Vim
* `tmux` for better terminal organization and multiplexing
* `zsh` for better shell interaction
* SilverSearcher (aka `ag`) for faster file searching.
* Fonts required by zsh spaceship prompt

First we install all the tools, next we will configure each one.

Install tools

$ sudo apt install neovim tmux zsh silversearcher-ag fonts-powerline

Configure nvim plugins

Install plug-vim plugin manager:

$ curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Configure plugin installation:

$ nvim ~/.config/nvim/init.vim
" Specify a directory for plugins
call plug#begin('~/.local/share/nvim/plugged')

" Install neomake
Plug 'neomake/neomake'

" Install and configure NERDTree
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
" NERDTree on ctrl+n
let NERDTreeShowHidden=1
map <silent> <C-n> :NERDTreeToggle<CR>
" close NERDTree after a file is opened
let g:NERDTreeQuitOnOpen=1

" Install and configure FZF for fuzzy finding
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
" make FZF respect gitignore if `ag` is installed
" you will obviously need to install `ag` for this to work
if (executable('ag'))
    let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
endif
nnoremap <C-P> :Files<CR>

" Install and configure ale for linting
Plug 'w0rp/ale'
" fix files on save
let g:ale_fix_on_save = 1
" lint after 1000ms after changes are made both on insert mode and normal mode
let g:ale_lint_on_text_changed = 'always'
let g:ale_lint_delay = 1000
" use nice symbols for errors and warnings
let g:ale_sign_error = '✗\ '
let g:ale_sign_warning = '⚠\ '
" fixer configurations
let g:ale_fixers = {
\   '*': ['remove_trailing_lines', 'trim_whitespace'],
\}

" Install and configure emmet-vim
Plug 'mattn/emmet-vim'
" make emmet behave well with JSX in JS and TS files
let g:user_emmet_settings = {
\  'javascript' : {
\      'extends' : 'jsx',
\  },
\  'typescript' : {
\      'extends' : 'tsx',
\  },
\}

" Install and configure YouCompleteMe for semantic-based completion
" You need Java8, Rust, Cargo (Rust packages), Go, TSServer, Node and NPM installed and in your PATH
" I'll let these lines commented out so we can install on demand
"Plug 'Valloric/YouCompleteMe', { 'do': './install.py --java-completer --ts-completer --go-completer --rust-completer' }
" disable auto_triggering ycm suggestions pane and instead
" use semantic completion only on Ctrl+n
"let ycm_trigger_key = '<C-n>'
"let g:ycm_auto_trigger = 0
"let g:ycm_key_invoke_completion = ycm_trigger_key
" this is some arcane magic to allow cycling through the YCM options
" with the same key that opened it.
" See http://vim.wikia.com/wiki/Improve_completion_popup_menu for more info.
"let g:ycm_key_list_select_completion = ['<TAB>', '<C-j>']
"inoremap <expr> ycm_trigger_key pumvisible() ? '"<C-j>'" : ycm_trigger_key;

Configure TMux

Install tpm, TMux Plugin Manager:

$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

Edit ~/.tmux.conf:

$ nvim ~/.tmux.conf

# Free the original `Ctrl-b` prefix keybinding.
unbind C-b

# set prefix key to ctrl-a
set -g prefix C-a

# vi keys for switching panes
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R

# shift-movement keys will resize panes
bind J resize-pane -D 5
bind K resize-pane -U 5
bind H resize-pane -L 5
bind L resize-pane -R 5

# Splitting panes.
bind - split-window -v
bind | split-window -h

# Start tabs at index 1
# (they usually start at 0, which is too far from where my fingers usually are)
set -g base-index 1

# Make pane numbering consistent with windows
setw -g pane-base-index 1

# Renumber windows when a window is closed
# This guarantees it will be easier for you to switch
# between windows as you keep opening and closing them
set -g renumber-windows on

# Automatically set window title according to the running program
set-window-option -g automatic-rename on
set-option -g set-titles on

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)run 
run -b '~/.tmux/plugins/tpm/tpm'

Reload TMux environment so TPM is sourced:

$ tmux source ~/.tmux.conf

Configure ZSH

First, set ZSH as your default login shell:

$ chsh -s $(which zsh)

Then install oh-my-zsh:

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

Install spaceship-prompt plugin:

$ git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt"

Symlink spaceship.zsh-theme to your oh-my-zsh custom themes directory:

$ ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"

Install these two nice plugins for better completion suggestions:

git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

Now, edit ~/.zshrc uncommenting or adding these lines:

ZSH_TMUX_AUTOSTART="true" # This one should be added to the top of the file

# Themes section
ZSH_THEME="spaceship" # Use the speceship-prompt

HIST_STAMPS="yyyy-mm-dd"

plugins=(
  z
  git
  chucknorris
  tmux
  zsh-autosuggestions
  zsh-syntax-highlighting
)

source $ZSH/oh-my-zsh.sh

export EDITOR='mvim'

# Load aliases
if [ -f ~/.aliases ]; then
    . ~/.aliases
fi

Configure for Python Development

Install pip3:

$ sudo apt install python3-pip

Then install pipenv:

$ pip install pipenv

Install Java

$ sudo apt install openjdk-11-jdk

Then, edit /etc/environment and add the JAVA_HOME variable as following:

JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

Check to see if there is a line like the following in your ~/.bashrc. If not, add it:

source /etc/environment

Install Maven

In a directory of your preference, download and extract the Maven binaries tarball:

$ wget http://mirror.nbtelecom.com.br/apache/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz
$ tar zxvf apache-maven-3.6.0-bin.tar.gz

In ~/.bashrc, add the bin directory from Maven installation to the PATH:

PATH="~/apache-maven-3.6.0/bin:$PATH"

You can then test your Maven installation:

$ cd ~
$ source .bashrc
$ mvn -v
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T15:41:47-03:00)
Maven home: /home/marcelo/Programs/maven-3.6.0
Java version: 11.0.1, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-13-generic", arch: "amd64", family: "unix"

Install Node LTS

Install the LTS version of Node, whatever it may be at the time you are doing your installation. Then, use a version manager to install required versions for your specific projects.

Node 10 (will be the only LTS until October 2019)

$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - && sudo apt install -y nodejs

Node 12 (will be the newest LTS from October 2019)

$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - && sudo apt install -y nodejs

Make sure sudo is not required

$ mkdir ~/.npm-global
$ npm config set prefix '~/.npm-global'

And in you .zshrc:

export PATH=~/.npm-global/bin:$PATH

Install a Node version manager

$ npm i -g n
$ echo export N_PREFIX=\"$HOME/.npm-global\" >> ~/.zshrc

Install Elixir and Erlang

$ wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb
$ sudo apt update && sudo apt install esl-erlang
$ sudo apt install elixir

Install and configure Docker

Follow this Gist.

Install Visual Studio Code

Follow instructions here.

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