Skip to content

Instantly share code, notes, and snippets.

@aralshawa
Last active December 6, 2024 03:05
Show Gist options
  • Save aralshawa/b616cf2a8bb7c1848e698edf35a1562f to your computer and use it in GitHub Desktop.
Save aralshawa/b616cf2a8bb7c1848e698edf35a1562f to your computer and use it in GitHub Desktop.
A set of reminders for when I set up a new computer for personal development use.

Setup

.zshrc Shell Configuration - Main Workstation

# Zsh 
export ZSH=/Users/abdul/.oh-my-zsh
# https://github.com/agnoster/agnoster-zsh-theme
ZSH_THEME="agnoster"
plugins=(git osx xcode zsh-autosuggestions)
source $ZSH/oh-my-zsh.sh

# User
DEFAULT_USER=abdul

export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/sbin:$PATH

# iTerm Shell Extensions
source ~/.iterm2_shell_integration.zsh

# Ruby
source /usr/local/opt/chruby/share/chruby/chruby.sh

# Python
alias ipython='python -m IPython'
alias ipython3='python3 -m IPython'
export PATH=$PATH:$HOME/Library/Python/2.7/bin

# NVM
export NVM_DIR="$HOME/.nvm"
alias initnvm='[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"'

# Go
export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin

# Utilities
alias lsc='ls | wc -l'
alias tarbz='tar -vxjf'
alias sizes='du -sch * | sort -h'
alias pg_start='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'
alias pg_stop='pg_ctl -D /usr/local/var/postgres stop -s -m fast'
alias cleanup_local_branches='git branch --merged > /tmp/cleanup && vim /tmp/cleanup && xargs git branch -d </tmp/cleanup && rm /tmp/cleanup'
alias sublime="open -a /Applications/Sublime\ Text.app"
alias system_info="system_profiler SPHardwareDataType SPSoftwareDataType"

function csv_col(){
  head -1 $1 | tr , \\n | sort | uniq -c
}

function cert_info() {
  echo | openssl s_client -showcerts -servername ${1} -connect ${1}:443 2>/dev/null | openssl x509 -inform pem -noout -text
}

# Completion extensions
if [ $commands[kubectl] ]; then
  source <(kubectl completion zsh)
fi
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"

# Proxy Settings

function proxy-show() {
  echo "ALL_PROXY = ($ALL_PROXY)"
  echo "HTTP_PROXY = ($HTTP_PROXY)"
  echo "http_proxy = ($http_proxy)"
  echo "HTTPS_PROXY = ($HTTPS_PROXY)"
  echo "https_proxy = ($https_proxy)"
  echo "ftp_proxy = ($ftp_proxy)"
  echo "rsync_proxy = ($rsync_proxy)"
  echo "no_proxy = ($no_proxy)"
  echo "NO_PROXY = ($NO_PROXY)"
}

function proxy-on() {
  export ALL_PROXY=http://localhost:8888
  export HTTP_PROXY=$ALL_PROXY
  export http_proxy=$ALL_PROXY
  export HTTPS_PROXY=$ALL_PROXY
  export https_proxy=$ALL_PROXY
  export ftp_proxy=$ALL_PROXY
  export rsync_proxy=$ALL_PROXY
  export NO_PROXY=localhost,.local,169.254.,127.0.0.1,10.0.2.,/var/run/docker.sock
  export no_proxy=$NO_PROXY
  proxy-show
}

function proxy-off() {
  unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy ftp_proxy rsync_proxy ALL_PROXY NO_PROXY no_proxy
  proxy-show
}

.bash_profile Shell Configuration - Remote Machines

# PS1
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad

# Aliases
alias ls='ls -GFh'

# Python
alias ipython='python -m IPython'
alias ipython3='python3 -m IPython'
PATH=$PATH:$HOME/Library/Python/3.7/bin:$HOME/Library/Python/2.7/bin
PATH=$PATH:/Library/Frameworks/Python.framework/Versions/3.7/bin

System Configurations

  • Turn on "Remote Login" and "Screen Sharing" under System Preferences → Sharing
  • Bump up key repeat under System Preferences → Keyboard

Git Setup

$ git config --global user.name "FIRSTNAME LASTNAME"
$ git config --global user.email "[email protected]"
$ git config --global push.default simple
$ git config --global color.ui "true"
$ git config --global alias.lol "log --pretty=oneline --abbrev-commit --graph --decorate"

# Example: git change-commits GIT_AUTHOR_NAME "name_one" "name_two"
# Credit: https://stackoverflow.com/a/11768843
$ git config --global alias.change-commits '!'"f() { VAR=\$1; OLD=\$2; NEW=\$3; shift 3; git filter-branch --env-filter \"if [[ \\\"\$\`echo \$VAR\`\\\" = '\$OLD' ]]; then export \$VAR='\$NEW'; fi\" \$@; }; f "

$ brew install tig # https://github.com/jonas/tig

Xcode Setup

# Install command line developer tools
xcode-select --install

Useful Utilities

  • Choosy: Configurable default browsers, rule-based checks, etc.
  • Bartender 3: How to hide menu bar icons on Mac
  • BetterTouchTool: Customize input devices and shortcuts (including window snapping and clipboard navigator)
  • iStat Menus: System monitoring menu bar utilities
  • Suspicious Package: Inspect macOS installer packages
  • pgcli: PGDB CLI with autocompletion

Useful Applications

  • Dash: Unified API Documentation Browser
  • Paw: HTTP Client and API Browser
  • Tables Plus: Unified SQL DB GUI
  • Hopper: macOS/Linux Disassembler
  • Sip: Colour sampling, editing, and code formatting
  • Charles Proxy: macOS/iOS proxy
  • Wireshark: Network monitoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment