Skip to content

Commit

Permalink
Merge branch 'master' into cmg
Browse files Browse the repository at this point in the history
* master: (54 commits)
  .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
  Normalize `open` across Linux, macOS, and Windows
  .gitconfig: Set `push.default = simple`
  ...
  • Loading branch information
jasonkim-coupang committed Apr 20, 2020
2 parents d82cac3 + 13e29f4 commit 8354ee7
Show file tree
Hide file tree
Showing 14 changed files with 303 additions and 263 deletions.
35 changes: 13 additions & 22 deletions .aliases
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ alias dl="cd ~/Downloads"
alias dt="cd ~/Desktop"
alias p="cd ~/projects"
alias g="git"
alias h="history"
alias j="jobs"

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

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

# List only directories
alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
Expand All @@ -50,12 +48,13 @@ alias sudo='sudo '
# Get week number
alias week='date +%V'

# Stopwatch
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'

# Get macOS Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
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'

# Google Chrome
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
alias canary='/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'

# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en0"
Expand All @@ -70,10 +69,6 @@ alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"
# Clean up LaunchServices to remove duplicates in the “Open With” menu
alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"

# View HTTP traffic
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""

# Canonical hex dump; some systems have this symlinked
command -v hd > /dev/null || alias hd="hexdump -C"

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

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

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

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

# Intuitive map function
# For example, to list all directories that contain a certain file:
Expand All @@ -133,12 +127,9 @@ alias map="xargs -n1"

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

# Make Grunt print stack traces by default
command -v grunt > /dev/null && alias grunt="grunt --stack"

# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
alias stfu="osascript -e 'set volume output muted true'"
alias pumpitup="osascript -e 'set volume output volume 100'"
Expand All @@ -151,7 +142,7 @@ alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v exten
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"

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

# Print each PATH entry on a separate line
alias path='echo -e ${PATH//:/\\n}'
8 changes: 5 additions & 3 deletions .bash_profile
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ for option in autocd globstar; do
done;

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

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

Expand Down
76 changes: 36 additions & 40 deletions .bash_prompt
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,45 @@ prompt_git() {
local branchName='';

# Check if the current directory is in a Git repository.
if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then

# check if the current directory is in .git before running git checks
if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then

# Ensure the index is up to date.
git update-index --really-refresh -q &>/dev/null;

# Check for uncommitted changes in the index.
if ! $(git diff --quiet --ignore-submodules --cached); then
s+='+';
fi;

# Check for unstaged changes.
if ! $(git diff-files --quiet --ignore-submodules --); then
s+='!';
fi;

# Check for untracked files.
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
s+='?';
fi;

# Check for stashed files.
if $(git rev-parse --verify refs/stash &>/dev/null); then
s+='$';
fi;

git rev-parse --is-inside-work-tree &>/dev/null || return;

# Check for what branch we’re on.
# Get the short symbolic ref. If HEAD isn’t a symbolic ref, get a
# tracking remote branch or tag. Otherwise, get the
# short SHA for the latest commit, or give up.
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
git describe --all --exact-match HEAD 2> /dev/null || \
git rev-parse --short HEAD 2> /dev/null || \
echo '(unknown)')";

# Early exit for Chromium & Blink repo, as the dirty check takes too long.
# Thanks, @paulirish!
# https://github.com/paulirish/dotfiles/blob/dd33151f/.bash_prompt#L110-L123
repoUrl="$(git config --get remote.origin.url)";
if grep -q 'chromium/src.git' <<< "${repoUrl}"; then
s+='*';
else
# Check for uncommitted changes in the index.
if ! $(git diff --quiet --ignore-submodules --cached); then
s+='+';
fi;
# Check for unstaged changes.
if ! $(git diff-files --quiet --ignore-submodules --); then
s+='!';
fi;
# Check for untracked files.
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
s+='?';
fi;
# Check for stashed files.
if $(git rev-parse --verify refs/stash &>/dev/null); then
s+='$';
fi;
fi;

# Get the short symbolic ref.
# If HEAD isn’t a symbolic ref, get the short SHA for the latest commit
# Otherwise, just give up.
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
git rev-parse --short HEAD 2> /dev/null || \
echo '(unknown)')";

[ -n "${s}" ] && s=" [${s}]";
[ -n "${s}" ] && s=" [${s}]";

echo -e "${1}${branchName}${2}${s}";
else
return;
fi;
echo -e "${1}${branchName}${2}${s}";
}

if tput setaf 1 &> /dev/null; then
Expand Down
4 changes: 4 additions & 0 deletions .exports
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ export LESS_TERMCAP_md="${yellow}";

