osx/custompkg/root/usr/local/bin/new-user-setup

262 lines
8.2 KiB
Plaintext
Raw Normal View History

2016-09-30 05:06:32 +00:00
#!/bin/bash
2016-10-03 21:17:48 +00:00
###################################### Configure sane user preference defaults
2016-09-30 21:47:50 +00:00
# black like my soul
defaults write NSGlobalDomain AppleInterfaceStyle Dark
# hide menu bar
defaults write NSGlobalDomain _HIHideMenuBar -bool true
# dock on left
defaults write com.apple.dock orientation left
# autohide dock
defaults write com.apple.dock autohide -bool true
# do not save to icloud drive by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool FALSE
# airdrop on all interfaces
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
2016-09-30 05:06:32 +00:00
# disable spotlight search spyware ugh thx
defaults write com.apple.lookup.shared LookupSuggestionsDisabled -int 1
defaults write com.apple.Safari UniversalSearchEnabled -int 0
# show battery percentage
defaults write com.apple.menuextra.battery ShowPercent -bool TRUE
# ask for password after 5 seconds of screen saver
defaults write com.apple.screensaver askForPassword -int 1
2016-09-30 21:47:50 +00:00
defaults write com.apple.screensaver askForPasswordDelay -int 30
2016-09-30 05:06:32 +00:00
# bottom right corner to lock screen
defaults write com.apple.dock "wvous-br-corner" -int 5
defaults write com.apple.dock "wvous-br-modifier" -int 0
2016-10-03 21:17:48 +00:00
# 10 minute screensaver activation
2016-09-30 21:47:50 +00:00
defaults write com.apple.screensaver idleTime -int 600
2016-10-03 21:17:48 +00:00
# terminal utf8 only
2016-09-30 21:47:50 +00:00
defaults write com.apple.Terminal StringEncodings -array 4
2016-10-03 21:17:48 +00:00
# close terminal window if shell exited cleanly
2016-09-30 21:47:50 +00:00
defaults write com.apple.Terminal ShellExitAction 2
defaults write com.apple.Terminal FontAntialias 1
defaults write com.apple.Terminal "Default Window Settings" "Pro"
defaults write com.apple.Terminal "Startup Window Settings" "Pro"
2016-10-04 01:46:38 +00:00
# new finder windows use ~
2016-09-30 05:06:32 +00:00
defaults write com.apple.finder NewWindowTarget -string "PfHm"
2016-10-04 01:46:38 +00:00
# new finder windows show status bar
defaults write com.apple.finder ShowStatusBar -int 1
2016-09-30 05:06:32 +00:00
# don't show mounted volumes on desktop
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -int 0
defaults write com.apple.finder ShowRemovableMediaOnDesktop -int 0
2016-10-04 03:13:33 +00:00
# set textedit to edit plain text by default:
defaults write com.apple.TextEdit RichText -int 0
2016-10-04 01:46:38 +00:00
# set airdrop/bluetooth to be discoverable by everyone in range
defaults write com.apple.sharingd DiscoverableMode Everyone
2016-09-30 05:06:32 +00:00
# finder show all file extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# set menubar clock to 24h with date and seconds
defaults write com.apple.menuextra.clock DateFormat -string 'EEE MMM d H:mm:ss'
2016-10-04 03:16:58 +00:00
defaults write NSGlobalDomain AppleICUForce24HourTime -bool true
2016-09-30 05:06:32 +00:00
# set keyboard to be really fucking fast
2016-10-03 21:17:48 +00:00
# normal minimum is 15 (225 ms)
defaults write NSGlobalDomain InitialKeyRepeat -int 15
# normal minimum is 2 (30 ms)
defaults write NSGlobalDomain KeyRepeat -int 1
2016-10-04 01:46:38 +00:00
# disable all spelling correction, smart quotes, capitalization, et c:
# (*important* for code)
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -int 0
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -int 0
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -int 0
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -int 0
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -int 0
2016-09-30 21:47:50 +00:00
# safari debug stuff
defaults write com.apple.Safari IncludeDevelopMenu -bool true
2016-10-03 21:17:48 +00:00
defaults write com.apple.Safari \
WebKitDeveloperExtrasEnabledPreferenceKey -bool true
2016-09-30 21:47:50 +00:00
defaults write com.apple.Safari "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" -bool true
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
2016-10-03 21:17:48 +00:00
######################################################### set default inputrc
2016-09-30 21:47:50 +00:00
cat > ~/.inputrc <<EOF
set show-all-if-ambiguous on
set completion-ignore-case on
set completion-prefix-display-length 4
Control-j: menu-complete
Control-k: menu-complete-backward
set show-all-if-unmodified on
set completion-map-case on
set horizontal-scroll-mode Off
EOF
2016-10-03 21:17:48 +00:00
############################################## install homebrew under homedir
2016-09-30 05:06:32 +00:00
if [[ ! -d ~/Library/Homebrew ]]; then
2016-10-03 21:17:48 +00:00
mkdir -p ~/Library/Homebrew
cd ~/Library/Homebrew
curl -fsSL https://github.com/Homebrew/brew/tarball/master | \
tar --strip-components 1 -xvf -
2016-09-30 05:06:32 +00:00
fi
2016-10-03 21:17:48 +00:00
######################################## setup modular bashrc.d and profile.d
2016-09-30 05:06:32 +00:00
cat > ~/.bashrc <<'EOF'
# do not edit this file. put files in the dir below.
for FN in $HOME/Library/bashrc.d/*.sh ; do
source $FN
done
EOF
mkdir -p ~/Library/bashrc.d
touch ~/Library/bashrc.d/keep.sh
cat > ~/.profile <<'EOF'
# do not edit this file. put files in the dir below.
source ~/.bashrc
for FN in $HOME/Library/profile.d/*.sh ; do
source $FN
done
EOF
mkdir -p ~/Library/profile.d
touch ~/Library/profile.d/keep.sh
2016-10-03 21:17:48 +00:00
####################################################### install homebrew path
cat > ~/Library/bashrc.d/100homebrew.sh <<'EOF'
export PATH+=":$HOME/Library/Homebrew/bin"
export PATH+=":$HOME/Library/Homebrew/sbin"
export HOMEBREW_NO_ANALYTICS=1
EOF
####################################### Set caskroom to install under homedir
cat > ~/Library/bashrc.d/100homebrewcaskdir.sh <<'EOF'
export HOMEBREW_CASK_OPTS="--appdir=$HOME/Applications"
EOF
##################################################################### set PS1
cat > ~/Library/bashrc.d/000.ps1.sh <<'EOF'
export PS1='\u@\h:\w\\$ '
EOF
############################################################ enable git prompt
2016-09-30 21:47:50 +00:00
cat > ~/Library/bashrc.d/200.git-prompt.sh <<'EOF'
if [ -f "$(brew --prefix bash-git-prompt)/share/gitprompt.sh" ]; then
GIT_PROMPT_THEME=Default
GIT_PROMPT_ONLY_IN_REPO=1
source "$(brew --prefix bash-git-prompt)/share/gitprompt.sh"
fi
EOF
2016-10-03 21:17:48 +00:00
########################################## enable bash completion in homebrew
cat > ~/Library/bashrc.d/900.homebrew-completion.sh <<'EOF'
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
EOF
#################################################### set sane env preferences
cat > ~/Library/bashrc.d/400.environment.sh <<'EOF'
export PAGER=vimpager
export EDITOR=vim
export VISUAL=$EDITOR
EOF
###################################################### set up helpful aliases
cat > ~/Library/bashrc.d/500.aliases.sh <<'EOF'
alias less=vimpager
EOF
2016-10-03 21:17:48 +00:00
################################################################### GPG Agent
cat > ~/Library/profile.d/900.gpg-agent.sh <<'EOF'
# check for existing running agent info
if [[ -e $HOME/.gpg-agent-info ]]; then
source $HOME/.gpg-agent-info
export GPG_AGENT_INFO SSH_AUTH_SOCK SSH_AGENT_PID
fi
2016-09-30 21:47:50 +00:00
2016-10-03 21:17:48 +00:00
# test existing agent, remove info file if not working
ssh-add -L 2>/dev/null >/dev/null || rm -f $HOME/.gpg-agent-info
# if no info file, start up potentially-new, working agent
if [[ ! -e $HOME/.gpg-agent-info ]]; then
2016-10-04 01:46:38 +00:00
gpg-agent \
--enable-ssh-support \
--daemon \
--write-env-file \
--use-standard-socket \
--pinentry-program $(brew --prefix)/bin/pinentry-mac \
2016-10-03 21:17:48 +00:00
2>&1 >/dev/null
fi
2016-09-30 05:06:32 +00:00
2016-10-03 21:17:48 +00:00
# load up new agent info
if [[ -e $HOME/.gpg-agent-info ]]; then
source $HOME/.gpg-agent-info
export GPG_AGENT_INFO SSH_AUTH_SOCK SSH_AGENT_PID
fi
EOF
#############################################################################
### load up profile scripts / paths for the rest of this configuration script
source ~/.profile
####################################################### install caskroom apps
2016-09-30 05:06:32 +00:00
if [[ ! -d ~/Applications ]]; then
mkdir -p ~/Applications
fi
brew tap caskroom/cask
CASKS="
2016-10-03 21:17:48 +00:00
atom
disk-inventory-x
2016-09-30 21:47:50 +00:00
github-desktop
2016-09-30 05:06:32 +00:00
google-chrome
google-drive
2016-09-30 21:47:50 +00:00
iterm2
keepassx
lastpass
2016-09-30 05:06:32 +00:00
slack
2016-10-04 01:46:38 +00:00
spotify
2016-09-30 21:47:50 +00:00
sublime-text
2016-10-04 01:46:38 +00:00
xscreensaver
2016-09-30 05:06:32 +00:00
"
for CASK in $CASKS ; do
brew cask install $CASK
done
2016-10-03 21:17:48 +00:00
#################################################### install homebrew packages
2016-09-30 05:06:32 +00:00
HOMEBREW_PKGS="
autoconf
automake
bash-completion
2016-09-30 21:47:50 +00:00
bash-git-prompt
2016-09-30 05:06:32 +00:00
bonnie++
byobu
cmake
coreutils
curl
daemontools
docker
docker-compose
docker-machine
duplicity
ffmpeg
fish
flac
geoip
ghc
gist
git
gnupg
gnupg2
go
gpg-agent
2016-09-30 21:47:50 +00:00
homebrew/dupes/rsync
2016-09-30 05:06:32 +00:00
irssi
jq
keybase
lame
mobile-shell
mtr
mutt
nmap
node
pbzip2
pinentry-mac
protobuf
pv
pwgen
python3
socat
sox
speedtest_cli
syncthing
tcptraceroute
terraform
tor
torsocks
unrar
unzip
vimpager
2016-09-30 05:06:32 +00:00
watch
wget
whatmask
"
for PKG in $HOMEBREW_PKGS ; do
brew install $PKG
done
2016-10-03 21:17:48 +00:00
############################################# look for vimrc in google drive
ln -s ~/Google\ Drive/Dotfiles/vimrc ~/.vimrc