Skip to content

Commit 137f1a5

Browse files
committed
* 'main' of https://github.com/mathiasbynens/dotfiles: (57 commits) 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 .bash_profile: Update bash-completion sourcing (mathiasbynens#864) ... # Conflicts: # .aliases # .functions # .macos # .osx
2 parents f0dcc1c + 66ba9b3 commit 137f1a5

File tree

15 files changed

+322
-282
lines changed

15 files changed

+322
-282
lines changed

.aliases

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ alias dl="cd ~/Downloads"
2727
alias dt="cd ~/Desktop"
2828
alias p="cd ~/projects"
2929
alias g="git"
30-
alias h="history"
31-
alias j="jobs"
3230
alias e=s
3331

3432
# Detect which `ls` flavor is in use
@@ -43,8 +41,8 @@ fi
4341
# List all files colorized in long format
4442
alias l="ls -lF ${colorflag}"
4543

46-
# List all files colorized in long format, including dot files
47-
alias la="ls -laF ${colorflag}"
44+
# List all files colorized in long format, excluding . and ..
45+
alias la="ls -lAF ${colorflag}"
4846

4947
# List only directories
5048
alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
@@ -64,14 +62,12 @@ alias sudo='sudo '
6462
# Get week number
6563
alias week='date +%V'
6664

67-
# Stopwatch
68-
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
69-
7065
# Get macOS Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
7166
alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm install npm -g; npm update -g; sudo gem update --system; sudo gem update; sudo gem cleanup'
7267

7368
# Google Chrome
7469
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
70+
alias canary='/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'
7571

7672
# IP addresses
7773
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
@@ -87,10 +83,6 @@ alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"
8783
# Clean up LaunchServices to remove duplicates in the “Open With” menu
8884
alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
8985

90-
# View HTTP traffic
91-
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
92-
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
93-
9486
# Canonical hex dump; some systems have this symlinked
9587
command -v hd > /dev/null || alias hd="hexdump -C"
9688

@@ -127,9 +119,9 @@ alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && k
127119
# URL-encode strings
128120
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
129121

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

134126
# Disable Spotlight
135127
alias spotoff="sudo mdutil -a -i off"
@@ -142,23 +134,16 @@ alias plistbuddy="/usr/libexec/PlistBuddy"
142134
# Airport CLI alias
143135
alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport'
144136

145-
# Ring the terminal bell, and put a badge on Terminal.app’s Dock icon
146-
# (useful when executing time-consuming commands)
147-
alias badge="tput bel"
148-
149137
# Intuitive map function
150138
# For example, to list all directories that contain a certain file:
151139
# find . -name .gitattributes | map dirname
152140
alias map="xargs -n1"
153141

154142
# One of @janmoesen’s ProTip™s
155143
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
156-
alias "$method"="lwp-request -m '$method'"
144+
alias "${method}"="lwp-request -m '${method}'"
157145
done
158146

159-
# Make Grunt print stack traces by default
160-
command -v grunt > /dev/null && alias grunt="grunt --stack"
161-
162147
# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
163148
alias stfu="osascript -e 'set volume output muted true'"
164149
alias pumpitup="osascript -e 'set volume output volume 100'"
@@ -184,7 +169,7 @@ alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v exten
184169
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
185170

186171
# Reload the shell (i.e. invoke as a login shell)
187-
alias reload="exec $SHELL -l"
172+
alias reload="exec ${SHELL} -l"
188173

189174
# Print each PATH entry on a separate line
190175
alias path='echo -e ${PATH//:/\\n}'

.bash_profile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ for option in autocd globstar; do
3030
done;
3131

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

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

.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

.exports

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,10 @@ export LESS_TERMCAP_md="${yellow}";
2828

2929
# Don’t clear the screen after quitting a manual page.
3030
export MANPAGER='less -X';
31+
32+
# Avoid issues with `gpg` as installed via Homebrew.
33+
# https://stackoverflow.com/a/42265848/96656
34+
export GPG_TTY=$(tty);
35+
36+
# Hide the “default interactive shell is now zsh” warning on macOS.
37+
export BASH_SILENCE_DEPRECATION_WARNING=1;

.functions

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,6 @@ function dataurl() {
7575
echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')";
7676
}
7777

78-
# Create a git.io short URL
79-
function gitio() {
80-
if [ -z "${1}" -o -z "${2}" ]; then
81-
echo "Usage: \`gitio slug url\`";
82-
return 1;
83-
fi;
84-
curl -i https://git.io/ -F "url=${2}" -F "code=${1}";
85-
}
86-
8778
# Create .gitignore file using gitignore.io
8879
function gi() {
8980
curl -L -s https://www.gitignore.io/api/$@ ;
@@ -116,48 +107,11 @@ function gz() {
116107
printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio";
117108
}
118109

119-
# Syntax-highlight JSON strings or files
120-
# Usage: `json '{"foo":42}'` or `echo '{"foo":42}' | json`
121-
function json() {
122-
if [ -t 0 ]; then # argument
123-
python -mjson.tool <<< "$*" | pygmentize -l javascript;
124-
else # pipe
125-
python -mjson.tool | pygmentize -l javascript;
126-
fi;
127-
}
128-
129110
# Run `dig` and display the most useful info
130111
function digga() {
131112
dig +nocmd "$1" any +multiline +noall +answer;
132113
}
133114

134-
# UTF-8-encode a string of Unicode symbols
135-
function escape() {
136-
printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u);
137-
# print a newline unless we’re piping the output to another program
138-
if [ -t 1 ]; then
139-
echo ""; # newline
140-
fi;
141-
}
142-
143-
# Decode \x{ABCD}-style Unicode escape sequences
144-
function unidecode() {
145-
perl -e "binmode(STDOUT, ':utf8'); print \"$@\"";
146-
# print a newline unless we’re piping the output to another program
147-
if [ -t 1 ]; then
148-
echo ""; # newline
149-
fi;
150-
}
151-
152-
# Get a character’s Unicode code point
153-
function codepoint() {
154-
perl -e "use utf8; print sprintf('U+%04X', ord(\"$@\"))";
155-
# print a newline unless we’re piping the output to another program
156-
if [ -t 1 ]; then
157-
echo ""; # newline
158-
fi;
159-
}
160-
161115
# Show all the names (CNs and SANs) listed in the SSL certificate
162116
# for a given domain
163117
function getcertnames() {
@@ -210,16 +164,6 @@ function s() {
210164
fi;
211165
}
212166

213-
# `v` with no arguments opens the current directory in Vim, otherwise opens the
214-
# given location
215-
function v() {
216-
if [ $# -eq 0 ]; then
217-
vim .;
218-
else
219-
vim "$@";
220-
fi;
221-
}
222-
223167
# `o` with no arguments opens the current directory, otherwise opens the given
224168
# location
225169
function o() {

0 commit comments

Comments
 (0)