# Don’t clear the screen after quitting a manual page.
export MANPAGER='less -X';

# Avoid issues with `gpg` as installed via Homebrew.
# https://stackoverflow.com/a/42265848/96656
export GPG_TTY=$(tty);
83 changes: 9 additions & 74 deletions .functions
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,6 @@ function dataurl() {
echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')";
}

# Create a git.io short URL
function gitio() {
if [ -z "${1}" -o -z "${2}" ]; then
echo "Usage: \`gitio slug url\`";
return 1;
fi;
curl -i https://git.io/ -F "url=${2}" -F "code=${1}";
}

# Start an HTTP server from a directory, optionally specifying the port
function server() {
local port="${1:-8000}";
Expand Down Expand Up @@ -111,48 +102,11 @@ function gz() {
printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio";
}

# Syntax-highlight JSON strings or files
# Usage: `json '{"foo":42}'` or `echo '{"foo":42}' | json`
function json() {
if [ -t 0 ]; then # argument
python -mjson.tool <<< "$*" | pygmentize -l javascript;
else # pipe
python -mjson.tool | pygmentize -l javascript;
fi;
}

# Run `dig` and display the most useful info
function digga() {
dig +nocmd "$1" any +multiline +noall +answer;
}

# UTF-8-encode a string of Unicode symbols
function escape() {
printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u);
# print a newline unless we’re piping the output to another program
if [ -t 1 ]; then
echo ""; # newline
fi;
}

# Decode \x{ABCD}-style Unicode escape sequences
function unidecode() {
perl -e "binmode(STDOUT, ':utf8'); print \"$@\"";
# print a newline unless we’re piping the output to another program
if [ -t 1 ]; then
echo ""; # newline
fi;
}

# Get a character’s Unicode code point
function codepoint() {
perl -e "use utf8; print sprintf('U+%04X', ord(\"$@\"))";
# print a newline unless we’re piping the output to another program
if [ -t 1 ]; then
echo ""; # newline
fi;
}

# Show all the names (CNs and SANs) listed in the SSL certificate
# for a given domain
function getcertnames() {
Expand Down Expand Up @@ -187,35 +141,16 @@ function getcertnames() {
fi;
}

# `s` with no arguments opens the current directory in Sublime Text, otherwise
# opens the given location
function s() {
if [ $# -eq 0 ]; then
subl .;
else
subl "$@";
fi;
}

# `a` with no arguments opens the current directory in Atom Editor, otherwise
# opens the given location
function a() {
if [ $# -eq 0 ]; then
atom .;
else
atom "$@";
fi;
}

# `v` with no arguments opens the current directory in Vim, otherwise opens the
# given location
function v() {
if [ $# -eq 0 ]; then
vim .;
# Normalize `open` across Linux, macOS, and Windows.
# This is needed to make the `o` function (see below) cross-platform.
if [ ! $(uname -s) = 'Darwin' ]; then
if grep -q Microsoft /proc/version; then
# Ubuntu on Windows using the Linux subsystem
alias open='explorer.exe';
else
vim "$@";
fi;
}
alias open='xdg-open';
fi
fi

# `o` with no arguments opens the current directory, otherwise opens the given
# location
Expand Down
17 changes: 12 additions & 5 deletions .gitconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"

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

# Clone a repository including all submodules
c = clone --recursive
Expand All @@ -29,6 +29,9 @@
branches = branch -a
remotes = remote -v

# List aliases
aliases = config --get-regexp alias

# Amend the currently staged files to the latest commit
amend = commit --amend --reuse-message=HEAD

Expand Down Expand Up @@ -81,6 +84,8 @@
br = branch
rb = rebase
co = checkout
# Show the user email for the current repository.
whoami = config user.email
[apply]
Expand All @@ -107,6 +112,10 @@
# http://michael-kuehnel.de/git/2014/11/21/git-mac-osx-and-german-umlaute.html
precomposeunicode = false
# Speed up commands involving untracked files such as `git status`.
# https://git-scm.com/docs/git-update-index#_untracked_cache
untrackedCache = true
[color]
# Use colors in Git commands that are capable of colored output when
Expand Down Expand Up @@ -162,10 +171,8 @@
[push]
# Use the Git 1.x.x default to avoid errors on machines with old Git
# installations. To use `simple` instead, add this to your `~/.extra` file:
# `git config --global push.default simple`. See http://git.io/mMah-w.
default = matching
# https://git-scm.com/docs/git-config#git-config-pushdefault
default = simple
# Make `git push` push relevant annotated tags when pushing branches out.
followTags = true
Expand Down
Loading

0 comments on commit 8354ee7

Please sign in to comment.