Skip to content

Commit 6668d60

Browse files
author
Justin Murray
committed
Merge branch 'master' of github.com:mathiasbynens/dotfiles
* 'master' of github.com:mathiasbynens/dotfiles: (374 commits) .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) .aliases: Update comment for `la` .tmux.conf: Use Ctrl+A as the prefix key Respect non-default brew installation locations .aliases: Don’t show `.` and `..` in `la` alias .macos: Don’t show recent applications in Dock ...
2 parents 6af1cba + d600133 commit 6668d60

32 files changed

+3116
-1155
lines changed

.aliases

Lines changed: 59 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
# Easier navigation: .., ..., ...., ....., ~ and -
24
alias ..="cd .."
35
alias ...="cd ../.."
@@ -10,84 +12,87 @@ alias -- -="cd -"
1012
alias d="cd ~/Documents/Dropbox"
1113
alias dl="cd ~/Downloads"
1214
alias dt="cd ~/Desktop"
13-
alias p="cd ~/Projects"
15+
alias p="cd ~/projects"
1416
alias g="git"
15-
alias h="history"
16-
alias j="jobs"
17-
alias v="vim"
18-
alias m="mate ."
19-
alias s="subl ."
20-
alias o="open"
21-
alias oo="open ."
2217

2318
# Detect which `ls` flavor is in use
2419
if ls --color > /dev/null 2>&1; then # GNU `ls`
2520
colorflag="--color"
26-
else # OS X `ls`
21+
export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
22+
else # macOS `ls`
2723
colorflag="-G"
24+
export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx'
2825
fi
2926

3027
# List all files colorized in long format
31-
alias l="ls -l ${colorflag}"
28+
alias l="ls -lF ${colorflag}"
3229

33-
# List all files colorized in long format, including dot files
34-
alias la="ls -la ${colorflag}"
30+
# List all files colorized in long format, excluding . and ..
31+
alias la="ls -lAF ${colorflag}"
3532

3633
# List only directories
37-
alias lsd='ls -l ${colorflag} | grep "^d"'
34+
alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
3835

3936
# Always use color output for `ls`
4037
alias ls="command ls ${colorflag}"
41-
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
38+
39+
# Always enable colored `grep` output
40+
# Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage.
41+
alias grep='grep --color=auto'
42+
alias fgrep='fgrep --color=auto'
43+
alias egrep='egrep --color=auto'
4244

4345
# Enable aliases to be sudo’ed
4446
alias sudo='sudo '
4547

46-
# Gzip-enabled `curl`
47-
alias gurl="curl --compressed"
48+
# Get week number
49+
alias week='date +%V'
50+
51+
# Get macOS Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
52+
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'
4853

49-
# Get OS X Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
50-
alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm update npm -g; npm update -g; sudo gem update'
54+
# Google Chrome
55+
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
56+
alias canary='/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'
5157

5258
# IP addresses
5359
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
54-
alias localip="ipconfig getifaddr en1"
55-
alias ips="ifconfig -a | grep -o 'inet6\? \(\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\|[a-fA-F0-9:]\+\)' | sed -e 's/inet6* //'"
60+
alias localip="ipconfig getifaddr en0"
61+
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
5662

57-
# Enhanced WHOIS lookups
58-
alias whois="whois -h whois-servers.net"
63+
# Show active network interfaces
64+
alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'"
5965

6066
# Flush Directory Service cache
6167
alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"
6268

6369
# Clean up LaunchServices to remove duplicates in the “Open With” menu
6470
alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
6571

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

73-
# OS X has no `md5sum`, so use `md5` as a fallback
75+
# macOS has no `md5sum`, so use `md5` as a fallback
7476
command -v md5sum > /dev/null || alias md5sum="md5"
7577

76-
# OS X has no `sha1sum`, so use `shasum` as a fallback
78+
# macOS has no `sha1sum`, so use `shasum` as a fallback
7779
command -v sha1sum > /dev/null || alias sha1sum="shasum"
7880

81+
# JavaScriptCore REPL
82+
jscbin="/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc";
83+
[ -e "${jscbin}" ] && alias jsc="${jscbin}";
84+
unset jscbin;
85+
7986
# Trim new lines and copy to clipboard
8087
alias c="tr -d '\n' | pbcopy"
8188

8289
# Recursively delete `.DS_Store` files
8390
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
8491

85-
# ROT13-encode text. Works for decoding, too! ;)
86-
alias rot13='tr a-zA-Z n-za-mN-ZA-M'
87-
88-
# Empty the Trash on all mounted volumes and the main HDD
89-
# Also, clear Apple’s System Logs to improve shell startup speed
90-
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl"
92+
# Empty the Trash on all mounted volumes and the main HDD.
93+
# Also, clear Apple’s System Logs to improve shell startup speed.
94+
# Finally, clear download history from quarantine. https://mths.be/bum
95+
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl; sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'"
9196

