Skip to content

Commit c378b62

Browse files
committed
* 'master' of https://github.com/mathiasbynens/dotfiles: meta: rename main branch .gitconfig: make `git init` default to `main` instead of `master` (mathiasbynens#926) .gitconfig: improve `git p` alias (mathiasbynens#896) .exports: Hide zsh warning on macOS .macos: fix showing ~/Library folder in macOS 10.15 (Catalina) (mathiasbynens#917) .gitconfig: Add `g whoami` README: Fix link (mathiasbynens#902) .bash_prompt: Exit early for Chromium/Blink repo .macos: Also disable Java for local domains in Safari (mathiasbynens#769) .macos: Consolidate energy management settings .gitconfig: Simplify `git p` alias .macos: Add Hot Corner option for Lock Screen (13) .macos: Replace `Flwv` with `glyv` (mathiasbynens#886) .aliases: Make `mergepdf` preserve hyperlinks .bash_profile: Update bash-completion sourcing (mathiasbynens#864) .bash_profile: Improve `g` autocompletion brew.sh: Update PHP formulae (mathiasbynens#859)
2 parents e6a8d5b + c886e13 commit c378b62

File tree

11 files changed

+118
-94
lines changed

11 files changed

+118
-94
lines changed

.aliases

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && k
120120
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
121121
alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"'
122122

123-
# Merge PDF files
124-
# Usage: `mergepdf -o output.pdf input{1,2,3}.pdf`
125-
alias mergepdf='/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py'
123+
# Merge PDF files, preserving hyperlinks
124+
# Usage: `mergepdf input{1,2,3}.pdf`
125+
alias mergepdf='gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=_merged.pdf'
126126

127127
# Disable Spotlight
128128
alias spotoff="sudo mdutil -a -i off"
@@ -145,9 +145,6 @@ for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
145145
alias "${method}"="lwp-request -m '${method}'"
146146
done
147147

148-
# Make Grunt print stack traces by default
149-
command -v grunt > /dev/null && alias grunt="grunt --stack"
150-
151148
# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
152149
alias stfu="osascript -e 'set volume output muted true'"
153150
alias pumpitup="osascript -e 'set volume output volume 100'"

.bash_profile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ done;
2929
export HOMEBREW_NO_ANALYTICS=1
3030

3131
# Add tab completion for many Bash commands
32-
if which brew &> /dev/null && [ -f "$(brew --prefix)/share/bash-completion/bash_completion" ]; then
33-
source "$(brew --prefix)/share/bash-completion/bash_completion";
32+
if which brew &> /dev/null && [ -r "$(brew --prefix)/etc/profile.d/bash_completion.sh" ]; then
33+
# Ensure existing Homebrew v1 completions continue to work
34+
export BASH_COMPLETION_COMPAT_DIR="$(brew --prefix)/etc/bash_completion.d";
35+
source "$(brew --prefix)/etc/profile.d/bash_completion.sh";
3436
elif [ -f /etc/bash_completion ]; then
3537
source /etc/bash_completion;
3638
fi;
3739

3840
# Enable tab completion for `g` by marking it as an alias for `git`
39-
if type _git &> /dev/null && [ -f /usr/local/etc/bash_completion.d/git-completion.bash ]; then
41+
if type _git &> /dev/null; then
4042
complete -o default -o nospace -F _git g;
4143
fi;
4244

