Skip to content

Commit cc01922

Browse files
committed
Merge remote-tracking branch 'matiasbynens/main'
* matiasbynens/main: readme: fix link to lri’s old notes .macos: adjust toolbar title rollover delay .gitconfig: Rely on Git v2.28’s `init.defaultBranch` .gitconfig: delete `mpr` alias .gitconfig: show most recent branches first 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
2 parents 912994c + 66ba9b3 commit cc01922

File tree

7 files changed

+129
-120
lines changed

7 files changed

+129
-120
lines changed

.aliases

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && k
105105
# URL-encode strings
106106
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
107107

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

112112
# Disable Spotlight
113113
alias spotoff="sudo mdutil -a -i off"
@@ -130,9 +130,6 @@ for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
130130
alias "${method}"="lwp-request -m '${method}'"
131131
done
132132

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

.bash_prompt

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

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

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

58-
echo -e "${1}${branchName}${2}${s}";
59-
else
60-
return;
61-
fi;
57+
echo -e "${1}${branchName}${2}${s}";
6258
}
6359

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

.gitconfig

Lines changed: 36 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
[alias]
22

3-
# View abbreviated SHA, description, and history graph of the latest 20 commits
3+
# View abbreviated SHA, description, and history graph of the latest 20 commits.
44
l = log --pretty=oneline -n 20 --graph --abbrev-commit
55

6-
# View the current working tree status using the short format
6+
# View the current working tree status using the short format.
77
s = status -s
88

9-
# Show the diff between the latest commit and the current state
9+
# Show the diff between the latest commit and the current state.
1010
d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
1111

12-
# `git di $number` shows the diff between the state `$number` revisions ago and the current state
12+
# `git di $number` shows the diff between the state `$number` revisions ago and the current state.
1313
di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
1414

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

18-
# Clone a repository including all submodules
18+
# Clone a repository including all submodules.
1919
c = clone --recursive
2020

21-
# Commit all changes
21+
# Commit all changes.
2222
ca = !git add -A && git commit -av
2323

24-
# Switch to a branch, creating it if necessary
24+
# Switch to a branch, creating it if necessary.
2525
go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f"
2626

2727
# Show verbose output about tags, branches or remotes
2828
tags = tag -l
29-
branches = branch -a
30-
remotes = remote -v
29+
branches = branch --all
30+
remotes = remote --verbose
3131

32-
# List aliases
32+
# List aliases.
3333
aliases = config --get-regexp alias
3434

35-
# Amend the currently staged files to the latest commit
35+
# Amend the currently staged files to the latest commit.
3636
amend = commit --amend --reuse-message=HEAD
3737

38-
# Credit an author on the latest commit
38+
# Credit an author on the latest commit.
3939
credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f"
4040

41-
# Interactive rebase with the given number of latest commits
41+
# Interactive rebase with the given number of latest commits.
4242
reb = "!r() { git rebase -i HEAD~$1; }; r"
4343

4444
# Remove the old tag with this name and tag the latest commit with it.
@@ -56,46 +56,38 @@
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

63-
# List contributors with number of commits
63+
# List contributors with number of commits.
6464
contributors = shortlog --summary --numbered
6565

66-
# Merge GitHub pull request on top of the current branch or,
67-
# if a branch name is specified, on top of the specified branch
68-
mpr = "!f() { \
69-
declare currentBranch=\"$(git symbolic-ref --short HEAD)\"; \
70-
declare branch=\"${2:-$currentBranch}\"; \
71-
if [ $(printf \"%s\" \"$1\" | grep '^[0-9]\\+$' > /dev/null; printf $?) -eq 0 ]; then \
72-
git fetch origin refs/pull/$1/head:pr/$1 && \
73-
git checkout -B $branch && \
74-
git rebase $branch pr/$1 && \
75-
git checkout -B $branch && \
76-
git merge pr/$1 && \
77-
git branch -D pr/$1 && \
78-
git commit --amend -m \"$(git log -1 --pretty=%B)\n\nCloses #$1.\"; \
79-
fi \
80-
}; f"
66+
# Show the user email for the current repository.
67+
whoami = config user.email
8168

8269
[apply]
8370

84-
# Detect whitespace errors when applying a patch
85-
whitespace = warn
71+
# Detect whitespace errors when applying a patch.
72+
whitespace = fix
73+
74+
[branch]
75+
76+
# Show most recently changed branches first.
77+
sort = -committerdate
8678

8779
[core]
8880

89-
# Use custom `.gitignore` and `.gitattributes`
81+
# Use custom `.gitignore` and `.gitattributes`.
9082
excludesfile = ~/.gitignore
9183
attributesfile = ~/.gitattributes
9284

93-
# Treat spaces before tabs and all kinds of trailing whitespace as an error
85+
# Treat spaces before tabs and all kinds of trailing whitespace as an error.
9486
# [default] trailing-space: looks for spaces at the end of a line
9587
# [default] space-before-tab: looks for spaces before tabs at the beginning of a line
9688
whitespace = space-before-tab,-indent-with-non-tab,trailing-space
9789

98-
# Make `git rebase` safer on macOS
90+
# Make `git rebase` safer on macOS.
9991
# More info: <http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/>
10092
trustctime = false
10193
editor = vim
@@ -145,24 +137,20 @@
145137

146138
[diff]
147139

148-
# Detect copies as well as renames
140+
# Detect copies as well as renames.
149141
renames = copies
150142

151143

152144
[diff "bin"]
153145

154-
# Use `hexdump` to diff binary files
146+
# Use `hexdump` to diff binary files.
155147
textconv = hexdump -v -C
156148

157149
[help]
158150

159-
# Automatically correct and execute mistyped commands
151+
# Automatically correct and execute mistyped commands.
160152
autocorrect = 1
161153

162-
[init]
163-
164-
defaultBranch = main
165-
166154
[mergetool "studio"]
167155

168156
cmd = studio merge "$REMOTE" "$BASE" "$MERGED"
@@ -172,7 +160,6 @@
172160

173161
# Include summaries of merged commits in newly created merge commit messages
174162
log = true
175-
tool = studio
176163

177164
[pull]
178165

@@ -213,3 +200,7 @@
213200
214201
name = Steven Mulder
215202
signingkey = 5B2157118E7AAAE6A50038B99C4464455D019245
203+
204+
[init]
205+
206+
defaultBranch = main

0 commit comments

Comments
 (0)