Skip to content

Commit c2fa2cb

Browse files
author
Jeff Walter
committed
* 'master' of https://github.com/mathiasbynens/dotfiles: (249 commits) 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) .aliases: Update comment for `la` .tmux.conf: Use Ctrl+A as the prefix key Respect non-default brew installation locations ...
2 parents 606c54b + c886e13 commit c2fa2cb

36 files changed

+2827
-2029
lines changed

.aliases

Lines changed: 42 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 ../.."
@@ -12,83 +14,85 @@ alias dl="cd ~/Downloads"
1214
alias dt="cd ~/Desktop"
1315
alias p="cd ~/projects"
1416
alias g="git"
15-
alias h="history"
16-
alias j="jobs"
1717

1818
# Detect which `ls` flavor is in use
1919
if ls --color > /dev/null 2>&1; then # GNU `ls`
2020
colorflag="--color"
21-
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`
2223
colorflag="-G"
24+
export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx'
2325
fi
2426

2527
# List all files colorized in long format
2628
alias l="ls -lF ${colorflag}"
2729

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

3133
# List only directories
3234
alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
3335

3436
# Always use color output for `ls`
3537
alias ls="command ls ${colorflag}"
36-
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'
3744

3845
# Enable aliases to be sudo’ed
3946
alias sudo='sudo '
4047

41-
# Gzip-enabled `curl`
42-
alias gurl='curl --compressed'
43-
4448
# Get week number
4549
alias week='date +%V'
4650

47-
# Stopwatch
48-
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
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'
4953

50-
# Get OS X Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
51-
alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm update npm -g; npm update -g; sudo gem update --system; 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'
5257

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

58-
# Enhanced WHOIS lookups
59-
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'"
6065

6166
# Flush Directory Service cache
6267
alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"
6368

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

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

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

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

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

8389
# Recursively delete `.DS_Store` files
8490
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
8591

86-
# ROT13-encode text. Works for decoding, too! ;)
87-
alias rot13='tr a-zA-Z n-za-mN-ZA-M'
88-
89-
# Empty the Trash on all mounted volumes and the main HDD
90-
# Also, clear Apple’s System Logs to improve shell startup speed
91-
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'"
9296

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

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

108112
# Disable Spotlight
109113
alias spotoff="sudo mdutil -a -i off"
@@ -113,9 +117,8 @@ alias spoton="sudo mdutil -a -i on"
113117
# PlistBuddy alias, because sometimes `defaults` just doesn’t cut it
114118
alias plistbuddy="/usr/libexec/PlistBuddy"
115119

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

120123
# Intuitive map function
121124
# For example, to list all directories that contain a certain file:
@@ -124,16 +127,12 @@ alias map="xargs -n1"
124127

125128
# One of @janmoesen’s ProTip™s
126129
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
127-
alias "$method"="lwp-request -m '$method'"
130+
alias "${method}"="lwp-request -m '${method}'"
128131
done
129132

130-
# Make Grunt print stack traces by default
131-
command -v grunt > /dev/null && alias grunt="grunt --stack"
132-
133133
# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
134134
alias stfu="osascript -e 'set volume output muted true'"
135-
alias pumpitup="osascript -e 'set volume 7'"
136-
alias hax="growlnotify -a 'Activity Monitor' 'System error' -m 'WTF R U DOIN'"
135+
alias pumpitup="osascript -e 'set volume output volume 100'"
137136

138137
# Kill all the tabs in Chrome to free up memory
139138
# [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
@@ -143,7 +142,7 @@ alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v exten
143142
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
144143

145144
# Reload the shell (i.e. invoke as a login shell)
146-
alias reload="exec $SHELL -l"
145+
alias reload="exec ${SHELL} -l"
147146

148-
# Faster npm for europeans
149-
command -v npm > /dev/null && alias npme="npm --registry http://registry.npmjs.eu"
147+
# Print each PATH entry on a separate line
148+
alias path='echo -e ${PATH//:/\\n}'

.bash_profile

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,50 @@
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,exports,aliases,functions,extra}; do
8-
[ -r "$file" ] && [ -f "$file" ] && source "$file"
9-
done
10-
unset file
8+
[ -r "$file" ] && [ -f "$file" ] && source "$file";
9+
done;
10+
unset file;
1111

1212
# Case-insensitive globbing (used in pathname expansion)
13-
shopt -s nocaseglob
13+
shopt -s nocaseglob;
1414

1515
# Append to the Bash history file, rather than overwriting it
16-
shopt -s histappend
16+
shopt -s histappend;
1717

1818
# Autocorrect typos in path names when using `cd`
19-
shopt -s cdspell
19+
shopt -s cdspell;
2020

2121
# Enable some Bash 4 features when possible:
2222
# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux`
2323
# * Recursive globbing, e.g. `echo **/*.txt`
2424
for option in autocd globstar; do
25-
shopt -s "$option" 2> /dev/null
26-
done
25+
shopt -s "$option" 2> /dev/null;
26+
done;
27+
28+
# Add tab completion for many Bash commands
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";
33+
elif [ -f /etc/bash_completion ]; then
34+
source /etc/bash_completion;
35+
fi;
36+
37+
# Enable tab completion for `g` by marking it as an alias for `git`
38+
if type _git &> /dev/null; then
39+
complete -o default -o nospace -F _git g;
40+
fi;
2741

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

3145
# Add tab completion for `defaults read|write NSGlobalDomain`
3246
# You could just use `-g` instead, but I like being explicit
33-
complete -W "NSGlobalDomain" defaults
47+
complete -W "NSGlobalDomain" defaults;
3448

3549
# Add `killall` tab completion for common apps
36-
complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall
37-
38-
# If possible, add tab completion for many more commands
39-
[ -f /etc/bash_completion ] && source /etc/bash_completion
50+
complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall;

0 commit comments

Comments
 (0)