Last active
March 18, 2020 02:46
-
-
Save navaz-alani/74d006c5833c7988c079c2435ec1c224 to your computer and use it in GitHub Desktop.
Setup scripts to install applications and customize a fresh OS X install.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Do not use Vi compatibility settings | |
set nocompatible | |
" Use utf-8 if Vim was compliled with multi-byte support | |
if has("multi_byte") | |
if &termencoding == "" | |
let &termencoding = &encoding | |
endif | |
set encoding=utf-8 | |
setglobal fileencoding=utf-8 | |
endif | |
if $TERM == "xterm-256color" || $COLORTERM == "gnome-terminal" | |
set t_Co=256 | |
endif | |
if filereadable(expand("~/.vimrc.before")) | |
source ~/.vimrc.before | |
endif | |
" =============== Pathogen Initialization =============== " | |
" This loads all the plugins in ~/.vim/bundle | |
" with tpope's pathogen plugin | |
try | |
call pathogen#infect() | |
catch | |
endtry | |
" ================ General Config ==================== " | |
set number " Show line numbers | |
set history=1000 " Store more history | |
set showcmd " Show incomplete cmds | |
set showmode " Show current mode | |
set visualbell " No sound | |
set hidden " Allow buffers to be hidden | |
" without writing to the disk | |
set textwidth=80 " Hard wrap at 80 characters | |
syntax on " Turn on syntax highlighting | |
" ================ Indentation ====================== " | |
set autoindent | |
set smartindent | |
set smarttab | |
set shiftwidth=2 | |
set softtabstop=2 | |
set tabstop=2 | |
set expandtab | |
filetype plugin indent on | |
" Display whitespace errors as `.' | |
set list listchars=tab:\ \ ,trail:. | |
set nowrap " Do not wrap lines | |
set linebreak " Wrap lines when convenient | |
" =============== Folds / wrapping =============== " | |
set foldmethod=indent " Fold based on indent | |
set foldnestmax=3 " Deepest fold is 3 levels | |
set nofoldenable " Don't fold by default | |
" Highlight long lines | |
if exists('+colorcolumn') | |
set colorcolumn=+1 | |
else | |
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1) | |
endif | |
" ============== Use Gitignore ============== " | |
" let gitignore = '.gitignore' " | |
let gitignore = 'ignore_this_block' | |
if filereadable(gitignore) | |
let igstring = '' | |
for oline in readfile(gitignore) | |
let line = substitute(oline, '\s|\n|\r', '', "g") | |
if line =~ '^#' | con | endif | |
if line == '' | con | endif | |
if line =~ '^!' | con | endif | |
if line =~ '/$' | let igstring .= "," . line . "*" | con | endif | |
let igstring .= "," . line | |
endfor | |
let execstring = "set wildignore+=".substitute(igstring, '^,', '', "g") | |
execute execstring | |
endif | |
" ================ Search Settings ================= " | |
set incsearch " Highlight as you search | |
set hlsearch " Highlight the current search | |
set ignorecase " Make search case insensitive... | |
set smartcase " ... except when we use uppercase letters | |
" =========== Custom Commands and keys ============= " | |
:command ToJSON %!python -m json.tool | |
:nmap \l :setlocal number!<CR> | |
:nmap \p :set paste!<CR> | |
:nmap j gj | |
:nmap k gk | |
" ================ Themes ================= " | |
try | |
let g:solarized_termtrans=1 | |
set background=dark | |
colorscheme solarized | |
catch | |
endtry | |
if filereadable(expand("~/.vimrc.after")) | |
source ~/.vimrc.after | |
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Path to oh-my-zsh installation | |
export ZSH="/Users/$(whoami)/.oh-my-zsh" | |
# ZSH theme | |
ZSH_THEME="gnzh" | |
# Use case-sensitive completion | |
CASE_SENSITIVE="true" | |
plugins=( | |
git | |
zsh-autosuggestions | |
zsh-syntax-highlighting | |
) | |
source $ZSH/oh-my-zsh.sh | |
# set vim mode on | |
set -o vi | |
# read user config | |
source ~/.config/$(whoami)_conf.d/user_config.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git_rename() { | |
if [[ $1 == "-h" || $1 == "--help" ]]; then | |
echo "Usage: git_rename <option> <old_branch_name> <new_branch_name>" | |
echo "Options:" | |
echo " -l or --local Rename locally" | |
echo " -r or --remote Rename locally and remote" | |
return 0 | |
elif [[ ( $1 != "-l" && $1 != "--local" ) && ( $1 != "-r" && $1 != "--remote" ) ]]; then | |
echo "error: unspecied protocol; -l (--local) or -r (--remote)" | |
return 1 | |
elif [[ -z $2 ]]; then | |
echo "error: old branch name unspecified" | |
return 1 | |
elif [[ -z $3 ]]; then | |
echo "error: new branch name unspecified" | |
return 1 | |
fi | |
git checkout $2 | |
git branch -m $3 | |
if [[ $1 == "-r" || $1 == "--remote" ]]; then | |
git push origin -u $3 | |
git push origin --delete $2 | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONF_DIR=~/.config | |
USR_CONF=CONF_DIR/$(whoami)_conf.d | |
SCRIPTS=$(ls *_sc.sh) | |
xc_setup() { | |
xcode-select --install | |
if [[ $? != 0 ]]; then | |
echo "error: could not install Xcode command line tools; Verify Xcode is installed." | |
return 1 | |
fi | |
} | |
install_OMZSH() { | |
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
} | |
get_plugins() { | |
# syntax highlighting | |
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting | |
# bash auto-suggestions | |
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions | |
} | |
sys_config() { | |
# install homebrew | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
cask_installs=( | |
"spotify" | |
"firefox" | |
"google-chrome" | |
"docker" | |
"dashlane" | |
"visual-studio-code" | |
"goland" | |
"mactex-no-gui" | |
) | |
formula_installs=( | |
"go" | |
"node" | |
"python" | |
"ranger" | |
"tree" | |
"bluetoothconnector" | |
) | |
for app in "${cask_installs[@]}"; do | |
brew cask install $app | |
done | |
for app in "${formula_installs[@]}"; do | |
brew install $app | |
done | |
} | |
main() { | |
xc_setup | |
# setup oh-my-zsh | |
install_OMZSH | |
get_plugins | |
# install zsh config | |
mv ./.zshrc > ~/.zshrc | |
# add personal config | |
mkdir $CONF_DIR; mkdir $USR_CONF | |
mkdir $USR_CONF/scripts | |
for sc in "${SCRIPTS[@]}"; do | |
mv $sc $USR_CONF/scripts | |
done | |
sys_config | |
# finally, read new config | |
source ~/.zshrc | |
} | |
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# user_config.sh contains any user specific settings that need to be loaded | |
# load custom scripts | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |
SC_DIR=$DIR/scripts | |
load_scripts() { | |
scripts=$(ls $SC_DIR/*.sh) | |
for sc in "${scripts[@]}"; do | |
source $sc | |
done | |
} | |
# caffeine prevents the display from switching off | |
# due to inactivity. Checks for any existing instances | |
# of `caffeinate` and starts one if none is running. | |
caffeine() { | |
arr=($(pgrep caffeinate)); | |
if [[ ${#arr} == "0" ]]; then | |
caffeinate -d &; | |
fi | |
} | |
load_scripts | |
caffeine | |
# aliases | |
alias go-git="/Users/$(whoami)/go/src/github.com/navaz-alani" | |
alias d="docker-compose" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment