From 307c6353663cf3cdb426eba4ea2555154c4c3508 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Thu, 25 Apr 2019 09:35:12 +0200 Subject: [PATCH 01/16] .bash_profile: Improve `g` autocompletion --- .bash_profile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bash_profile b/.bash_profile index 29717373d18..7334d10b9f2 100644 --- a/.bash_profile +++ b/.bash_profile @@ -33,7 +33,7 @@ elif [ -f /etc/bash_completion ]; then fi; # Enable tab completion for `g` by marking it as an alias for `git` -if type _git &> /dev/null && [ -f /usr/local/etc/bash_completion.d/git-completion.bash ]; then +if type _git &> /dev/null; then complete -o default -o nospace -F _git g; fi; From 5368015b53467949c36f1e386582ac066b0d0ae6 Mon Sep 17 00:00:00 2001 From: Jeff Byrnes Date: Thu, 25 Apr 2019 03:42:27 -0400 Subject: [PATCH 02/16] .bash_profile: Update bash-completion sourcing (#864) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous sourcing is replaced with what the current “caveats” specify (see `brew info bash-completion@2`). And, thanks to Homebrew/homebrew-core#36254, any bash-completions meant for bash-completion v1 are now included, thanks to the environment variable. --- .bash_profile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.bash_profile b/.bash_profile index 7334d10b9f2..f79b6145e40 100644 --- a/.bash_profile +++ b/.bash_profile @@ -26,8 +26,10 @@ for option in autocd globstar; do done; # Add tab completion for many Bash commands -if which brew &> /dev/null && [ -f "$(brew --prefix)/share/bash-completion/bash_completion" ]; then - source "$(brew --prefix)/share/bash-completion/bash_completion"; +if which brew &> /dev/null && [ -r "$(brew --prefix)/etc/profile.d/bash_completion.sh" ]; then + # Ensure existing Homebrew v1 completions continue to work + export BASH_COMPLETION_COMPAT_DIR="$(brew --prefix)/etc/bash_completion.d"; + source "$(brew --prefix)/etc/profile.d/bash_completion.sh"; elif [ -f /etc/bash_completion ]; then source /etc/bash_completion; fi; From e42090bf49f860283951041709163653c8a2c522 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Fri, 23 Aug 2019 15:09:43 +0200 Subject: [PATCH 03/16] .aliases: Make `mergepdf` preserve hyperlinks --- .aliases | 9 +++------ brew.sh | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.aliases b/.aliases index 35446a14288..3387fa0609e 100644 --- a/.aliases +++ b/.aliases @@ -105,9 +105,9 @@ alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && k # URL-encode strings alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"' -# Merge PDF files -# Usage: `mergepdf -o output.pdf input{1,2,3}.pdf` -alias mergepdf='/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py' +# Merge PDF files, preserving hyperlinks +# Usage: `mergepdf input{1,2,3}.pdf` +alias mergepdf='gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=_merged.pdf' # Disable Spotlight alias spotoff="sudo mdutil -a -i off" @@ -130,9 +130,6 @@ for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do alias "${method}"="lwp-request -m '${method}'" done -# Make Grunt print stack traces by default -command -v grunt > /dev/null && alias grunt="grunt --stack" - # Stuff I never really use but cannot delete either because of http://xkcd.com/530/ alias stfu="osascript -e 'set volume output muted true'" alias pumpitup="osascript -e 'set volume output volume 100'" diff --git a/brew.sh b/brew.sh index 5c8963d6e6d..26508ee43dd 100755 --- a/brew.sh +++ b/brew.sh @@ -22,7 +22,7 @@ brew install moreutils brew install findutils # Install GNU `sed`, overwriting the built-in `sed`. brew install gnu-sed --with-default-names -# Install Bash 4. +# Install a modern version of Bash. brew install bash brew install bash-completion2 @@ -83,6 +83,7 @@ brew install ack #brew install exiv2 brew install git brew install git-lfs +brew install gs brew install imagemagick --with-webp brew install lua brew install lynx From 7a41a35b964aad9e71ce3c3e800d64de006d32a0 Mon Sep 17 00:00:00 2001 From: Barry Date: Fri, 23 Aug 2019 08:30:24 -0500 Subject: [PATCH 04/16] .macos: Replace `Flwv` with `glyv` (#886) As of macOS 10.14, Cover Flow view was replaced with Gallery view. --- .macos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.macos b/.macos index 2ce16068182..d7f87e5d4db 100755 --- a/.macos +++ b/.macos @@ -308,7 +308,7 @@ defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist # Use list view in all Finder windows by default -# Four-letter codes for the other view modes: `icnv`, `clmv`, `Flwv` +# Four-letter codes for the other view modes: `icnv`, `clmv`, `glyv` defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv" # Disable the warning before emptying the Trash From 1bed7aa8e04d7b8374edc2047aecddb51eb86fce Mon Sep 17 00:00:00 2001 From: Gianluca Truda Date: Fri, 23 Aug 2019 15:33:34 +0200 Subject: [PATCH 05/16] .macos: Add Hot Corner option for Lock Screen (13) Closes #872. --- .macos | 1 + 1 file changed, 1 insertion(+) diff --git a/.macos b/.macos index d7f87e5d4db..d07fbdf76c7 100755 --- a/.macos +++ b/.macos @@ -424,6 +424,7 @@ sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/Simulator ( # 10: Put display to sleep # 11: Launchpad # 12: Notification Center +# 13: Lock Screen # Top left screen corner → Mission Control defaults write com.apple.dock wvous-tl-corner -int 2 defaults write com.apple.dock wvous-tl-modifier -int 0 From b5cbad4f910987cc74ee110521d67f913631575f Mon Sep 17 00:00:00 2001 From: Jeff Byrnes Date: Fri, 23 Aug 2019 09:34:54 -0400 Subject: [PATCH 06/16] .gitconfig: Simplify `git p` alias MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This uses git pull’s --recurse-submodules argument to avoid the compount command of the previous version of this alias. Closes #868. --- .gitconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitconfig b/.gitconfig index b44243359b9..a4bc3e65aec 100644 --- a/.gitconfig +++ b/.gitconfig @@ -13,7 +13,7 @@ di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d" # Pull in remote changes for the current repository and all its submodules - p = !"git pull; git submodule foreach git pull origin master" + p = git pull --recurse-submodules # Clone a repository including all submodules c = clone --recursive From 5befea3cbca7b7868e8ec18c2372673b49d3c2da Mon Sep 17 00:00:00 2001 From: Kevin Deldycke Date: Tue, 21 Mar 2017 11:13:23 +0100 Subject: [PATCH 07/16] .macos: Consolidate energy management settings Closes #771. --- .macos | 64 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/.macos b/.macos index d07fbdf76c7..40983f0d7ee 100755 --- a/.macos +++ b/.macos @@ -22,9 +22,6 @@ while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & #sudo scutil --set LocalHostName "0x6D746873" #sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "0x6D746873" -# Set standby delay to 24 hours (default is 1 hour) -sudo pmset -a standbydelay 86400 - # Disable the sound effects on boot sudo nvram SystemAudioVolume=" " @@ -96,12 +93,6 @@ defaults write com.apple.helpviewer DevMode -bool true # in the login window sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName -# Restart automatically if the computer freezes -sudo systemsetup -setrestartfreeze on - -# Never go into computer sleep mode -sudo systemsetup -setcomputersleep Off > /dev/null - # Disable Notification Center and remove the menu bar icon launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist 2> /dev/null @@ -126,20 +117,6 @@ defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false #sudo rm -rf /System/Library/CoreServices/DefaultDesktop.jpg #sudo ln -s /path/to/your/image /System/Library/CoreServices/DefaultDesktop.jpg -############################################################################### -# SSD-specific tweaks # -############################################################################### - -# Disable hibernation (speeds up entering sleep mode) -sudo pmset -a hibernatemode 0 - -# Remove the sleep image file to save disk space -sudo rm /private/var/vm/sleepimage -# Create a zero-byte file instead… -sudo touch /private/var/vm/sleepimage -# …and make sure it can’t be rewritten -sudo chflags uchg /private/var/vm/sleepimage - ############################################################################### # Trackpad, mouse, keyboard, Bluetooth accessories, and input # ############################################################################### @@ -195,6 +172,47 @@ sudo systemsetup -settimezone "Europe/Brussels" > /dev/null # Stop iTunes from responding to the keyboard media keys #launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist 2> /dev/null +############################################################################### +# Energy saving # +############################################################################### + +# Enable lid wakeup +sudo pmset -a lidwake 1 + +# Restart automatically on power loss +sudo pmset -a autorestart 1 + +# Restart automatically if the computer freezes +sudo systemsetup -setrestartfreeze on + +# Sleep the display after 15 minutes +sudo pmset -a displaysleep 15 + +# Disable machine sleep while charging +sudo pmset -c sleep 0 + +# Set machine sleep to 5 minutes on battery +sudo pmset -b sleep 5 + +# Set standby delay to 24 hours (default is 1 hour) +sudo pmset -a standbydelay 86400 + +# Never go into computer sleep mode +sudo systemsetup -setcomputersleep Off > /dev/null + +# Hibernation mode +# 0: Disable hibernation (speeds up entering sleep mode) +# 3: Copy RAM to disk so the system state can still be restored in case of a +# power failure. +sudo pmset -a hibernatemode 0 + +# Remove the sleep image file to save disk space +sudo rm /private/var/vm/sleepimage +# Create a zero-byte file instead… +sudo touch /private/var/vm/sleepimage +# …and make sure it can’t be rewritten +sudo chflags uchg /private/var/vm/sleepimage + ############################################################################### # Screen # ############################################################################### From 299b7dc6db8715a8b306267c14f62673286a19f3 Mon Sep 17 00:00:00 2001 From: Kevin Deldycke Date: Fri, 23 Aug 2019 15:44:28 +0200 Subject: [PATCH 08/16] .macos: Also disable Java for local domains in Safari (#769) --- .macos | 1 + 1 file changed, 1 insertion(+) diff --git a/.macos b/.macos index 40983f0d7ee..69e0aaa97c1 100755 --- a/.macos +++ b/.macos @@ -524,6 +524,7 @@ defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebK # Disable Java defaults write com.apple.Safari WebKitJavaEnabled -bool false defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaEnabled -bool false +defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaEnabledForLocalFiles -bool false # Block pop-up windows defaults write com.apple.Safari WebKitJavaScriptCanOpenWindowsAutomatically -bool false From 8cf8c1c8315a6349224eeb3ecc033d469456025f Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Tue, 1 Oct 2019 14:07:56 +0200 Subject: [PATCH 09/16] .bash_prompt: Exit early for Chromium/Blink repo --- .bash_prompt | 76 +++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/.bash_prompt b/.bash_prompt index 3ff63eb6821..74db549f994 100644 --- a/.bash_prompt +++ b/.bash_prompt @@ -16,49 +16,45 @@ prompt_git() { local branchName=''; # Check if the current directory is in a Git repository. - if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then - - # check if the current directory is in .git before running git checks - if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then - - # Ensure the index is up to date. - git update-index --really-refresh -q &>/dev/null; - - # Check for uncommitted changes in the index. - if ! $(git diff --quiet --ignore-submodules --cached); then - s+='+'; - fi; - - # Check for unstaged changes. - if ! $(git diff-files --quiet --ignore-submodules --); then - s+='!'; - fi; - - # Check for untracked files. - if [ -n "$(git ls-files --others --exclude-standard)" ]; then - s+='?'; - fi; - - # Check for stashed files. - if $(git rev-parse --verify refs/stash &>/dev/null); then - s+='$'; - fi; - + git rev-parse --is-inside-work-tree &>/dev/null || return; + + # Check for what branch we’re on. + # Get the short symbolic ref. If HEAD isn’t a symbolic ref, get a + # tracking remote branch or tag. Otherwise, get the + # short SHA for the latest commit, or give up. + branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \ + git describe --all --exact-match HEAD 2> /dev/null || \ + git rev-parse --short HEAD 2> /dev/null || \ + echo '(unknown)')"; + + # Early exit for Chromium & Blink repo, as the dirty check takes too long. + # Thanks, @paulirish! + # https://github.com/paulirish/dotfiles/blob/dd33151f/.bash_prompt#L110-L123 + repoUrl="$(git config --get remote.origin.url)"; + if grep -q 'chromium/src.git' <<< "${repoUrl}"; then + s+='*'; + else + # Check for uncommitted changes in the index. + if ! $(git diff --quiet --ignore-submodules --cached); then + s+='+'; fi; + # Check for unstaged changes. + if ! $(git diff-files --quiet --ignore-submodules --); then + s+='!'; + fi; + # Check for untracked files. + if [ -n "$(git ls-files --others --exclude-standard)" ]; then + s+='?'; + fi; + # Check for stashed files. + if $(git rev-parse --verify refs/stash &>/dev/null); then + s+='$'; + fi; + fi; - # Get the short symbolic ref. - # If HEAD isn’t a symbolic ref, get the short SHA for the latest commit - # Otherwise, just give up. - branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \ - git rev-parse --short HEAD 2> /dev/null || \ - echo '(unknown)')"; - - [ -n "${s}" ] && s=" [${s}]"; + [ -n "${s}" ] && s=" [${s}]"; - echo -e "${1}${branchName}${2}${s}"; - else - return; - fi; + echo -e "${1}${branchName}${2}${s}"; } if tput setaf 1 &> /dev/null; then From 8794573a49cc2e838ba31e8921aaf81f3ffdce5b Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Wed, 27 Nov 2019 16:46:55 +0100 Subject: [PATCH 10/16] README: Fix link (#902) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6fed2ea8f5..7effe343d2c 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ To update later on, just run that command again. ### Specify the `$PATH` -If `~/.path` exists, it will be sourced along with the other files, before any feature testing (such as [detecting which version of `ls` is being used](https://github.com/mathiasbynens/dotfiles/blob/aff769fd75225d8f2e481185a71d5e05b76002dc/.aliases#L21-26)) takes place. +If `~/.path` exists, it will be sourced along with the other files, before any feature testing (such as [detecting which version of `ls` is being used](https://github.com/mathiasbynens/dotfiles/blob/aff769fd75225d8f2e481185a71d5e05b76002dc/.aliases#L21-L26)) takes place. Here’s an example `~/.path` file that adds `/usr/local/bin` to the `$PATH`: From 3fbceb469cc52f021b11f4a0d335c4362366cac4 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Mon, 20 Jan 2020 07:54:41 +0100 Subject: [PATCH 11/16] .gitconfig: Add `g whoami` https://twitter.com/ericlaw/status/1218759854002724864 --- .gitconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitconfig b/.gitconfig index a4bc3e65aec..11c237ecc53 100644 --- a/.gitconfig +++ b/.gitconfig @@ -79,6 +79,9 @@ fi \ }; f" + # Show the user email for the current repository. + whoami = config user.email + [apply] # Detect whitespace errors when applying a patch From 13e29f408fc360360b4468aef2c318dff287c7d2 Mon Sep 17 00:00:00 2001 From: Robert Barat Date: Fri, 3 Apr 2020 02:14:25 -0400 Subject: [PATCH 12/16] .macos: fix showing ~/Library folder in macOS 10.15 (Catalina) (#917) --- .macos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.macos b/.macos index 69e0aaa97c1..e7da9cbded0 100755 --- a/.macos +++ b/.macos @@ -336,7 +336,7 @@ defaults write com.apple.finder WarnOnEmptyTrash -bool false defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true # Show the ~/Library folder -chflags nohidden ~/Library +chflags nohidden ~/Library && xattr -d com.apple.FinderInfo ~/Library # Show the /Volumes folder sudo chflags nohidden /Volumes From 85cedcc150e4ac1a5ab9cd1624ca7cdcde189f82 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Wed, 29 Apr 2020 08:02:02 +0200 Subject: [PATCH 13/16] .exports: Hide zsh warning on macOS --- .exports | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.exports b/.exports index ae9b020cad9..02cd3cdae8d 100644 --- a/.exports +++ b/.exports @@ -32,3 +32,6 @@ export MANPAGER='less -X'; # Avoid issues with `gpg` as installed via Homebrew. # https://stackoverflow.com/a/42265848/96656 export GPG_TTY=$(tty); + +# Hide the “default interactive shell is now zsh” warning on macOS. +export BASH_SILENCE_DEPRECATION_WARNING=1; From d6001330c3bdb4e3f35a8ce2d3b12ac24cd3ee8c Mon Sep 17 00:00:00 2001 From: Jeff Byrnes Date: Mon, 4 May 2020 17:01:51 -0400 Subject: [PATCH 14/16] .gitconfig: improve `git p` alias (#896) Fix a bug introduced in #868, originally proposed in #826. --- .gitconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitconfig b/.gitconfig index 11c237ecc53..fa356f55109 100644 --- a/.gitconfig +++ b/.gitconfig @@ -13,7 +13,7 @@ di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d" # Pull in remote changes for the current repository and all its submodules - p = git pull --recurse-submodules + p = pull --recurse-submodules # Clone a repository including all submodules c = clone --recursive From edea61cb41bfe3553830d810bf843ba51ce94fee Mon Sep 17 00:00:00 2001 From: Chad Gorshing Date: Tue, 16 Jun 2020 16:29:51 -0500 Subject: [PATCH 15/16] .gitconfig: make `git init` default to `main` instead of `master` (#926) Reference: https://stackoverflow.com/a/50880622/96656 --- .config/git/template/HEAD | 1 + .gitconfig | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .config/git/template/HEAD diff --git a/.config/git/template/HEAD b/.config/git/template/HEAD new file mode 100644 index 00000000000..b870d82622c --- /dev/null +++ b/.config/git/template/HEAD @@ -0,0 +1 @@ +ref: refs/heads/main diff --git a/.gitconfig b/.gitconfig index fa356f55109..69f8a54e336 100644 --- a/.gitconfig +++ b/.gitconfig @@ -188,3 +188,7 @@ [url "git://gist.github.com/"] insteadOf = "gist:" + +[init] + + templateDir = ~/.config/git/template/ From c886e139233320e29fd882960ba3dd388d57afd7 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Tue, 16 Jun 2020 23:35:12 +0200 Subject: [PATCH 16/16] meta: rename main branch --- .gitconfig | 2 +- .osx | 2 +- README.md | 2 +- bootstrap.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitconfig b/.gitconfig index 69f8a54e336..b4d26657725 100644 --- a/.gitconfig +++ b/.gitconfig @@ -56,7 +56,7 @@ # Find commits by commit message fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f" - # Remove branches that have already been merged with master + # Remove branches that have already been merged with main # a.k.a. ‘delete merged’ dm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d" diff --git a/.osx b/.osx index 4eacb4e03b7..df12aac66b3 100644 --- a/.osx +++ b/.osx @@ -1 +1 @@ -# 301 https://github.com/mathiasbynens/dotfiles/blob/master/.macos +# 301 https://github.com/mathiasbynens/dotfiles/blob/main/.macos diff --git a/README.md b/README.md index 7effe343d2c..d7bca276ad5 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ set -- -f; source bootstrap.sh To install these dotfiles without Git: ```bash -cd; curl -#L https://github.com/mathiasbynens/dotfiles/tarball/master | tar -xzv --strip-components 1 --exclude={README.md,bootstrap.sh,.osx,LICENSE-MIT.txt} +cd; curl -#L https://github.com/mathiasbynens/dotfiles/tarball/main | tar -xzv --strip-components 1 --exclude={README.md,bootstrap.sh,.osx,LICENSE-MIT.txt} ``` To update later on, just run that command again. diff --git a/bootstrap.sh b/bootstrap.sh index 6844b84a624..5894c6c22f2 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -2,7 +2,7 @@ cd "$(dirname "${BASH_SOURCE}")"; -git pull origin master; +git pull origin main; function doIt() { rsync --exclude ".git/" \