9297
# Show/hide hidden files in Finder
9398
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
@@ -100,9 +105,9 @@ alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && k
100105
# URL-encode strings
101106
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
102107

103-
# Merge PDF files
104-
# Usage: `mergepdf -o output.pdf input{1,2,3}.pdf`
105-
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'
106111

107112
# Disable Spotlight
108113
alias spotoff="sudo mdutil -a -i off"
@@ -112,9 +117,8 @@ alias spoton="sudo mdutil -a -i on"
112117
# PlistBuddy alias, because sometimes `defaults` just doesn’t cut it
113118
alias plistbuddy="/usr/libexec/PlistBuddy"
114119

115-
# Ring the terminal bell, and put a badge on Terminal.app’s Dock icon
116-
# (useful when executing time-consuming commands)
117-
alias badge="tput bel"
120+
# Airport CLI alias
121+
alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport'
118122

119123
# Intuitive map function
120124
# For example, to list all directories that contain a certain file:
@@ -123,10 +127,22 @@ alias map="xargs -n1"
123127

124128
# One of @janmoesen’s ProTip™s
125129
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
126-
alias "$method"="lwp-request -m '$method'"
130+
alias "${method}"="lwp-request -m '${method}'"
127131
done
128132

129133
# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
130134
alias stfu="osascript -e 'set volume output muted true'"
131-
alias pumpitup="osascript -e 'set volume 7'"
132-
alias hax="growlnotify -a 'Activity Monitor' 'System error' -m 'WTF R U DOIN'"
135+
alias pumpitup="osascript -e 'set volume output volume 100'"
136+
137+
# Kill all the tabs in Chrome to free up memory
138+
# [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
139+
alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill"
140+
141+
# Lock the screen (when going AFK)
142+
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
143+
144+
# Reload the shell (i.e. invoke as a login shell)
145+
alias reload="exec ${SHELL} -l"
146+
147+
# Print each PATH entry on a separate line
148+
alias path='echo -e ${PATH//:/\\n}'

.bash_profile

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# Add `~/bin` to the `$PATH`
2-
export PATH="$HOME/bin:$PATH"
2+
export PATH="$HOME/bin:$PATH";
33

44
# Load the shell dotfiles, and then some:
55
# * ~/.path can be used to extend `$PATH`.
66
# * ~/.extra can be used for other settings you don’t want to commit.
77
for file in ~/.{path,bash_prompt_airline,exports,aliases,functions,extra}; do
8-
[ -r "$file" ] && source "$file"
9-
done
10-
unset file
8+
[ -r "$file" ] && [ -f "$file" ] && source "$file";
9+
done;
10+
unset file;
1111

1212
# Load dircolors
1313
command -v dircolors >/dev/null 2>&1 && { eval `dircolors ~/.dir_colors`; }
1414

1515
# Case-insensitive globbing (used in pathname expansion)
16-
shopt -s nocaseglob
16+
shopt -s nocaseglob;
1717

1818
# Append to the Bash history file, rather than overwriting it
19-
shopt -s histappend
19+
shopt -s histappend;
2020

2121
# Autocorrect typos in path names when using `cd`
22-
shopt -s cdspell
22+
shopt -s cdspell;
2323

2424
# enable vi style command line editing
2525
set -o vi
@@ -28,18 +28,32 @@ set -o vi
2828
# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux`
2929
# * Recursive globbing, e.g. `echo **/*.txt`
3030
for option in autocd globstar; do
31-
shopt -s "$option" 2> /dev/null
32-
done
31+
shopt -s "$option" 2> /dev/null;
32+
done;
33+
34+
# Add tab completion for many Bash commands
35+
if which brew &> /dev/null && [ -r "$(brew --prefix)/etc/profile.d/bash_completion.sh" ]; then
36+
# Ensure existing Homebrew v1 completions continue to work
37+
export BASH_COMPLETION_COMPAT_DIR="$(brew --prefix)/etc/bash_completion.d";
38+
source "$(brew --prefix)/etc/profile.d/bash_completion.sh";
39+
elif [ -f /etc/bash_completion ]; then
40+
source /etc/bash_completion;
41+
fi;
42+
43+
# Enable tab completion for `g` by marking it as an alias for `git`
44+
if type _git &> /dev/null; then
45+
complete -o default -o nospace -F _git g;
46+
fi;
3347

3448
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
35-
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" scp sftp ssh
49+
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2- | tr ' ' '\n')" scp sftp ssh;
3650

3751
# Add tab completion for `defaults read|write NSGlobalDomain`
3852
# You could just use `-g` instead, but I like being explicit
39-
complete -W "NSGlobalDomain" defaults
53+
complete -W "NSGlobalDomain" defaults;
4054

4155
# Add `killall` tab completion for common apps
42-
complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall
56+
complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall;
4357

4458
# If possible, add tab completion for many more commands
4559
[ -f /etc/bash_completion ] && source /etc/bash_completion

0 commit comments

Comments
 (0)