Skip to content

Instantly share code, notes, and snippets.

@OleksandrKucherenko
Last active April 22, 2024 07:49
Show Gist options
  • Save OleksandrKucherenko/e76220f22359e0e49c81c5474b1457a1 to your computer and use it in GitHub Desktop.
Save OleksandrKucherenko/e76220f22359e0e49c81c5474b1457a1 to your computer and use it in GitHub Desktop.
Pre-configure My mac
#!/usr/bin/env bash
set -x # uncomment to debug
# required for Homebrew
xcode-select —-install
sudo xcodebuild -license accept
# install https://brew.sh/
which brew || (/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" )
# install latest bash
if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then
brew install bash
else
echo "[info] detected BASH version: ${BASH_VERSION}"
fi
# Include cask software packages
# Not needed any more, outdated: brew tap caskroom/cask
# install iTerm2
brew install iterm2 --cask
# install ZSH
which zsh || (brew install zsh)
# install latest GIT
brew install git
brew install git-lfs
# install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# ZSH fast-syntax-highlighting
# deprecated: git clone https://github.com/zdharma/fast-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting
git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting
# ZSH autosuggestions, https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# make ZSH default shell
sudo sh -c "echo $(which zsh) >> /etc/shells" && chsh -s $(which zsh)
# install powerline fonts (https://github.com/powerline/fonts/#quick-installation)
mkdir ~/workspace
git clone https://github.com/powerline/fonts.git --depth=1 ~/workspace/fonts
~/workspace/fonts/install.sh
# show file system as tree in terminal
which tree || (brew install tree)
# `cat` replacer
which bat || (brew install bat)
# expect, simualte user input in scripts
which expect || (brew install expect)
# RIP grep
which rg || (brew install ripgrep)
# https://formulae.brew.sh/formula/midnight-commander
which mcedit || (brew install midnight-commander)
# https://github.com/tldr-pages/tldr
which tldr || (brew install tldr)
# https://formulae.brew.sh/formula/htop
which htop || (brew install htop)
# https://formulae.brew.sh/formula/tmux
which tmux || (brew install tmux)
# JSON, https://formulae.brew.sh/formula/jq
which jq || (brew install jq)
# Yaml, https://github.com/mikefarah/yq
which yq || (brew install yq)
# Nano editor, https://www.nano-editor.org/
which nano || (brew install nano)
# https://formulae.brew.sh/formula/watchman
which watchman || (brew install watchman)
# https://formulae.brew.sh/formula/watch, https://www.geeksforgeeks.org/watch-command-in-linux-with-examples/
which watch || (brew install watch)
# PipeViewer, https://www.ivarch.com/programs/pv.shtml
which pv || (brew install pv)
# Gnu-Sed, https://www.gnu.org/software/sed/
which gsed || (brew install gsed)
# https://command-not-found.com/whiptail
brew install newt
# instal NVM
which nvm || (curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash)
nvm install --lts
nvm use --lts
# install YVM
#which yvm || (brew install tophat/bar/yvm)
which yvm || (curl -s https://raw.githubusercontent.com/tophat/yvm/master/scripts/install.js | node)
yvm list-remote
# install direnv
which direnv || (curl -sfL https://direnv.net/install.sh | bash)
direnv allow
# install RVM, https://rvm.io/rvm/install
which rvm || (curl -sSL https://get.rvm.io | bash -s stable --ruby)
# install LastPass
brew install lastpass --cask
# diff tools
brew install p4v --cask
# p4merge, as GIT default merge tool... https://gist.github.com/tony4d/3454372
git config --global merge.tool p4mergetool
git config --global mergetool.p4mergetool.cmd "/Applications/p4merge.app/Contents/Resources/launchp4merge \$PWD/\$BASE \$PWD/\$REMOTE \$PWD/\$LOCAL \$PWD/\$MERGED"
git config --global mergetool.p4mergetool.trustExitCode false
git config --global mergetool.keepBackup false
#brew install kdiff3
# GIT UI
brew install fork --cask
# install messangers
brew install --cask slack
brew install --cask zoom
brew install --cask telegram-desktop
brew install --cask skype
brew install --cask microsoft-teams
brew install --cask discord
# install alternative browser
brew install google-chrome --cask
# Extensions:
# LastPass: https://chrome.google.com/webstore/detail/lastpass-free-password-ma/hdokiejnpimakedhajhdlcegeplioahd?hl=en-GB
# LanguageTool: https://chrome.google.com/webstore/detail/grammar-and-spell-checker/oldceeleldhonbafppcapldpdifcinji?hl=en-GB
# Grammarly: https://chrome.google.com/webstore/detail/grammarly-for-chrome/kbfnbcaeplbcioakkpcpgfkobkghlhen?hl=en-GB
# ImTranslator: https://chrome.google.com/webstore/detail/imtranslator-translator-d/noaijdpnepcgjemiklgfkcfbkokogabh?hl=en-GB
# AdsBlock: https://getadblock.com/
brew install firefox --cask
/Applications/Firefox.app/Contents/MacOS/firefox https://addons.mozilla.org/en-US/firefox/addon/lastpass-password-manager/ &
# https://github.com/AdoptOpenJDK/homebrew-openjdk
# brew tap AdoptOpenJDK/openjdk
# brew install adoptopenjdk11 --cask
brew install --cask temurin
# install extra fonts
brew tap homebrew/cask-fonts
brew install font-fira-code --cask
brew tap colindean/fonts-nonfree
brew install font-microsoft-office --cask
# install vscode
brew install visual-studio-code --cask
# install TextMate, https://formulae.brew.sh/cask/textmate
brew install textmate --cask
# Anydesk, https://formulae.brew.sh/cask/anydesk
brew install anydesk --cask
# cyberduck, https://cyberduck.io/
brew install cyberduck --cask
# XnConvert, https://www.xnview.com/en/xnconvert/
brew install xnconvert --cask
brew install imagemagick
brew install graphicsmagick
brew install ffmpeg
# Clipboard Manager, Multiple Clipboards
# Clipy, https://clipy-app.com/
brew install clipy --cask
# https://maccy.app/, https://github.com/p0deje/Maccy
brew install maccy
# trolCommander, https://trolsoft.ru/en/soft/trolcommander
brew install trolcommander --cask
# Far Manager For Linux (works for MacOs), https://github.com/elfmz/far2l
brew install --cask far2l
# GitUp, https://gitup.co/
brew install gitup --cask
# Kap, https://getkap.co/
brew install kap --cask
# Keka, www.keka.io
brew install keka --cask
# Be Focused, https://xwavesoft.com/be-focused-pro-for-iphone-ipad-mac-os-x.html
# Windows manager
# Magnet, https://magnet.crowdcafe.com/index.html
# Penc, https://deniz.co/penc/
brew install penc --cask
# Divvy, https://mizage.com/divvy/
brew install divvy --cask
# Calendar, Time, https://www.mowglii.com/itsycal/
# Use pattern: E | 'w'ww | d MMM, HH:mm:ss
brew install itsycal --cask
# Hex Fiend, https://ridiculousfish.com/hexfiend/, https://formulae.brew.sh/cask/hex-fiend
brew install hex-fiend --cask
# https://github.com/zsh-users/zsh-completions
# Android Logcat
brew install pidcat
# Androic Screen Copy tool, https://formulae.brew.sh/formula/scrcpy
brew instal scrcpy
# Screensaver
# https://fliqlo.com/#/screensaver
brew install fliqlo --cask
# Markdown editor, https://macdown.uranusjr.com/
brew install macdown --cask
# https://objective-see.com/products/knockknock.html
brew install knockknock --cask
# manual actions
echo '
plugins=(git colored-man-pages colorize pip python brew osx fast-syntax-highlighting zsh-autosuggestions)
'
# https://github.com/cnstntn-kndrtv/open-in-buttons-for-finder-toolbar
# Finder: Show hidden files
defaults write com.apple.finder AppleShowAllFiles YES
# Finder: Automatically open a new Finder window when a volume is mounted
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true
# Activity Monitor: Visualize CPU usage in the Activity Monitor Dock icon
defaults write com.apple.ActivityMonitor IconType -int 5
# Temperature monitoring: https://beebom.com/how-check-cpu-temperature-mac/, https://fannywidget.com/
brew install fanny
# Enable TouchID for terminal SUDO
# https://dev.to/equiman/how-to-use-macos-s-touch-id-on-terminal-5fhg
# https://unix.stackexchange.com/questions/99350/how-to-insert-text-before-the-first-line-of-a-file
sudo gsed -i '1i auth sufficient pam_tid.so' /etc/pam.d/sudo
# Configure environment ~/.zshrc
# https://www.appsdeveloperblog.com/how-to-set-java_home-on-mac/
#
# List available: `/usr/libexec/java_home -V`
#
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
export ANDROID_HOME=/usr/local/opt/android
export GRADLE_USER_HOME=/usr/local/opt/.gradle
export M2_HOME=/usr/local/opt/.m2
# run in terminal
launchctl setenv JAVA_HOME $JAVA_HOME
launchctl setenv GRADLE_USER_HOME $GRADLE_USER_HOME
launchctl setenv M2_HOME $M2_HOME
launchctl setenv ANDROID_HOME $ANDROID_HOME
# configure Finder, src: https://github.com/mathiasbynens/dotfiles/blob/main/.macos
# Finder: show path bar
defaults write com.apple.finder ShowPathbar -bool true
# Keep folders on top when sorting by name
defaults write com.apple.finder _FXSortFoldersFirst -bool true
# Display full POSIX path as Finder window title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
# Show hidden files
defaults write com.apple.finder AppleShowAllFiles true
# Avoid creating .DS_Store files on network or USB volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true