.bash_prompt

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,49 +14,45 @@ prompt_git() {
1414
local branchName='';
1515

1616
# Check if the current directory is in a Git repository.
17-
if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then
18-
19-
# check if the current directory is in .git before running git checks
20-
if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then
21-
22-
# Ensure the index is up to date.
23-
git update-index --really-refresh -q &>/dev/null;
24-
25-
# Check for uncommitted changes in the index.
26-
if ! $(git diff --quiet --ignore-submodules --cached); then
27-
s+='+';
28-
fi;
29-
30-
# Check for unstaged changes.
31-
if ! $(git diff-files --quiet --ignore-submodules --); then
32-
s+='!';
33-
fi;
34-
35-
# Check for untracked files.
36-
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
37-
s+='?';
38-
fi;
39-
40-
# Check for stashed files.
41-
if $(git rev-parse --verify refs/stash &>/dev/null); then
42-
s+='$';
43-
fi;
44-
17+
git rev-parse --is-inside-work-tree &>/dev/null || return;
18+
19+
# Check for what branch we’re on.
20+
# Get the short symbolic ref. If HEAD isn’t a symbolic ref, get a
21+
# tracking remote branch or tag. Otherwise, get the
22+
# short SHA for the latest commit, or give up.
23+
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
24+
git describe --all --exact-match HEAD 2> /dev/null || \
25+
git rev-parse --short HEAD 2> /dev/null || \
26+
echo '(unknown)')";
27+
28+
# Early exit for Chromium & Blink repo, as the dirty check takes too long.
29+
# Thanks, @paulirish!
30+
# https://github.com/paulirish/dotfiles/blob/dd33151f/.bash_prompt#L110-L123
31+
repoUrl="$(git config --get remote.origin.url)";
32+
if grep -q 'chromium/src.git' <<< "${repoUrl}"; then
33+
s+='*';
34+
else
35+
# Check for uncommitted changes in the index.
36+
if ! $(git diff --quiet --ignore-submodules --cached); then
37+
s+='+';
4538
fi;
39+
# Check for unstaged changes.
40+
if ! $(git diff-files --quiet --ignore-submodules --); then
41+
s+='!';
42+
fi;
43+
# Check for untracked files.
44+
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
45+
s+='?';
46+
fi;
47+
# Check for stashed files.
48+
if $(git rev-parse --verify refs/stash &>/dev/null); then
49+
s+='$';
50+
fi;
51+
fi;
4652

47-
# Get the short symbolic ref.
48-
# If HEAD isn’t a symbolic ref, get the short SHA for the latest commit
49-
# Otherwise, just give up.
50-
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
51-
git rev-parse --short HEAD 2> /dev/null || \
52-
echo '(unknown)')";
53-
54-
[ -n "${s}" ] && s=" [${s}]";
53+
[ -n "${s}" ] && s=" [${s}]";
5554

56-
echo -e "${1}${branchName}${2}${s}";
57-
else
58-
return;
59-
fi;
55+
echo -e "${1}${branchName}${2}${s}";
6056
}
6157

6258
if tput setaf 1 &> /dev/null; then

.config/git/template/HEAD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref: refs/heads/main

.exports

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ export MANPAGER='less -X';
3232
# Avoid issues with `gpg` as installed via Homebrew.
3333
# https://stackoverflow.com/a/42265848/96656
3434
export GPG_TTY=$(tty);
35+
36+
# Hide the “default interactive shell is now zsh” warning on macOS.
37+
export BASH_SILENCE_DEPRECATION_WARNING=1;

.gitconfig

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
1414

1515
# Pull in remote changes for the current repository and all its submodules
16-
p = !"git pull; git submodule foreach git pull origin master"
16+
p = pull --recurse-submodules
1717

1818
# Clone a repository including all submodules
1919
c = clone --recursive
@@ -56,7 +56,7 @@
5656
# Find commits by commit message
5757
fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f"
5858

59-
# Remove branches that have already been merged with master
59+
# Remove branches that have already been merged with main
6060
# a.k.a. ‘delete merged’
6161
dm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
6262

@@ -79,6 +79,9 @@
7979
fi \
8080
}; f"
8181
82+
# Show the user email for the current repository.
83+
whoami = config user.email
84+
8285
[apply]
8386
8487
# Detect whitespace errors when applying a patch
@@ -185,3 +188,7 @@
185188
[url "git://gist.github.com/"]
186189
187190
insteadOf = "gist:"
191+
192+
[init]
193+
194+
templateDir = ~/.config/git/template/

.macos

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
2222
#sudo scutil --set LocalHostName "0x6D746873"
2323
#sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "0x6D746873"
2424

25-
# Set standby delay to 24 hours (default is 1 hour)
26-
sudo pmset -a standbydelay 86400
27-
2825
# Disable the sound effects on boot
2926
sudo nvram SystemAudioVolume=" "
3027

@@ -96,12 +93,6 @@ defaults write com.apple.helpviewer DevMode -bool true
9693
# in the login window
9794
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
9895

