Last active
September 8, 2020 20:02
-
-
Save obatiuk/7be332c88bf6ead4bde7e48329e55f0f to your computer and use it in GitHub Desktop.
osx basic setup script
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
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion | |
export PATH=$PATH:$HOME/tools/git-tools | |
export JAVA_HOME=$(/usr/libexec/java_home) | |
export GREP_OPTIONS='--color=always' | |
export GREP_COLOR='1;35;40' | |
export CLICOLOR=1 | |
alias ll='ls -la' | |
alias fixcam='sudo pkill "VDCAssistant"' | |
alias update='brew update; brew upgrade; brew prune; brew cleanup; brew doctor; brew cu; softwareupdate -i -a' | |
# The next lines enable git prompt | |
[ -r $(brew --prefix)/etc/bash_completion.d/git-prompt.sh ] && . $(brew --prefix)/etc/bash_completion.d/git-prompt.sh | |
# If the function __git_ps1 is NOT defined, create a dummy | |
type __git_ps1 > /dev/null 2>&1 | |
if [ $? != "0" ] ; then | |
# define a dummy function so that it can be safely used in PS1 below. | |
__git_ps1() { echo ; } | |
fi | |
export GIT_PS1_SHOWCOLORHINTS=1 | |
export GIT_PS1_SHOWUNTRACKEDFILES=1 | |
export GIT_PS1_SHOWDIRTYSTATE=1 | |
export PROMPT_COMMAND='__git_ps1 "[\[\e[0;33m\]\u\[\e[0;m\]@\h \W"] "\\\$ "' |
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
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict | |
This file remaps the key bindings of a single user on Mac OS X 10.5 to more | |
closely match default behavior on Windows systems. This makes the Command key | |
behave like Windows Control key. To use Control instead of Command, either swap | |
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys... | |
or replace @ with ^ in this file. | |
Here is a rough cheatsheet for syntax. | |
Key Modifiers | |
^ : Ctrl | |
$ : Shift | |
~ : Option (Alt) | |
@ : Command (Apple) | |
# : Numeric Keypad | |
Non-Printable Key Codes | |
Standard | |
Up Arrow: \UF700 Backspace: \U0008 F1: \UF704 | |
Down Arrow: \UF701 Tab: \U0009 F2: \UF705 | |
Left Arrow: \UF702 Escape: \U001B F3: \UF706 | |
Right Arrow: \UF703 Enter: \U000A ... | |
Insert: \UF727 Page Up: \UF72C | |
Delete: \UF728 Page Down: \UF72D | |
Home: \UF729 Print Screen: \UF72E | |
End: \UF72B Scroll Lock: \UF72F | |
Break: \UF732 Pause: \UF730 | |
SysReq: \UF731 Menu: \UF735 | |
Help: \UF746 | |
OS X | |
delete: \U007F | |
For a good reference see http://osxnotes.net/keybindings.html. | |
NOTE: typically the Windows 'Insert' key is mapped to what Macs call 'Help'. | |
Regular Mac keyboards don't even have the Insert key, but provide 'Fn' instead, | |
which is completely different. | |
*/ | |
{ | |
"\UF729" = "moveToBeginningOfLine:"; /* Home */ | |
"^\UF702" = "moveToBeginningOfLine:"; /* Cmd + Left Arrow */ | |
"@\UF729" = "moveToBeginningOfDocument:"; /* Ctrl + Home */ | |
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */ | |
"$@\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Ctrl + Home */ | |
"$^\UF702" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Cmd + Left Arrow */ | |
"\UF72B" = "moveToEndOfLine:"; /* End */ | |
"^\UF703" = "moveToEndOfLine:"; /* Cmd + Right Arrow */ | |
"@\UF72B" = "moveToEndOfDocument:"; /* Ctrl + End */ | |
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */ | |
"$@\UF72B" = "moveToEndOfDocumentAndModifySelection:"; /* Shift + Ctrl + End */ | |
"$^\UF703" = "moveToEndOfLineAndModifySelection:"; /* Shift + Cmd + Right Arrow */ | |
"\UF72C" = "pageUp:"; /* PageUp */ | |
"\UF72D" = "pageDown:"; /* PageDown */ | |
"@x" = "cut:"; /* Ctrl + x */ | |
"@c" = "copy:"; /* Crtl + c */ | |
"@v" = "paste:"; /* Ctrl + v */ | |
"$\UF728" = "cur:"; /* Shift + Del */ | |
"@\UF727" = "copy:"; /* Ctrl + Insert */ | |
"$\UF727" = "paste:"; /* Shift + Insert */ | |
"@\UF702" = "moveWordBackward:"; /* Ctrl + Left Arrow */ | |
"@\UF703" = "moveWordForward:"; /* Ctrl + Right Arrow */ | |
"$@\UF702" = "moveWordBackwardAndModifySelection:"; /* Shift + Cmd + Left Arrow */ | |
"$@\UF703" = "moveWordForwardAndModifySelection:"; /* Shift + Cmd + Right Arrow */ | |
} |
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
#!/bin/bash | |
# helpers | |
function echo_ok { echo -e '\033[1;32m'"$1"'\033[0m'; } | |
function echo_warn { echo -e '\033[1;33m'"$1"'\033[0m'; } | |
function echo_error { echo -e '\033[1;31mERROR: '"$1"'\033[0m'; } | |
## Base packages | |
# homebrew | |
export HOMEBREW_CASK_OPTS="--appdir=/Applications" | |
if hash brew &> /dev/null; then | |
echo_ok "Homebrew already installed" | |
else | |
echo_warn "Installing homebrew..." | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
fi | |
# Cask | |
brew tap caskroom/cask | |
brew tap caskroom/fonts | |
brew tap caskroom/versions | |
# Fonts | |
echo_warn "Installing fonts..." | |
brew cask install \ | |
font-anonymous-pro \ | |
font-dejavu-sans-mono-for-powerline \ | |
font-droid-sans \ | |
font-droid-sans-mono font-droid-sans-mono-for-powerline \ | |
font-inconsolata font-inconsolata-for-powerline \ | |
font-liberationmono-nerd-font-mono font-liberation-mono-for-powerline \ | |
font-liberation-sans \ | |
font-source-code-pro font-source-code-pro-for-powerline \ | |
font-source-sans-pro \ | |
font-ubuntu | |
### Packages & Applications | |
# Development packages | |
brew install bash-completion | |
brew install git git-extras | |
brew install node | |
brew install tree | |
brew install ncdu | |
brew install jq | |
brew install mc | |
brew cask install java | |
brew cask install postico | |
brew cask install spectacle | |
brew cask install caffeine | |
brew cask install postman | |
brew cask install opera | |
brea cask install firefox | |
brew cask install google-chrome | |
brew cask install google-hangouts | |
# command-line tool for upgrading every outdated app installed by Homebrew Cask | |
# use `brew uc` to upgrade all outdated apps (see `brew help cu` for more details) | |
# Source: https://github.com/buo/homebrew-cask-upgrade | |
brew tap buo/cask-upgrade | |
### Settings | |
# ============================================== | |
# Appearance | |
# ============================================== | |
# Enable subpixel font rendering on non-Apple LCDs | |
defaults write -g AppleFontSmoothing -int 2 | |
# Use dark menubar and Dock | |
defaults write -g AppleInterfaceStyle -string "Dark" | |
# ============================================== | |
# Finder | |
# ============================================== | |
echo "Setting Finder preferences" | |
# Show all filename extensions in Finder | |
defaults write -g AppleShowAllExtensions -bool true | |
# Display hidden files | |
defaults write com.apple.finder AppleShowAllFiles -bool true | |
# Show full path in Finder title | |
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true | |
# Show Path Bar | |
defaults write com.apple.Finder ShowPathbar -bool true | |
# Show Status Bar | |
defaults write com.apple.finder ShowStatusBar -bool true | |
# Sets default save target to be a local disk, not iCloud. | |
defaults write -g NSDocumentSaveNewDocumentsToCloud -bool false | |
# Set Default Finder Location to Home Folder | |
defaults write com.apple.finder NewWindowTarget -string "PfLo" && \ | |
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}" | |
# Show icons for hard drives, servers, and removable media on the desktop | |
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true | |
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true | |
defaults write com.apple.finder ShowMountedServersOnDesktop -bool true | |
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true | |
# Avoid creating .DS_Store files on network volumes | |
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true | |
# Avoid creating .DS_Store files on USB Volumes | |
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true | |
# Disable window animations and Get Info animations in Finder | |
defaults write com.apple.finder DisableAllAnimations -bool true | |
# Display Library folders | |
sudo chflags nohidden /Library/ ~/Library/ | |
# ============================================== | |
# Dock | |
# ============================================== | |
echo "Setting Dock preferences" | |
# Position (left, bottom, right) | |
defaults write com.apple.dock orientation -string "bottom" | |
# Set the icon size of Dock items to 36 pixels | |
defaults write com.apple.dock tilesize -int 36 | |
# Make Dock icons of hidden applications translucent | |
defaults write com.apple.dock showhidden -bool true | |
# Prefer tabs when opening documents: 'always', 'fullscreen', 'manual' | |
defaults write -g AppleWindowTabbingMode -string 'fullscreen' | |
# ============================================== | |
# Dashboard | |
# ============================================== | |
echo "Setting Dashboard preferences" | |
# disable Dashboard | |
defaults write com.apple.dashboard mcx-disabled -bool true | |
# ============================================== | |
# Screencapture | |
# ============================================== | |
# Save screenshots to the desktop | |
defaults write com.apple.screencapture location -string "$HOME/Desktop" | |
# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF) | |
defaults write com.apple.screencapture type -string "png" | |
# Disable shadow in screenshots | |
defaults write com.apple.screencapture disable-shadow -bool true | |
# ============================================== | |
# Terminal | |
# ============================================== | |
echo "Setting Terminal preferences" | |
# ---------------------------------------------- | |
# Copy the "Pro" profile to "Pro Improved" | |
# ---------------------------------------------- | |
pathToTerminalPrefs="${HOME}/Library/Preferences/com.apple.Terminal.plist" | |
/usr/libexec/PlistBuddy -c "Copy :Window\ Settings:Pro :Window\ Settings:Pro\ Improved" ${pathToTerminalPrefs} | |
/usr/libexec/PlistBuddy -c "Set :Window\ Settings:Pro\ Improved:name Pro\ Improved" ${pathToTerminalPrefs} | |
# ---------------------------------------------- | |
# Modify the "Pro Improved" profile | |
# ---------------------------------------------- | |
# Close if the shell exited cleanly | |
/usr/libexec/PlistBuddy -c "Add :Window\ Settings:Pro\ Improved:shellExitAction integer 1" ${pathToTerminalPrefs} | |
# Make the window a bit larger | |
/usr/libexec/PlistBuddy -c "Add :Window\ Settings:Pro\ Improved:columnCount integer 120" ${pathToTerminalPrefs} | |
/usr/libexec/PlistBuddy -c "Add :Window\ Settings:Pro\ Improved:rowCount integer 70" ${pathToTerminalPrefs} | |
# ---------------------------------------------- | |
# Terminal preferences | |
# ---------------------------------------------- | |
# Shell opens with: /bin/bash | |
defaults write com.apple.Terminal Shell -string "/bin/bash" | |
# Set the "Pro Improved" as the default | |
defaults write com.apple.Terminal "Startup Window Settings" -string "Pro Improved" | |
defaults write com.apple.Terminal "Default Window Settings" -string "Pro Improved" | |
CFPreferencesAppSynchronize "com.apple.Terminal" | |
### Keyboard | |
# Disable dashes substitution | |
defaults write -g NSAutomaticDashSubstitutionEnabled 0 | |
defaults write -g TSWPAutomaticDashSubstitution 0 | |
# Disable automatic capitalization as it’s annoying when typing code | |
defaults write -g NSAutomaticCapitalizationEnabled -bool false | |
# set faster key repeat (minimum possible values) | |
defaults write -g KeyRepeat -int 2 | |
defaults write -g InitialKeyRepeat -int 15 | |
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs) | |
defaults write -g AppleKeyboardUIMode -int 3 | |
# Use all F1,F2 keys as standard function keys | |
defaults write -g com.apple.keyboard.fnState -int 1 | |
## Keyboard shortcuts | |
# ('Command' key should be swapped with 'Control; key before that) | |
mkdir -p ${HOME}/Library/KeyBindings | |
curl -o ${HOME}/Library/KeyBindings/DefaultKeyBinding.disct https://gist.githubusercontent.com/obatiuk/7be332c88bf6ead4bde7e48329e55f0f/raw/9ce147ce9f0a3be1c78b1c1c27e33ca117b25b2e/DefaultKeyBinding.disct | |
# Add correct Ukrainian Layout (should be enabled manually) | |
svn export -r HEAD --trust-server-cert-failures=unknown-ca --non-interactive --force https://github.com/korzhyk/OSX-Ukrainian-Unicode-Layout/trunk/Install%20Ukrainian%20Unicode%20Layout.app/Contents/Resources/Layout ~/Library/Keyboard\ Layouts/ | |
# Kill affected applications | |
for app in Finder Dock Safari; do killall "$app" > /dev/null 2>&1; done | |
echo "Done. Note that some of these changes require a logout/restart to take effect." | |
# Other stuff | |
mkdir -p ${HOME}/tools | |
cd ${HOME}/tools | |
git clone https://github.com/MestreLion/git-tools.git | |
hostname=mac | |
sudo scutil --set ComputerName $hostname | |
sudo scutil --set LocalHostName $hostname | |
sudo scutil --set HostName $hostname | |
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $hostname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment