Skip to content

Instantly share code, notes, and snippets.

@theaxel
Last active April 27, 2022 05:09
Show Gist options
  • Save theaxel/dfdc585226db7dbfb0d57fe55819f588 to your computer and use it in GitHub Desktop.
Save theaxel/dfdc585226db7dbfb0d57fe55819f588 to your computer and use it in GitHub Desktop.
Mac Setup for Ruby Developer
[url "git@github.com:"]
insteadOf = https://github.com/
#!/bin/zsh
# Close any open System Preferences panes, to prevent them from overriding
# settings we’re about to change
osascript -e 'tell application "System Preferences" to quit'
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.macos` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Screenshot location
test -d "${HOME}/Pictures/screenshots" || mkdir -p "${HOME}/Pictures/screenshots"
defaults write com.apple.screencapture location -string "${HOME}/Pictures/screenshots"
# Don’t display the annoying prompt when quitting iTerm
defaults write com.googlecode.iterm2 PromptOnQuit -bool false
# Disable “natural” (Lion-style) scrolling
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false
# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10
# Set language and text formats
# Note: if you’re in the US, replace `EUR` with `USD`, `Centimeters` with
# `Inches`, `en_GB` with `en_US`, and `true` with `false`.
defaults write NSGlobalDomain AppleLanguages -array "en" "nl"
defaults write NSGlobalDomain AppleLocale -string "en_GB@currency=EUR"
defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters"
defaults write NSGlobalDomain AppleMetricUnits -bool true
# Finder: show all filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Keep folders on top when sorting by name
defaults write com.apple.finder _FXSortFoldersFirst -bool true
# Disable the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true
# Enable subpixel font rendering on non-Apple LCDs
# Reference: https://github.com/kevinSuttle/macOS-Defaults/issues/17#issuecomment-266633501
# defaults write NSGlobalDomain AppleFontSmoothing -int 1
# Enable HiDPI display modes (requires restart)
# sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true
# Install Sublime Text settings
# cp -r init/Preferences.sublime-settings ~/Library/Application\ Support/Sublime\ Text*/Packages/User/Preferences.sublime-settings 2> /dev/null
echo "Done. Note that some of these changes require a logout/restart to take effect."
# Aliases
if [ -x "$(command -v exa)" ]; then
alias la="exa -la --git"
fi
# ENV vars
export GITHUB_TOKEN=[TOKEN]
export GEMFURY_TOKEN=[GEM_TOKEN]
export BUNDLE_GITHUB__COM="${GITHUB_TOKEN}:x-oauth-basic"
export BUNDLE_GEM__FURY__IO="${GEMFURY_TOKEN}"
# Activate ZSH Plugins
plugins=( asdf docker docker-compose git herpoku ruby zsh-syntax-highlighting zsh-autosuggestions )
. /opt/homebrew/opt/asdf/libexec/asdf.sh
# to execute run: brew bundle
cask_args appdir: "/Applications"
brew "jq"
brew "jo"
brew "ssh-copy-id"
brew "zsh-completions"
brew "zsh-syntax-highlighting"
# App Store
brew "mas"
mas "1Password 7", id: 1333542190
mas "Slack", id: 803453959
# Start the docker-compose stack in the current directory
alias dc="docker compose"
alias dcu="docker compose up -d"
alias dcr="docker compose run --rm"
# Start the docker-compose stack in the current directory and rebuild the images
alias dcub="docker compose up -d --build"
# Stop, delete (down) or restart the docker-compose stack in the current directory
alias dcs="docker compose stop"
alias dcd="docker compose down"
alias dcrs="docker compose restart"
# Show the logs for the docker-compose stack in the current directory
# May be extended with the service name to get service-specific logs, like
# 'dcl php' to get the logs of the php container
alias dcl="docker compose logs"
alias dps="docker ps"
# Quickly run the docker exec command like this: 'dex container-name bash'
alias dex="docker exec -it"
# Standard container executables
alias drails="docker compose run --rm rails"
alias drake="docker compose run --rm rake"
alias drspec="docker compose run --rm rspec"
alias dbundle="docker compose run --rm bundle"
# This command is a neat shell pipeline to stop all running containers no matter
# where you are and without knowing any container names
alias dsa="docker ps -q | awk '{print $1}' | xargs -o docker stop"
#!/bin/bash
# Homebrew - for managing libs
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# zsh -
brew install zsh
# Oh My Zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# PowerLevel10k - zsh on steroids :) => https://github.com/romkatv/powerlevel10k#homebrew
brew install romkatv/powerlevel10k/powerlevel10k
echo "source $(brew --prefix)/opt/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc
# Install asdf
brew install asdf
# https://asdf-vm.com/guide/getting-started.html#_3-install-asdf
echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc
# Configure completions in zsh
# https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh
# Add to ~/.zprofile => FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
# zsh-syntax-highlighting - It enables highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal.
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# or
brew install zsh-syntax-highlighting
# zsh-autosuggestions - It suggests commands as you type based on history and completions.
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# or
brew install zsh-autosuggestions
# exa: is a modern replacement for ls
brew install exa
{
"color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme",
"default_encoding": "UTF-8",
"default_line_ending": "unix",
"detect_indentation": false,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
".DS_Store",
"Desktop.ini",
"*.pyc",
"._*",
"Thumbs.db",
".Spotlight-V100",
".Trashes"
],
"folder_exclude_patterns":
[
".git",
"node_modules"
],
"font_face": "Monaco",
"font_size": 13,
"highlight_modified_tabs": true,
"hot_exit": false,
"line_padding_bottom": 5,
"match_brackets": true,
"match_brackets_angle": true,
"remember_open_files": true,
"rulers":
[
120
],
"show_encoding": true,
"show_line_endings": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"word_wrap": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment