Improve OSX setup

This commit is contained in:
Lynda Wang 2020-07-25 19:39:09 -04:00 committed by Michael Campagnaro
parent ee11695dee
commit e2f40a7be7
27 changed files with 1378 additions and 702 deletions

View File

@ -39,7 +39,6 @@ abort() {
reload() {
if [[ $platform == 'Linux' || $platform == 'Darwin' ]]; then
#source ~/.zshrc
test -f ~/.aliases && . ~/.aliases
else
test -f ~/.aliases && . ~/.aliases
@ -445,6 +444,7 @@ alias pdot='cd ~/.private-dotfiles'
alias duh='du -csh'
alias exp='explorer .'
alias f='fg'
alias grep='grep -n --color '
alias history='fc -l 1'
alias histroy='history'
alias irb='irb --readline -r irb/completion'

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
source "$HOME/.dotfiles/script_helpers/all.sh"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
source "$HOME/.dotfiles/script_helpers/printing.sh"
source "$HOME/.dotfiles/script_helpers/platform.sh"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copies vim data from the home directory to the dotfiles repo.

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copies vim data from the dotfiles repo to the home directory.

30
install Normal file → Executable file
View File

@ -1,4 +1,15 @@
#!/bin/bash
#!/usr/bin/env bash
platform=`uname`
if [[ $platform == 'Darwin' ]]; then
if ! command -v brew &>/dev/null
then
# We need to update bash, so we'll start with setting up homebrew.
./osx/pre_install
exit
fi
fi
source "script_helpers/printing.sh"
source "script_helpers/core.sh"
@ -6,9 +17,10 @@ source "script_helpers/platform.sh"
source "script_helpers/file_ops.sh"
cwd=$PWD
platform=`uname`
confirm_link=0
os_is_windows is_windows
os_is_macos is_macos
os_is_linux is_linux
if [[ $is_windows -eq 1 ]]; then
# Check for admin permissions.
@ -28,7 +40,9 @@ set -e
setup_zsh() {
printf "Setting up zsh...\n"
if [[ $is_linux -eq 1 ]]; then
sudo apt install zsh
fi
TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
@ -41,16 +55,16 @@ setup_zsh() {
fi
fi
setup_dir .dotfiles/zsh .zsh
FILES=()
FILES+=('zsh')
FILES+=('zshrc')
FILES+=('zshenv')
FILES+=('zlogin')
FILES+=('zprofile')
for file in "${FILES[@]}"
do
setup_file "$file"
setup_file .dotfiles/$file .$file
done
}
@ -96,9 +110,9 @@ if [[ $is_windows -eq 0 ]]; then
setup_zsh
fi
if [[ $platform == 'Darwin' ]]; then
printf "\n${BOLD}Running the OS X installer${NORMAL}\n"
./osx/install.sh
if [[ $is_macos -eq 1 ]]; then
printf "\n${BOLD}Running the MacOS installer${NORMAL}\n"
$cwd/osx/install
fi
popd "$HOME" &>/dev/null

75
osx/install Executable file
View File

@ -0,0 +1,75 @@
#!/usr/bin/env bash
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
BOLD=""
NORMAL=""
fi
set -e
printf "Installing env...\n"
ln -sf $HOME/.dotfiles/osx/env.platform $HOME/.env.platform
printf "Installing Git customizations...\n"
ln -sf $HOME/.dotfiles/osx/gitconfig.platform $HOME/.gitconfig.platform
#-----------------------------------
# Homebrew packages
#-----------------------------------
printf "Installing Homebrew...\n"
brew_packages=(
'openssl'
'wget'
'git'
'rlwrap'
'cmake'
'vim'
'sdl'
'tree'
)
brew tap homebrew/core
for package in "${brew_packages[@]}"
do
printf "Installing $package...\n"
ret=$(brew list | awk /$package/)
if [[ $ret == $package ]]; then
printf "${YELLOW}Already installed!${NORMAL}\n"
else
eval "brew install $package"
printf \n
fi
done
# We have issues downloading Rust on 10.11 with the patched Homebrew checkout
# so we'll install it using their script.
bash -c "$(curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs)"
# For Vim search
cargo install ripgrep
# The homebrew core ctags package is very old.
brew install --HEAD universal-ctags/universal-ctags/universal-ctags
printf "\n${YELLOW}If you haven't already installed the Xcode dev tools then do so now by installing Xcode from the App Store:${NORMAL}\n"
printf "When that finishes open a terminal and run the following:\n"
printf " 1. ${YELLOW}sudo xcode-select --install${NORMAL}\n"
printf " 2. ${YELLOW}sudo xcodebuild -license${NORMAL}\n"
printf " 3. ${YELLOW}sudo xcode-select -s /Applications/Xcode.app/Contents/Developer${NORMAL}\n"
printf "\n${BOLD}Finished setting up OS X${NORMAL}\n"

View File

@ -1,52 +0,0 @@
#!/bin/bash
source "../script_helpers/printing.sh"
set -e
printf "Installing env...\n"
ln -sf $HOME/.dotfiles/osx/env.platform $HOME/.env.platform
printf "Installing git customizations...\n"
ln -sf $HOME/.dotfiles/osx/gitconfig.platform $HOME/.gitconfig.platform
brew tap homebrew/core
printf "Installing xquartz..."
#brew cask install xquartz
brew_packages=(
'tree'
'openssl'
'git'
# 'xclip'
'rlwrap'
'cmake'
'pkg-config'
'vim'
'the_silver_searcher'
'selecta'
# 'rust'
# 'go'
'sdl')
for package in "${brew_packages[@]}"
do
printf "Installing $package..."
ret=$(brew list | awk /$package/)
if [[ $ret == $package ]]; then
printf "${YELLOW}already installed!${NORMAL}\n"
else
eval "brew install $package"
printf \n
fi
done
printf "\n${YELLOW}Now you must install Xcode.${NORMAL}\n"
printf "Open the App Store and install the software.\n"
printf "When that finishes open a terminal and run the following:\n"
printf " 1. ${YELLOW}sudo xcode-select --install${NORMAL}\n"
printf " 2. ${YELLOW}sudo xcodebuild -license${NORMAL}\n"
printf " 3. ${YELLOW}sudo xcode-select -s /Applications/Xcode.app/Contents/Developer${NORMAL}\n"
printf "\n${BOLD}Finished setting up OS X${NORMAL}\n"

54
osx/pre_install Executable file
View File

@ -0,0 +1,54 @@
#!/usr/bin/env bash
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
BOLD=""
NORMAL=""
fi
set -e
printf "Installing Homebrew...\n"
# OSX 10.11 and earlier will issue certificate errors when Homebrew attempts to download packages
# with curl. Detect if we're running on 10.11 or earlier and if so use a fork that passes the
# --insecure option to curl.
kernel_major="$(uname -r | sed 's/\..*//')"
case $kernel_major in
15 | 14 | 13) download_patched_homebrew=1 ;;
*) download_patched_homebrew=0 ;;
esac
if [[ $download_patched_homebrew -eq 1 ]]; then
printf "${BOLD}Current MacOS kernel ${NORMAL}${YELLOW}$(uname -r)${NORMAL}${BOLD} requires a patched version of Homebrew...${NORMAL}\n"
bash -c "$(curl -fsSL https://raw.githubusercontent.com/sir-pinecone/brew/master/install.sh)"
else
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi
brew tap homebrew/core
printf "\nInstalling bash...\n"
ret=$(brew list | awk /$package/)
if [[ $ret == $package ]]; then
printf "${YELLOW}Already installed!${NORMAL}\n"
else
eval "brew install bash"
printf "\n${YELLOW}Finished installing updated version of bash.\nYou must now enable it. Run:${NORMAL}\n"
printf " ${BOLD}sudo vim /etc/shells${NORMAL}\n"
printf "${YELLOW}And add ${NORMAL}${BOLD}/usr/local/bin/bash${NORMAL}${YELLOW} to the end of the list. After that close your terminal and re-run the dotfiles install script.${NORMAL}\n"
fi

View File

@ -1,14 +0,0 @@
# OSX
## Setting up Ruby
* Install rvm
* Install bundler
* Install Ruby Docs
gem install rdoc-data
rdoc-data --install
gem rdoc --all --overwrite
## Setup Keyboard
Map <CapsLock> to <Ctrl> in System Preferences -> Keyboard -> Modifier Keys. Now <caps-c> can leave insert mode.

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
source_helpers="$HOME/.dotfiles/script_helpers"
source "$source_helpers/printing.sh"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#---------------------------------------------------------------------------------------------------
# API

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Requires the printing.sh helper to be sourced.

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Requires the printing.sh helper to be sourced.
# Requires the platform.sh helper to be sourced.
@ -165,6 +165,7 @@ link_file() {
echo "expand_symlinks? $expand_symlinks"
fi
if [[ $is_windows -eq 1 ]]; then
if [[ $expand_symlinks -eq 1 ]]; then
source_path=$(expand_path "$source_path")
dest_path=$(expand_path "$dest_path")
@ -172,6 +173,7 @@ link_file() {
source_path=$(_clean_link_file_path "$source_path")
dest_path=$(_clean_link_file_path "$dest_path")
fi
fi
if [[ $debug -eq 1 ]]; then
echo "after source: $source_path"
@ -210,6 +212,7 @@ link_file() {
echo Link cmd:: $link_cmd
fi
printf "${BOLD}*${NORMAL} ${YELLOW}Linking '$source_path'${NORMAL} to ${YELLOW}'$dest_path'${NORMAL}\n"
eval $link_cmd
}

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#---------------------------------------------------------------------------------------------------
# API

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
uname_s="$(uname -s)"
case "${uname_s}" in

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)

30
vimrc
View File

@ -134,11 +134,6 @@ Plug 'nelstrom/vim-qargs' " For the GlobalReplaceIt function (i.e. s
if IsWindows()
Plug 'suxpert/vimcaps' " Disable capslock (useful if the OS isn't configured to do so).
else
" Fuzzy search
" @incomplete Test out ctrlp for non-Windows setup.
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Plug 'junegunn/fzf.vim'
" @fixme Doesn't do anything under Windows...
" Plug 'ervandew/supertab' " Improved autocompletion.
endif
@ -939,35 +934,23 @@ nnoremap <C-p> :cp<CR>
" SEARCH
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" @incomplete
if !IsWindows()
let rg_args = "--column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --pretty \"always\" " . g:campo_custom_search_args
let cmd = "command! -bang -nargs=* Find call fzf#vim#grep('rg " . rg_args . "'.shellescape(<q-args>), 1, <bang>0)"
exec cmd
endif
" Search using ripgrep (first install with Rust: cargo install ripgrep).
function! Search(case_sensitive)
let helper = "[" . (a:case_sensitive ? "case-sensitive" : "case-insensitive") . "] search: "
let term = input(helper)
if empty(term)
let l:helper = "[" . (a:case_sensitive ? "case-sensitive" : "case-insensitive") . "] search: "
let l:term = input(l:helper)
if empty(l:term)
return
endif
"@note --pretty (i.e. colors) is not enabled in vim-ripgrep because the
"quickfix window doesn't seem to parse the ansi color codes.
let rg_args = "--trim -g \"!tags\" " . g:campo_custom_search_args
let l:rg_args = "--column --line-number --no-heading --fixed-strings --no-ignore --hidden --follow --trim -g \"!tags\" " . g:campo_custom_search_args
if !a:case_sensitive
let rg_args .= " --ignore-case"
let l:rg_args .= " --ignore-case"
endif
if IsWindows()
exec 'Rg ' . rg_args . ' "' . term . '"'
else
" @incomplete Test out ripgrep on non-Windows OS
echo "Not implemented"
endif
exec 'Rg ' . l:rg_args . ' "' . l:term . '"'
endfunction
map <leader>s :call Search(0)<cr>
map <leader>ss :call Search(1)<cr>
@ -978,7 +961,6 @@ map <leader>ss :call Search(1)<cr>
nnoremap <expr> o (&buftype is# "quickfix" ? "<CR>\|:lopen<CR>" : "o")
nnoremap <expr> p (&buftype is# "quickfix" ? "<CR>\|:copen<CR>" : "p")
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" SEARCH & REPLACE
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

View File

@ -159,7 +159,7 @@ processor time and is generally useless.
### Setting up Custom Search
* First install Rusto. See `Setting up Rust` below.
* First install Rust. See `Setting up Rust` below.
* Setup `ripgrep`:
* Open an `msvc x64` shell and run `cargo install ripgrep`. **Note** the last time I did this
I got linker errors saying that it was trying to link an x86 exe in a 64-bit env. I had to run

18
zlogin
View File

@ -1,11 +1,7 @@
# go to saved path if there is one
if [[ -f ~/.current_path~ ]]; then
cd `cat ~/.current_path~`
rm ~/.current_path~
fi
# Need to edit the path again here so that we can get the homebrew bin folder ahead of
# everything else. This is necessary because zsh is modifying the path in zshrc, and
# that causes us to run out of /usr/bin for programs that we want to use from homebrew's
# bin
path=($HOME/homebrew/opt/openssl/bin $HOME/homebrew/sbin $HOME/homebrew/bin $path)
# Need to edit the path again here so that we can get the homebrew bin folder
# ahead of everything else. This is necessary because zsh is modifying the path
# in zshrc, and that causes us to run out of /usr/bin for programs that we want
# to use from homebrew's bin
#
# Update 2020-07-25: This no longer seems to be an issue.
#path=(/usr/local/bin /usr/local/sbin /usr/local/opt/openssl/bin $path)

View File

@ -1 +0,0 @@
source ~/.zshrc

21
zshenv
View File

@ -1,10 +1,4 @@
platform=`uname -s`
kernel_release=`uname -r`
test -f ~/.aliases.private && . ~/.aliases.private
# Common env must come first.
test -f ~/.private-dotfiles.common/env && . ~/.private-dotfiles.common/env
test -f ~/.private-dotfiles/env && . ~/.private-dotfiles/env
# Unbreak broken, non-colored terminal
export TERM=xterm-256color
@ -17,11 +11,10 @@ export HOMEBREW_NO_ANALYTICS=1
export HOMEBREW_NO_INSECURE_REDIRECT=1
export HOMEBREW_CASK_OPTS=--require-sha
# Grep tweaks
export GREP_OPTIONS="-nRi --color --exclude-dir=.git --exclude-dir=tmp --exclude-dir=log --exclude-dir=node_modules --exclude-dir=bower_components --exclude-dir=coverage --exclude-dir=.bundle --exclude=*.csv --exclude=*.pdf --exclude-dir=vendor --exclude-dir=rdoc --exclude-dir=target --exclude-dir=personal --exclude-dir=resources/public/js/*.*" # --exclude-dir=images --exclude-dir=coverage
# Ruby
export RBENV_PATH="$HOME/.rbenv"
# Clojure
export LEIN_FAST_TRAMPOLINE=y
if [[ $platform == 'Linux' ]]; then
@ -32,16 +25,6 @@ if [[ $platform == 'Linux' ]]; then
export LOLCOMMITS_DIR="/shared/Dev/lolcommits"
fi
path=($HOME/bin $HOME/.dotfiles/bin ${RBENV_PATH}/bin $HOME/.vim/scripts $path)
if [[ $platform == 'Darwin' ]]; then
test -f $HOME/.cargo && source $HOME/.cargo/env
# TODO: test for qt
if [ -d "$HOME/Qt" ]; then
path=($HOME/Qt/5.8/clang_64/bin $path)
fi
fi
if [ -d "$HOME/.rbenv" ]; then
# Start rbenv
eval "$(rbenv init -)"

15
zshrc
View File

@ -90,8 +90,19 @@ bindkey -e
source $ZSH/lib/*.zsh
# Source my custom files after oh-my-zsh so I can override things.
source $HOME/.env.platform
source $HOME/.aliases
test -f $HOME/.aliases && . $HOME/.aliases
test -f $HOME/.aliases.private && . $HOME/.aliases.private
# Common env must come first.
test -f $HOME/.private-dotfiles.common/env && . $HOME/.private-dotfiles.common/env
test -f $HOME/.private-dotfiles/env && . $HOME/.private-dotfiles/env
if [[ -d "$HOME/bin" ]]; then
export PATH=$HOME/bin/:$PATH
fi
if [[ -d "$HOME/.dotfiles/bin" ]]; then
export PATH=$HOME/.dotfiles/bin/:$PATH
fi
# Fix <c-h> in neovim
infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $HOME/.$TERM.ti