99-
# Restart automatically if the computer freezes
100-
sudo systemsetup -setrestartfreeze on
101-
102-
# Never go into computer sleep mode
103-
#sudo systemsetup -setcomputersleep Off > /dev/null
104-
10596
# Disable Notification Center and remove the menu bar icon
10697
#launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist 2> /dev/null
10798

@@ -126,20 +117,6 @@ defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
126117
#sudo rm -rf /System/Library/CoreServices/DefaultDesktop.jpg
127118
#sudo ln -s /path/to/your/image /System/Library/CoreServices/DefaultDesktop.jpg
128119

129-
###############################################################################
130-
# SSD-specific tweaks #
131-
###############################################################################
132-
133-
# Disable hibernation (speeds up entering sleep mode)
134-
sudo pmset -a hibernatemode 0
135-
136-
# Remove the sleep image file to save disk space
137-
sudo rm /private/var/vm/sleepimage
138-
# Create a zero-byte file instead…
139-
sudo touch /private/var/vm/sleepimage
140-
# …and make sure it can’t be rewritten
141-
sudo chflags uchg /private/var/vm/sleepimage
142-
143120
###############################################################################
144121
# Trackpad, mouse, keyboard, Bluetooth accessories, and input #
145122
###############################################################################
@@ -172,14 +149,11 @@ defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144
172149
defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true
173150

174151
# Disable press-and-hold for keys in favor of key repeat
175-
#defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
176-
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool true
152+
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
177153

178154
# Set a blazingly fast keyboard repeat rate
179-
#defaults write NSGlobalDomain KeyRepeat -int 1
180-
#defaults write NSGlobalDomain InitialKeyRepeat -int 10
181-
defaults write NSGlobalDomain KeyRepeat -int 6
182-
defaults write NSGlobalDomain InitialKeyRepeat -int 25
155+
defaults write NSGlobalDomain KeyRepeat -int 1
156+
defaults write NSGlobalDomain InitialKeyRepeat -int 10
183157

184158
# Set language and text formats
185159
# Note: if you’re in the US, replace `EUR` with `USD`, `Centimeters` with
@@ -193,11 +167,52 @@ defaults write NSGlobalDomain AppleMetricUnits -bool false
193167
sudo defaults write /Library/Preferences/com.apple.loginwindow showInputMenu -bool true
194168

195169
# Set the timezone; see `sudo systemsetup -listtimezones` for other values
196-
systemsetup -settimezone "America/Los_Angeles" > /dev/null
170+
systemsetup -settimezone "America/Denver" > /dev/null
197171

198172
# Stop iTunes from responding to the keyboard media keys
199173
#launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist 2> /dev/null
200174

175+
###############################################################################
176+
# Energy saving #
177+
###############################################################################
178+
179+
# Enable lid wakeup
180+
sudo pmset -a lidwake 1
181+
182+
# Restart automatically on power loss
183+
sudo pmset -a autorestart 1
184+
185+
# Restart automatically if the computer freezes
186+
sudo systemsetup -setrestartfreeze on
187+
188+
# Sleep the display after 15 minutes
189+
sudo pmset -a displaysleep 15
190+
191+
# Disable machine sleep while charging
192+
sudo pmset -c sleep 0
193+
194+
# Set machine sleep to 5 minutes on battery
195+
sudo pmset -b sleep 5
196+
197+
# Set standby delay to 24 hours (default is 1 hour)
198+
sudo pmset -a standbydelay 86400
199+
200+
# Never go into computer sleep mode
201+
sudo systemsetup -setcomputersleep Off > /dev/null
202+
203+
# Hibernation mode
204+
# 0: Disable hibernation (speeds up entering sleep mode)
205+
# 3: Copy RAM to disk so the system state can still be restored in case of a
206+
# power failure.
207+
sudo pmset -a hibernatemode 0
208+
209+
# Remove the sleep image file to save disk space
210+
sudo rm /private/var/vm/sleepimage
211+
# Create a zero-byte file instead…
212+
sudo touch /private/var/vm/sleepimage
213+
# …and make sure it can’t be rewritten
214+
sudo chflags uchg /private/var/vm/sleepimage
215+
201216
###############################################################################
202217
# Screen #
203218
###############################################################################
@@ -311,7 +326,7 @@ defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
311326
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
312327

