Skip to content

Commit f2fe7ae

Browse files
committed
Merge branch 'master' of https://github.com/sorodrigo/dotfiles
* 'master' of https://github.com/sorodrigo/dotfiles: (46 commits) update bash-completion@2 fix: revert main branch mods git checkout alias Update README.md updates .gitconfig aliases updates brew.sh + disables gpg signing update 2023 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) ...
2 parents 1d1c098 + d24cf31 commit f2fe7ae

File tree

16 files changed

+239
-238
lines changed

16 files changed

+239
-238
lines changed

.aliases

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,6 @@
33
# Easier navigation: .., ..., ...., ....., ~ and -
44
alias ..="cd .."
55
alias ...="cd ../.."
6-
# alias ....="cd ../../.."
7-
# alias .....="cd ../../../.."
8-
# alias ~="cd ~" # `cd` is probably faster to type though
9-
# alias -- -="cd -"
10-
11-
# Shortcuts
12-
# alias d="cd ~/Documents/Dropbox"
13-
# alias dl="cd ~/Downloads"
14-
# alias dt="cd ~/Desktop"
15-
# alias p="cd ~/projects"
16-
# alias g="git"
17-
# alias h="history"
18-
# alias j="jobs"
196

207
# Detect which `ls` flavor is in use
218
if ls --color > /dev/null 2>&1; then # GNU `ls`
@@ -29,8 +16,8 @@ fi
2916
# List all files colorized in long format
3017
alias l="ls -lF ${colorflag}"
3118

32-
# List all files colorized in long format, including dot files
33-
alias la="ls -laF ${colorflag}"
19+
# List all files colorized in long format, excluding . and ..
20+
alias la="ls -lAF ${colorflag}"
3421

3522
# List only directories
3623
alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
@@ -50,15 +37,11 @@ alias sudo='sudo '
5037
# Get week number
5138
alias week='date +%V'
5239

53-
# Stopwatch
54-
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
55-
5640
# Get macOS Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
5741
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'
5842

5943
# Google Chrome
6044
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
61-
# alias canary='/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'
6245

6346
# IP addresses
6447
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
@@ -68,16 +51,9 @@ alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[
6851
# Show active network interfaces
6952
alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'"
7053

71-
# Flush Directory Service cache
72-
# alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"
73-
7454
# Clean up LaunchServices to remove duplicates in the “Open With” menu
7555
# alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
7656

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

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

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

12197
# Disable Spotlight
12298
alias spotoff="sudo mdutil -a -i off"
@@ -129,23 +105,16 @@ alias plistbuddy="/usr/libexec/PlistBuddy"
129105
# Airport CLI alias
130106
# alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport'
131107

132-
# Ring the terminal bell, and put a badge on Terminal.app’s Dock icon
133-
# (useful when executing time-consuming commands)
134-
# alias badge="tput bel"
135-
136108
# Intuitive map function
137109
# For example, to list all directories that contain a certain file:
138110
# find . -name .gitattributes | map dirname
139111
alias map="xargs -n1"
140112

141113
# One of @janmoesen’s ProTip™s
142114
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
143-
alias "$method"="lwp-request -m '$method'"
115+
alias "${method}"="lwp-request -m '${method}'"
144116
done
145117

146-
# Make Grunt print stack traces by default
147-
command -v grunt > /dev/null && alias grunt="grunt --stack"
148-
149118
# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
150119
# alias stfu="osascript -e 'set volume output muted true'"
151120
# alias pumpitup="osascript -e 'set volume output volume 100'"
@@ -158,7 +127,7 @@ alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v exten
158127
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
159128

160129
# Reload the shell (i.e. invoke as a login shell)
161-
# alias reload="exec $SHELL -l"
130+
# alias reload="exec ${SHELL} -l"
162131

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

.bash_profile

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

2828
# Add tab completion for many Bash commands
29-
if which brew &> /dev/null && [ -f "$(brew --prefix)/share/bash-completion/bash_completion" ]; then
30-
source "$(brew --prefix)/share/bash-completion/bash_completion";
29+
if which brew &> /dev/null && [ -r "$(brew --prefix)/etc/profile.d/bash_completion.sh" ]; then
30+
# Ensure existing Homebrew v1 completions continue to work
31+
export BASH_COMPLETION_COMPAT_DIR="$(brew --prefix)/etc/bash_completion.d";
32+
source "$(brew --prefix)/etc/profile.d/bash_completion.sh";
3133
elif [ -f /etc/bash_completion ]; then
3234
source /etc/bash_completion;
3335
fi;
3436

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

.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

.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: 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 & 46 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
# Start an HTTP server from a directory, optionally specifying the port
8879
function server() {
8980
local port="${1:-8000}";
@@ -111,48 +102,11 @@ function gz() {
111102
printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio";
112103
}
113104

114-
# Syntax-highlight JSON strings or files
115-
# Usage: `json '{"foo":42}'` or `echo '{"foo":42}' | json`
116-
function json() {
117-
if [ -t 0 ]; then # argument
118-
python -mjson.tool <<< "$*" | pygmentize -l javascript;
119-
else # pipe
120-
python -mjson.tool | pygmentize -l javascript;
121-
fi;
122-
}
123-
124105
# Run `dig` and display the most useful info
125106
function digga() {
126107
dig +nocmd "$1" any +multiline +noall +answer;
127108
}
128109

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

.gitconfig

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

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

2424
# Clone a repository including all submodules
2525
c = clone --recursive
@@ -28,7 +28,7 @@
2828
ca = !git add -A && git commit -av
2929

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

3333
# checkout to branch
3434
co = checkout
@@ -38,6 +38,9 @@
3838
branches = branch -a
3939
remotes = remote -v
4040

41+
# List aliases
42+
aliases = config --get-regexp alias
43+
4144
# Amend the currently staged files to the latest commit
4245
amend = commit --amend --reuse-message=HEAD
4346

@@ -85,6 +88,9 @@
8588
fi \
8689
}; f"
8790
91+
# Show the user email for the current repository.
92+
whoami = config user.email
93+
8894
[apply]
8995
9096
# Detect whitespace errors when applying a patch
@@ -109,6 +115,10 @@
109115
# http://michael-kuehnel.de/git/2014/11/21/git-mac-osx-and-german-umlaute.html
110116
precomposeunicode = false
111117
118+
# Speed up commands involving untracked files such as `git status`.
119+
# https://git-scm.com/docs/git-update-index#_untracked_cache
120+
untrackedCache = true
121+
112122
[color]
113123
114124
# Use colors in Git commands that are capable of colored output when
@@ -143,9 +153,6 @@
143153
144154
# Detect copies as well as renames
145155
renames = copies
146-
# Enable an experimental heuristic that shifts the hunk boundary in an
147-
# attempt to make the resulting patch easier to read.
148-
indentHeuristic = true
149156
150157
[diff "bin"]
151158
@@ -164,10 +171,8 @@
164171
165172
[push]
166173
167-
# Use the Git 1.x.x default to avoid errors on machines with old Git
168-
# installations. To use `simple` instead, add this to your `~/.extra` file:
169-
# `git config --global push.default simple`. See http://git.io/mMah-w.
170-
default = matching
174+
# https://git-scm.com/docs/git-config#git-config-pushdefault
175+
default = simple
171176
# Make `git push` push relevant annotated tags when pushing branches out.
172177
followTags = true
173178
@@ -192,3 +197,7 @@
192197
[url "git://gist.github.com/"]
193198
194199
insteadOf = "gist:"
200+
201+
[init]
202+
203+
templateDir = ~/.config/git/template/

0 commit comments

Comments
 (0)