{"id":17854213,"url":"https://github.com/ddelange/new-mac-setup","last_synced_at":"2025-10-16T07:52:06.860Z","repository":{"id":55111929,"uuid":"166650248","full_name":"ddelange/new-mac-setup","owner":"ddelange","description":"A clean setup of Mac OS X 10.15 for [Python] development and more: [ Tech Stack -- Mac Look and Feel -- Terminal Look and Feel -- Git with 2FA -- Preferences -- Backups -- Dotfiles ] ","archived":false,"fork":false,"pushed_at":"2024-12-23T13:53:42.000Z","size":1470,"stargazers_count":42,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-29T17:40:36.716Z","etag":null,"topics":["dotfiles-macos","setup-development-environment","setup-macos","zero-sh"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddelange.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-20T10:46:58.000Z","updated_at":"2024-12-26T07:46:36.000Z","dependencies_parsed_at":"2024-12-19T21:23:34.965Z","dependency_job_id":"1a3d5eb9-3d1d-4713-8aac-e181682ebdd2","html_url":"https://github.com/ddelange/new-mac-setup","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddelange%2Fnew-mac-setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddelange%2Fnew-mac-setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddelange%2Fnew-mac-setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddelange%2Fnew-mac-setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddelange","download_url":"https://codeload.github.com/ddelange/new-mac-setup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233363322,"owners_count":18664964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotfiles-macos","setup-development-environment","setup-macos","zero-sh"],"created_at":"2024-10-28T00:42:09.029Z","updated_at":"2025-09-17T09:31:59.843Z","avatar_url":"https://github.com/ddelange.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# new-mac-setup\n\n[![gitmoji](https://img.shields.io/badge/gitmoji-%20%F0%9F%98%9C%20%F0%9F%98%8D-ffdd67)](https://github.com/carloscuesta/gitmoji-cli)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n\nA clean setup of Mac OS X 10.15 for Python development and more\n\nFor personal \u0026 professional use.\n\n\u003c!-- See also corresponding sublime user settings file in this repo.\n\nAuto updates on save.\n\nhttps://github.com/naokazuterada/MarkdownTOC#usage --\u003e\n\u003c!-- MarkdownTOC --\u003e\n\n- [Notes](#notes)\n- [Tech Stack](#tech-stack)\n  - [Mac Look and Feel](#mac-look-and-feel)\n    - [Apple look \u0026 feel optimisations](#apple-look--feel-optimisations)\n  - [Terminal Look and Feel](#terminal-look-and-feel)\n    - [Homebrew and its essentials](#homebrew-and-its-essentials)\n    - [iTerm nerd font](#iterm-nerd-font)\n    - [Casks](#casks)\n    - [Mac App Store \\(MAS\\)](#mac-app-store-mas)\n  - [Backups](#backups)\n  - [pyenv and pyenv-virtualenv](#pyenv-and-pyenv-virtualenv)\n  - [Terraform](#terraform)\n  - [Git with 2FA](#git-with-2fa)\n      - [Mac OSX specifics](#mac-osx-specifics)\n      - [Aliases](#aliases)\n        - [Shorthands](#shorthands)\n        - [Cleaning](#cleaning)\n        - [Rewriting history](#rewriting-history)\n      - [Split diff](#split-diff)\n      - [Mergetool](#mergetool)\n  - [Cleanup \\(different options\\)](#cleanup-different-options)\n- [Keyboard Shortcuts](#keyboard-shortcuts)\n- [Misc](#misc)\n  - [Kubernetes CLI \\(kubectl\\)](#kubernetes-cli-kubectl)\n  - [Fancy Dropbox screen shot sharing](#fancy-dropbox-screen-shot-sharing)\n  - [Gigabit USB Driver OS X 10.9+](#gigabit-usb-driver-os-x-109)\n- [TODO](#todo)\n\n\u003c!-- /MarkdownTOC --\u003e\n\n\n## Notes\n\n- Avoid committing secrets into this repo by running `pre-commit install` in this dir.\n- Want to copy a big dir from an old Mac? Below is `brew install rsync`! It's much faster than Finder's copying util.\n  ```\n  # boot old Mac while holding `T` to go in Target Disk Mode\n  # password prompt should pop up\n  rsync -au --progress \u003cdrag src folder\u003e ~/backup\n  ```\n- Don't forget to take with your whole `.gnupg` folder, `.gitconfig`, `.envrc` etc!\n- Chrome settings/bookmarks are not backed up and are assumed to come from its builtin Sync.\n\n## Tech Stack\n\n### Mac Look and Feel\n\n```bash\n# Do you understand zsh internals? I don't.\nchsh -s /bin/bash \u0026\u0026 reset\n# show hidden files (finder restart needed)\ndefaults write com.apple.finder AppleShowAllFiles YES\n# disable google chrome dark mode when Mojave dark mode is enabled\ndefaults write com.google.Chrome NSRequiresAquaSystemAppearance -bool yes\n# fit more items in the menu bar [ref](https://apple.stackexchange.com/a/465674/292695)\ndefaults -currentHost write -globalDomain NSStatusItemSpacing -int 6\ndefaults -currentHost write -globalDomain NSStatusItemSelectionPadding -int 6\n```\n\n#### Apple look \u0026 feel optimisations\n\n\u003c!-- TODO convert these to https://github.com/msanders/setup/blob/master/defaults.yaml --\u003e\n\n- `System Preferences/Appearance/`\n  - `Show scroll bars:` Always\n  - `Click in the scroll bar to:` Jump to the spot that's clicked\n- `System Preferences/Keyboard/`\n  - Slide `Key Repeat` to `Fast`\n  - Slide `Delay Until Repeat` to tick one before `Short`\n  - Enable `Keyboard navigation`\n  - Under `Text Input`, untick/remove all `Text Replacements...`\n- `System Preferences/Security \u0026 Privacy/`\n  - Under `FileVault`, turn on FileVault\n- `System Preferences/Accessibility/`\n  - Under `Zoom`, tick `Use scroll gesture with modifier keys to zoom:`\n  - Under `Display`, untick `Shake mouse pointer to locate`\n  - Under `Pointer Control/Trackpad Options...`, tick `Enable dragging/three finger drag`\n- `System Preferences/Trackpad/`\n  - Under `Point \u0026 Click`, set `Click Medium`, enable Tap to click\n  - Under `Scroll \u0026 Zoom`, ticks 0, 1, 0, 1\n  - Under `More Gestures`, set everything to four fingers, disable `Swipe between pages`, disable `Launchpad`, enable `Show Desktop`\n- `System Preferences/Desktop \u0026 Dock/`\n  - Tick `Automatically hide and show the Dock`\n  - Untick `Show suggested and recent apps in Dock`\n- `System Preferences/Language \u0026 Region/`\n  - Set `Number Format` to 1 234 567.89\n  - Untick `Show suggested and recent apps in Dock`\n- `System Preferences/Keyboard`\n  - Under `Text Input/Input Sources/Edit...` untick everything\n- Finder preferences\n  - `General`\n    - `New Finder windows show:` home\n  - `Advanced`\n    - Tick `Show all filename extensions`\n    - `When performing a search:` Search the Current Folder\n- Finder View Options (go home: \u003ckbd\u003e⌘⇧H\u003c/kbd\u003e, then \u003ckbd\u003e⌘J\u003c/kbd\u003e)\n  - Change to list view\n  - Tick `Always open in List View`\n    - Tick `Browse in List View`\n  - `Group by:` None\n  - `Sort by:` Name\n  - Tick `Calculate all sizes`\n  - Tick `Show Library Folder`\n  - **Click** `Use as Defaults`\n- Finder `View` menu item\n  - `Show Tab Bar`\n  - `Show Path Bar`\n  - `Show Status Bar`\n- TextEdit preferences\n  - `New Document`\n    - `Format`: Plain text\n    - Untick `Check spelling as you type`\n  - `Open and Save`\n    - Untick `Add \".txt\" extension to plain text files`\n    - Under `Plain Text File Encoding`, select two times `UTF-8`\n- Screenshot `Options` (to open: \u003ckbd\u003e⌘⇧5\u003c/kbd\u003e)\n  - Save to `Clipboard`\n  - Untick  `Show Floating Thumbnail`\n\n\n### Terminal Look and Feel\n\n#### Homebrew and its essentials\n\n```bash\n# install homebrew (which installs command-line tools)\n/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)\"\nbrew tap buo/cask-upgrade  # `brew cu -a docker` - https://github.com/buo/homebrew-cask-upgrade#usage\n# check whether all is good\nbrew doctor\n\n# and some essentials\nbrew install git gitmoji bash-completion rsync curl openssl readline automake xz zlib sshfs htop ncdu direnv pwgen gcc rust sqlite3 libpq\n```\n\n\n#### iTerm [nerd font](https://github.com/ryanoasis/nerd-fonts/blob/master/readme.md)\n\n```bash\nbrew install --cask iterm2 font-inconsolata-lgc-nerd-font\n\n# some blazing fast rust\ncargo install ripgrep  # rg (search for regex occurrences in directory, fastest regex implementation in the world)\ncargo install zoxide  # z (cd with auto-complete) - echo 'eval \"$(zoxide init bash)\"' \u003e ~.bash_profile\nbrew install zenith # fancy htop with persistent network and disk I/O history graphs\nbrew install eza  # modern alternative for ls https://github.com/eza-community/eza\nbrew install tealdeer  # rust implementation of tldr (man for lazy people) https://github.com/tealdeer-rs/tealdeer\ntldr --update  # populate cache\n# use exa with icons and git status instead of builtin ls\n# this is in .bash_profile already\nalias ls=\"eza --all --group-directories-first --icons --level=2\"  # default level for --tree\nalias ll=\"ls --long --sort=age --git --time=modified --time-style=iso\"\n```\n\n\n#### Casks\n\n```bash\n# Docker CE - docker.com/community-edition - Open Docker.app manually to install helper and to enable CLI\nbrew install --cask docker\n# Sublime Text - sublimetext.com\nbrew install --cask sublime-text\n# Sublime Merge - sublimemerge.com\nbrew install --cask sublime-merge\n# Google Chrome - google.com/chrome\nbrew install --cask google-chrome\n# PIA VPN - privateinternetaccess.com - Requires manual install from ~/Library/Caches/Homebrew/downloads\nbrew install --cask private-internet-access\n# Tunnelblick OpenVPN - tunnelblick.net\n# brew install --cask tunnelblick\n# The Unarchiver - theunarchiver.com\nbrew install --cask the-unarchiver\n# f.lux - justgetflux.com - In Preferences/Sessions, tick 'Allow Display Sleep'\n# brew install --cask flux\n# VLC - videolan.org/vlc\nbrew install --cask vlc\n# Slack - slack.com\n# brew install --cask slack\n# Zoom.us - zoom.us\nbrew install --cask zoom\n# Whatsapp - whatsapp.com\n# brew install --cask whatsapp\n# Dropbox - dropbox.com\n# brew install --cask dropbox\n# Authy - authy.com - Set Master Password in preferences after init\n# brew install --cask authy\n# Jitsi Meet - jit.si\n# brew install --cask jitsi-meet\n# Maccy - maccy.app\nbrew install --cask maccy\n# pdflatex - tug.org/mactex/\nbrew install --cask mactex-no-gui\n# stats in menu bar https://github.com/exelban/stats\nbrew install --cask stats\n# rectangle window resizer https://github.com/rxhanson/Rectangle\nbrew install --cask rectangle\n```\n\n\n#### Mac App Store (MAS)\n\nWhen launching apps for the first time, you might have to accept the dev under `System Preferences/Security \u0026 Privacy/General`\n\nNote: mas will not allow you to install (or even purchase) an app for the first time: it must already be in the Purchased tab of the App Store.\n\n```bash\nbrew install mas\n```\n\n```bash\n# DaisyDisk - daisydiskapp.com\n# give full disk access under sysprefs security tab\nmas install 411643860\n# Amphetamine - roaringapps.com/app/amphetamine\nmas install 937984704\n# Telegram - macos.telegram.org - set password and enter behaviour after init\nmas install 747648890\n```\n\n\n### Backups\n\nNote: first open Chrome for the first time\n\n- Clone (a fork of) this repo and set things up\n  ```bash\n  mkdir ~/git\n  git clone https://github.com/ddelange/new-mac-setup.git ~/git/new-mac-setup\n  ln -s ~/git/new-mac-setup/.bash_profile ~/.bash_profile \u0026\u0026 source ~/.bash_profile\n  ln -s ~/git/.envrc ~/.envrc # tell direnv to look for env vars when entering/leaving ~ (same file works for nested directories in a cumulative fashion)\n  touch ~/.env # fill this one with your secrets/env vars like `export PYENV_VERSION=vv`\n  mkdir -p ~/.config/htop \u0026\u0026 ln -s ~/git/new-mac-setup/htoprc ~/.config/htop/htoprc\n\n  # Sublime Text 3 backup\n  # restore\n  mkdir -p \"${HOME}/Library/Application Support/Sublime Text 3/Packages/User\" \u0026\u0026 \\\n      rsync -a \"${HOME}/git/new-mac-setup/sublime_text_user_settings/\" \"${HOME}/Library/Application Support/Sublime Text 3/Packages/User\"\n\n  # create\n  rsync -a \"${HOME}/Library/Application Support/Sublime Text 3/Packages/User/\" \"${HOME}/git/new-mac-setup/sublime_text_user_settings\"\n\n  # Chrome search engines backup\n  # restore\n  sqlite3 \"${HOME}/Library/Application Support/Google/Chrome/Default/Web Data\" \u003c \"${HOME}/git/new-mac-setup/search-engine-export.sql\"\n  # create\n  (printf 'begin transaction;\\n'; sqlite3 \"${HOME}/Library/Application Support/Google/Chrome/Default/Web Data\" 'select short_name,keyword,url,favicon_url from keywords' | awk -F\\| '{ printf \"REPLACE INTO keywords (short_name, keyword, url, favicon_url) values ('\"'\"%s\"'\"', '\"'\"%s\"'\"', '\"'\"%s\"'\"', '\"'\"%s\"'\"');\\n\", $1, $2, $3, $4 }'; printf 'end transaction;\\n') \u003e ./search-engine-export.sql\n  ```\n- iTerm2 preferences: under `General/Preferences`, tick `Load preferences from a custom folder or URL` and paste `~/git/new-mac-setup`. Quit iTerm\n- Stats preferences: in `General/Import Settings...`, select `Stats settings.plist`. Drag \u0026 drop menu bar items with ⌘+drag\n- iStat Menus preferences: in `File/Import Settings...`, select `iStat Menus Settings.ismp`. Drag \u0026 drop menu bar items with ⌘+drag\n- Quickly download audio \u0026 video with [`yt`](https://github.com/ddelange/yt)\n  ```bash\n  brew install ddelange/brewformulae/yt\n  ``` \n\n\n### [pyenv](https://github.com/pyenv/pyenv/blob/master/COMMANDS.md#command-reference) and [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv#usage)\n\n- Note: pyvenv-virtualenv needs to be initialised in [`~/.bash_profile`](/.bash_profile) (already present there in the right order to cooperate with direnv), or in `~/.bashrc` if both files are [maintained separately](https://github.com/pyenv/pyenv-virtualenv/issues/36#issuecomment-48387008):\n  ```bash\n  eval \"$(pyenv init -)\"\n  if which pyenv-virtualenv-init \u003e /dev/null; then eval \"$(pyenv virtualenv-init -)\"; fi\n  ```\n- Set up latest Python versions (this needs the `LDFLAGS` and `CPPFLAGS` in `.bash_profile`):\n  ```bash\n  brew install pyenv pyenv-virtualenv\n  # get your favourite python versions - github.com/momo-lab/pyenv-install-latest\n  git clone https://github.com/momo-lab/pyenv-install-latest.git \"$(pyenv root)\"/plugins/pyenv-install-latest\n  git clone https://github.com/concordusapps/pyenv-implict.git \"$(pyenv root)\"/plugins/pyenv-implict\n  pyenv install -l | grep '^\\s*[0-9]' # list all available python versions\n  pyenv install-latest 2\n  pyenv install-latest 3.12\n  pyenv versions  # see currently installed versions\n  pyenv global $(pyenv install-latest --print 3.12) $(pyenv install-latest --print 2.7)  # set default versions: prefer py3 over py2\n  # install virtualenv 'vv' based latest pyenv Python version 3.x, inheriting installed packages\n  pyenv virtualenv $(pyenv install-latest --print 3.12) --system-site-packages vv312\n  # same for 'vv27' with python 2.7.x\n  pyenv virtualenv $(pyenv install-latest --print 2.7) --system-site-packages vv27\n  ```\n- Auto-activate venv using direnv when cd'ing into a folder containing an `.envrc` and `.env`:\n  ```bash\n  echo 'export PYENV_VERSION=vv312' \u003e\u003e ~/.env\n  ln -s ~/git/.envrc ~/.envrc  # if it wasn't done already\n  ```\n- Manage envs\n  ```bash\n  pyenvls # alias in .bash_profile\n  pyenv virtualenvs\n  pyenv virtualenv --system-site-packages \u003cvenv-name\u003e\n  pyenv activate \u003cvenv-name\u003e\n  pyenv deactivate\n  pyenv uninstall \u003cvenv-name\u003e\n  ```\n- Add an env var like `export PYENV_VERSION=vv` to your direnv `.env` file to automatically activate and deactivate when entering and leaving directories. Works as long as you don't put a dash (`-`) in your venv name.\n\n### Terraform\n\n```bash\nbrew install tfenv tflint\ntfenv install\ntfenv use\n```\n\n### Git with 2FA\n\n[Enable and set up 2FA](https://gist.github.com/ateucher/4634038875263d10fb4817e5ad3d332f). It's recommended to first delete any git configurations locally after enabling 2FA.\n\n- Use built-in keychain and app password from above, and add a Mac specific global gitignore:\n  ```bash\n  git config --global user.name \"ddelange\"\n  git config --global user.email \"14880945+ddelange@users.noreply.github.com\"  # fetch this from https://github.com/settings/emails\n  git config --global credential.helper osxkeychain\n\n  # EITHER\n  curl -sLw \"\\n\" \"http://gitignore.io/api/macos,python,django,sublimetext\" \u003e\u003e ~/.gitignore  # for all possibilities see http://gitignore.io/api/list\n  # OR\n  cp .gitignore.global ~/.gitignore  # can no longer be a symlink on git version 2.32+\n\n  git config --global core.excludesfile \"~/.gitignore\"\n  ```\n- Note: it's advised to add [commit signature verification](https://help.github.com/en/articles/managing-commit-signature-verification) to Git.\n- EITHER get the existing `~/.gnupg/` from your old machine\n- OR [Generate a GPG key](https://help.github.com/en/articles/generating-a-new-gpg-key#generating-a-gpg-key) and tell Git to use it:\n  ```bash\n  brew install gpg\n  gpg --full-generate-key  # recommended settings: enter, ed25519, enter\n  gpg --list-secret-keys --keyid-format LONG  # copy the signing key after 'sec  ed25519/'\n  gpg --armor --export \u003ckey-here\u003e  # paste this key at github.com/settings/keys\n  git config --global user.signingkey \u003ckey-here\u003e\n  git config --global commit.gpgsign true\n  git config --global gpg.program \"$(which gpg)\"\n  # sign tags using git tag -s\n  ```\n- To [enable password caching](https://stackoverflow.com/a/38422272/5511061) for 1 week:\n  ```bash\n  echo \"default-cache-ttl 604800\" \u003e\u003e ~/.gnupg/gpg-agent.conf\n  echo \"max-cache-ttl 604800\" \u003e\u003e ~/.gnupg/gpg-agent.conf\n  echo \"log-file /var/log/gpg-agent.log\" \u003e\u003e ~/.gnupg/gpg-agent.conf\n  ```\n\n\n##### Mac OSX specifics\n\n```bash\ngit config --global pull.rebase false\ngit config --global core.trustctime false  # http://www.git-tower.com/blog/make-git-rebase-safe-on-osx\ngit config --global core.precomposeunicode false  # http://michael-kuehnel.de/git/2014/11/21/git-mac-osx-and-german-umlaute.html\ngit config --global core.untrackedCache true  # https://git-scm.com/docs/git-update-index#_untracked_cache\ngit config --global merge.log true  # Include summaries of merged commits in newly created merge commit messages\ngit config --global push.default \"simple\" # https://git-scm.com/docs/git-config#Documentation/git-config.txt-pushdefault\ngit config --global push.followTags true # https://git-scm.com/docs/git-config#Documentation/git-config.txt-pushfollowTags\ngit config --global init.defaultBranch master\n```\n\n\n##### Aliases\n\nSome of these aliases depend on one another, in which case it's noted in the comments.\n\n###### Shorthands\n```bash\ngit config --global alias.br \"branch\"\ngit config --global alias.ca \"commit -am\"\ngit config --global alias.cm \"commit\"\ngit config --global alias.co \"checkout\"\ngit config --global alias.mt \"mergetool\"\ngit config --global alias.st \"status\"\n# split diff - needs icdiff (see below) - use `git icdiff` to keep output in terminal after less quits\ngit config --global alias.df '! f() { diff=$(git difft \"$@\") \u0026\u0026 test \"$diff\" \u0026\u0026 echo \"$diff\" | less -eR; }; f'\n# who needs the default verbose git log? - also try `git lg --all`\ngit config --global alias.lg \"log --graph --oneline\"\n# tested with GitHub remote - ref https://stackoverflow.com/questions/28666357#comment101797372_50056710\ngit config --global alias.defaultbranch '! f() { echo $(git remote show origin | grep \"HEAD branch\" | cut -d \":\" -f 2 | xargs); }; f'\n# summary of all configured aliases\ngit config --global alias.alias \"! git config --get-regexp '^alias\\.' | sed -e s/^alias\\.// | grep -v ^'alias ' | sed 's/ /#/' | column -ts#\"\n# \"commit all \u0026 push\" - needs ca,pr - usage `git cap 'Fix bug'` - runs autoformatting pre-commit hooks, commits all modified tracked files with message, and push\ngit config --global alias.cap '! f() { git ca \"$@\" \u0026\u0026 git pr; }; f'\n# \"pull request\" - push new or existing branch skipping the usual --set-upstream error - alias will be overwritten when git-extras is installed\ngit config --global alias.pr '! git push --set-upstream origin \"$(git rev-parse --abbrev-ref HEAD)\"'\n```\n\n###### Cleaning\n```bash\n# \"delete merged\" - delete all local branches (-D) that have been deleted (merged) on remote\ngit config --global alias.dm '! git fetch -p \u0026\u0026 for branch in `git branch -vv | grep '\"': gone] ' | awk '\"'{print $1}'\"'\"'`; do git branch -D $branch; done'\n# \"fetch purge\" - before fetching, remove any remote-tracking references that no longer exist on the remote\ngit config --global alias.fp \"fetch -p --all\"\n# \"rinse \u0026 repeat\" - needs defaultbranch,dm - usage `git gg [develop]` - return to default branch (or specified branch), delete merged and pull\ngit config --global alias.gg '! f() { git checkout \"${1:-$(git defaultbranch)}\" \u0026\u0026 git dm \u0026\u0026 git pull; }; f'\n# \"pull all\" - pull all local branches and return to original branch\ngit config --global alias.pall '! f() { \\\nSTART=$(git branch | grep \"\\*\" | sed \"s/^.//\"); \\\nfor i in $(git branch | sed \"s/^.//\"); do \\\n  git checkout $i; \\\n  git pull || break; \\\ndone; \\\ngit checkout $START; \\\n}; f'\n```\n\n###### Rewriting history\n```bash\n# \"commit all amend\" last commit, adding all modified tracked files to the it without editing the commit message\ngit config --global alias.amend \"commit --amend --reset-author --no-edit -a\"\n# \"commit all amend with message\" - add all modified tracked files to the last commit with a new commit message\ngit config --global alias.camend \"commit --amend --reset-author -am\"\n# \"squash last\" X commits - allowing to edit a pre-generated commit message before committing - known caveat: when trying to squash into an initial commit, the reset fails\ngit config --global alias.squashlast '!f(){ TEMP_MSG=\"$(mktemp)\" \u0026\u0026 git log --format=%B HEAD...HEAD~${1} \u003e \"${TEMP_MSG}\" \u0026\u0026 git reset --soft HEAD~${1} \u0026\u0026 git commit -n --edit --file \"${TEMP_MSG}\"; rm \"${TEMP_MSG}\"; }; f'\n# \"undo\" whatever you did last, for instance an erroneous squashlast - ref https://megakemp.com/2016/08/25/git-undo/\ngit config --global alias.undo '! f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'\n```\n\n\n##### Split diff\n\n- `git df` (above) uses less that keeps a clean terminal\n- `git icdiff` and `git difft` (below) uses new core.pager that leaves less output in terminal after exiting\n\n```bash\ngit config --global --replace-all core.pager 'less -+$LESS -eFRSX'  # with double quotes, $ will be evaluated\n\n# with diff highlighting\npip install git+https://github.com/jeffkaufman/icdiff.git  # installs git-icdiff for `git icdiff``\ngit config --global icdiff.options \"--highlight --line-numbers --numlines=3 --color=always\"\ngit config --global difftool.icdiff.cmd 'icdiff --highlight --line-numbers --numlines=3 --color=always $LOCAL $REMOTE'\n\n# with syntax \u0026 diff highlighting\nbrew install difftastic\ngit config --global difftool.difft.cmd 'difft --display=side-by-side-show-both --color=always --background=light \"$LOCAL\" \"$REMOTE\"'\ngit config --global alias.difft 'difftool --tool difft --no-prompt'\n```\n\n\n##### Mergetool\n\nOn failed automatic merge, use Sublime Merge GUI for conflict resolution using `git mergetool` or `git mt` (see above).\n```bash\ngit config --global mergetool.smerge.cmd 'smerge mergetool \"$BASE\" \"$LOCAL\" \"$REMOTE\" -o \"$MERGED\"'\ngit config --global mergetool.smerge.trustExitCode true\ngit config --global mergetool.keepBackup false\ngit config --global merge.tool smerge\n```\n\n\n### Cleanup ([different options](https://github.com/Homebrew/brew/issues/3784#issuecomment-364675767))\n\n```bash\nbrew cleanup --prune=0  # delete cache older than 0 days\n```\n\n\n## Keyboard Shortcuts\n\n- Sublime\n  - `s`, `smerge`\n  - line selctors: \u003ckbd\u003e⌘L\u003c/kbd\u003e, \u003ckbd\u003e⌘⇧L\u003c/kbd\u003e\n  - swap lines: \u003ckbd\u003e⌃⌘↑/↓\u003c/kbd\u003e\n  - swap selection shortcut TODO\n- forward delete (\u003ckbd\u003e⌦\u003c/kbd\u003e): \u003ckbd\u003efn⌫\u003c/kbd\u003e or \u003ckbd\u003e^D\u003c/kbd\u003e\n- cutpaste files: \u003ckbd\u003e⌘⌥V\u003c/kbd\u003e\n- lock machine: \u003ckbd\u003e⌘⇧Q\u003c/kbd\u003e\n- spotlight: \u003ckbd\u003e⌘␣\u003c/kbd\u003e\n- screenshots: \u003ckbd\u003e⌘⇧3/4/5\u003c/kbd\u003e and one window: \u003ckbd\u003e⌘⇧4\u003c/kbd\u003e, then \u003ckbd\u003e␣\u003c/kbd\u003e\n- restore tab: \u003ckbd\u003e⌘⇧T\u003c/kbd\u003e\n- \u003ckbd\u003e^↑/↓\u003c/kbd\u003e\n- \u003ckbd\u003e⌘~\u003c/kbd\u003e or \u003ckbd\u003e⌘\\`\u003c/kbd\u003e to switch windows\n- `~.` to stop ssh\n- emoji chooser: \u003ckbd\u003e⌘^␣\u003c/kbd\u003e\n- the shortcut-changing prefpane\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eFull Keyboard Symbol List\u003c/b\u003e\u003c/summary\u003e\u003cp\u003e\n\n- ⌘ is \u003ckbd\u003ecommand\u2028\u003c/kbd\u003e\n- ⌥ is \u003ckbd\u003eoption\u2028\u003c/kbd\u003e\n- ⌃ is \u003ckbd\u003econtrol\u2028\u003c/kbd\u003e\n- ⇧ is \u003ckbd\u003eshift\u2028\u003c/kbd\u003e\n- ⇪ is \u003ckbd\u003ecaps lock\u2028\u003c/kbd\u003e\n- ← is \u003ckbd\u003eleft arrow\u2028\u003c/kbd\u003e\n- → is \u003ckbd\u003eright arrow\u2028\u003c/kbd\u003e\n- ↑ is \u003ckbd\u003eup arrow\u2028\u003c/kbd\u003e\n- ↓ is \u003ckbd\u003edown arrow\u2028\u003c/kbd\u003e\n- ⇥ is \u003ckbd\u003etab\u2028\u003c/kbd\u003e\n- ⇤ is \u003ckbd\u003ebacktab\u2028\u003c/kbd\u003e\n- ↩ is \u003ckbd\u003ereturn\u2028\u003c/kbd\u003e\n- ⌤ is \u003ckbd\u003eenter\u2028\u003c/kbd\u003e\n- ⌫ is \u003ckbd\u003edelete\u2028/backspace\u003c/kbd\u003e\n- ⌦ is \u003ckbd\u003eforward delete\u2028\u003c/kbd\u003e\n- ⇞ is \u003ckbd\u003epage up\u2028\u003c/kbd\u003e\n- ⇟ is \u003ckbd\u003epage down\u2028\u003c/kbd\u003e\n- ↖ is \u003ckbd\u003ehome\u2028\u003c/kbd\u003e\n- ↘ is \u003ckbd\u003eend\u2028\u003c/kbd\u003e\n- ⌧ is \u003ckbd\u003eclear\u2028\u003c/kbd\u003e\n- ␣ is \u003ckbd\u003espace\u2028\u003c/kbd\u003e\n- ⎋ is \u003ckbd\u003eescape\u2028\u003c/kbd\u003e\n- ⏏ is \u003ckbd\u003eeject\u003c/kbd\u003e\n\n\u003c/p\u003e\u003c/details\u003e\n\n\n## Misc\n\n- To revert to the classic iTunes playlist view from before v12.6:\n  - Open your iTunes library\n  - Open and run [`Restore old iTunes playlists view.scpt`](/Restore%20old%20iTunes%20playlists%20view.scpt).\n- Scroll horizontally using \u003ckbd\u003e⇧\u003c/kbd\u003e, then mouse wheel\n\n\n### Kubernetes CLI ([kubectl](https://kubernetes.io/docs/reference/kubectl/))\n\nKubectl is a command line interface for running commands against Kubernetes clusters (like viewing logs or executing commands on pods).\nSee [`kubebash kubelogs kubebranch`](https://gist.github.com/ddelange/24575a702a10c2cb6348c4c7f342e0eb) for plug \u0026 play kubectl extensions (they are already in [`~/.bash_profile`](/.bash_profile)).\n\n\n### [Fancy Dropbox screen shot sharing](https://github.com/ddelange/mac-smart-bitly-shortcut)\n\nAppleScript to shorten links using the bitly API in a smart way directly with a keyboard shortcut\n\n\n### [Gigabit USB Driver OS X 10.9+](https://www.asix.com.tw/products.php?op=pItemdetail\u0026PItemID=131;71;112)\n\n**Not needed for 10.15, it is now built-in.**\n\nFor almost any [Gigabit Ethernet USB hub](https://www.ebay.com/itm/3-Ports-USB-3-0-Hub-Gigabit-Ethernet-Lan-RJ45-Network-Adapter-Hub-Hot-Lot-YT/183586523117)\n- Unzip [`AX88179_178A_macintosh_Driver_Installer_v2.13.0.zip`](/AX88179_178A_macintosh_Driver_Installer_v2.13.0.zip)\n- Install driver `pkg` from `AX88179_178A.dmg`\n- Restart\n\n\n## TODO\n\n- Automate this repo with [zero.sh](https://github.com/zero-sh/zero.sh), e.g. https://github.com/msanders/setup\n- Add low battery warning plist\n- Add LaTeX scripts\n- Add Dougs applescripts like [Show in Playlists](http://dougscripts.com/itunes/scripts/ss.php?sp=showinplaylists)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddelange%2Fnew-mac-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddelange%2Fnew-mac-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddelange%2Fnew-mac-setup/lists"}