313328
# Use list view in all Finder windows by default
314-
# Four-letter codes for the other view modes: `icnv`, `clmv`, `Flwv`
329+
# Four-letter codes for the other view modes: `icnv`, `clmv`, `glyv`
315330
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
316331

317332
# Disable the warning before emptying the Trash
@@ -321,7 +336,7 @@ defaults write com.apple.finder WarnOnEmptyTrash -bool false
321336
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
322337

323338
# Show the ~/Library folder
324-
chflags nohidden ~/Library
339+
chflags nohidden ~/Library && xattr -d com.apple.FinderInfo ~/Library
325340

326341
# Show the /Volumes folder
327342
sudo chflags nohidden /Volumes
@@ -427,6 +442,7 @@ sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/Simulator (
427442
# 10: Put display to sleep
428443
# 11: Launchpad
429444
# 12: Notification Center
445+
# 13: Lock Screen
430446
# Top left screen corner → Mission Control
431447
defaults write com.apple.dock wvous-tl-corner -int 2
432448
defaults write com.apple.dock wvous-tl-modifier -int 0
@@ -508,6 +524,7 @@ defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebK
508524
# Disable Java
509525
defaults write com.apple.Safari WebKitJavaEnabled -bool false
510526
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaEnabled -bool false
527+
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaEnabledForLocalFiles -bool false
511528

512529
# Block pop-up windows
513530
defaults write com.apple.Safari WebKitJavaScriptCanOpenWindowsAutomatically -bool false

.osx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# 301 https://github.com/mathiasbynens/dotfiles/blob/master/.macos
1+
# 301 https://github.com/mathiasbynens/dotfiles/blob/main/.macos

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ To update later on, just run that command again.
3838

3939
### Specify the `$PATH`
4040

41-
If `~/.path` exists, it will be sourced along with the other files, before any feature testing takes place.
41+
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.
4242

4343
Here’s an example `~/.path` file that adds `/usr/local/bin` to the `$PATH`:
4444

@@ -81,7 +81,8 @@ When setting up a new Mac, you may want to install some common [Homebrew](https:
8181
./brew.sh
8282
```
8383

84-
==== BASE ====
84+
Some of the functionality of these dotfiles depends on formulae installed by `brew.sh`. If you don’t plan to run `brew.sh`, you should look carefully through the script and manually install any particularly important ones. A good example is Bash/Git completion: the dotfiles use a special version from Homebrew.
85+
8586
## Feedback
8687

8788
Suggestions/improvements
@@ -106,8 +107,6 @@ Suggestions/improvements
106107
* [Nicolas Gallagher](http://nicolasgallagher.com/) and his [dotfiles repository](https://github.com/necolas/dotfiles)
107108
* [Sindre Sorhus](https://sindresorhus.com/)
108109
* [Tom Ryder](https://sanctum.geek.nz/) and his [dotfiles repository](https://sanctum.geek.nz/cgit/dotfiles.git/about)
109-
==== BASE ====
110-
* [Kevin Suttle](http://kevinsuttle.com/) and his [dotfiles repository](https://github.com/kevinSuttle/dotfiles) and [OSXDefaults project](https://github.com/kevinSuttle/OSXDefaults), which aims to provide better documentation for [`~/.macos`](https://mths.be/macos)
111-
* [Haralan Dobrev](http://hkdobrev.com/)
112-
* anyone who [contributed a patch](https://github.com/mathiasbynens/dotfiles/contributors) or [made a helpful suggestion](https://github.com/mathiasbynens/dotfiles/issues)
113-
==== BASE ====
110+
* [Kevin Suttle](http://kevinsuttle.com/) and his [dotfiles repository](https://github.com/kevinSuttle/dotfiles) and [macOS-Defaults project](https://github.com/kevinSuttle/macOS-Defaults), which aims to provide better documentation for [`~/.macos`](https://mths.be/macos)
111+
* [Haralan Dobrev](https://hkdobrev.com/)
112+
* Anyone who [contributed a patch](https://github.com/mathiasbynens/dotfiles/contributors) or [made a helpful suggestion](https://github.com/mathiasbynens/dotfiles/issues)

bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
cd "$(dirname "${BASH_SOURCE}")";
44

5-
git pull origin master;
5+
git pull origin main;
66

77
function doIt() {
88
rsync --exclude ".git/" \

0 commit comments

Comments
 (0)