aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.aliases17
-rw-r--r--.bash_profile32
-rw-r--r--.bash_prompt78
-rw-r--r--.bashrc2
-rw-r--r--.exports22
-rw-r--r--.functions257
-rw-r--r--.gitconfig38
-rwxr-xr-x.osx3
-rwxr-xr-xbootstrap.sh26
9 files changed, 218 insertions, 257 deletions
diff --git a/.aliases b/.aliases
index bdac6b3..db4d8e9 100644
--- a/.aliases
+++ b/.aliases
@@ -38,9 +38,6 @@ export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40
# Enable aliases to be sudo’ed
alias sudo='sudo '
-# Gzip-enabled `curl`
-alias gurl='curl --compressed'
-
# Get week number
alias week='date +%V'
@@ -78,9 +75,9 @@ command -v md5sum > /dev/null || alias md5sum="md5"
command -v sha1sum > /dev/null || alias sha1sum="shasum"
# JavaScriptCore REPL
-jscbin="/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc"
-[ -e "${jscbin}" ] && alias jsc="${jscbin}"
-unset jscbin
+jscbin="/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc";
+[ -e "${jscbin}" ] && alias jsc="${jscbin}";
+unset jscbin;
# Trim new lines and copy to clipboard
alias c="tr -d '\n' | pbcopy"
@@ -88,9 +85,6 @@ alias c="tr -d '\n' | pbcopy"
# Recursively delete `.DS_Store` files
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
-# ROT13-encode text. Works for decoding, too! ;)
-alias rot13='tr a-zA-Z n-za-mN-ZA-M'
-
# Empty the Trash on all mounted volumes and the main HDD
# Also, clear Apple’s System Logs to improve shell startup speed
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl"
@@ -138,7 +132,6 @@ 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 7'"
-alias hax="growlnotify -a 'Activity Monitor' 'System error' -m 'WTF R U DOIN'"
# Kill all the tabs in Chrome to free up memory
# [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
@@ -150,5 +143,5 @@ alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resource
# Reload the shell (i.e. invoke as a login shell)
alias reload="exec $SHELL -l"
-# Faster npm for europeans
-command -v npm > /dev/null && alias npme="npm --registry http://registry.npmjs.eu"
+# Faster npm for Europeans
+command -v npm > /dev/null && alias npme="npm --registry http://registry.npmjs.eu/"
diff --git a/.bash_profile b/.bash_profile
index ba564c9..dbc60d3 100644
--- a/.bash_profile
+++ b/.bash_profile
@@ -1,46 +1,46 @@
# Add `~/bin` to the `$PATH`
-export PATH="$HOME/bin:$PATH"
+export PATH="$HOME/bin:$PATH";
# Load the shell dotfiles, and then some:
# * ~/.path can be used to extend `$PATH`.
# * ~/.extra can be used for other settings you don’t want to commit.
for file in ~/.{path,bash_prompt,exports,aliases,functions,extra}; do
- [ -r "$file" ] && [ -f "$file" ] && source "$file"
-done
-unset file
+ [ -r "$file" ] && [ -f "$file" ] && source "$file";
+done;
+unset file;
# Case-insensitive globbing (used in pathname expansion)
-shopt -s nocaseglob
+shopt -s nocaseglob;
# Append to the Bash history file, rather than overwriting it
-shopt -s histappend
+shopt -s histappend;
# Autocorrect typos in path names when using `cd`
-shopt -s cdspell
+shopt -s cdspell;
# Enable some Bash 4 features when possible:
# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux`
# * Recursive globbing, e.g. `echo **/*.txt`
for option in autocd globstar; do
- shopt -s "$option" 2> /dev/null
-done
+ shopt -s "$option" 2> /dev/null;
+done;
# Add tab completion for many Bash commands
if which brew > /dev/null && [ -f "$(brew --prefix)/etc/bash_completion" ]; then
- source "$(brew --prefix)/etc/bash_completion"
-fi
+ source "$(brew --prefix)/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
- complete -o default -o nospace -F _git g
-fi
+ complete -o default -o nospace -F _git g;
+fi;
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
-[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2 | tr ' ' '\n')" scp sftp ssh
+[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2 | tr ' ' '\n')" scp sftp ssh;
# Add tab completion for `defaults read|write NSGlobalDomain`
# You could just use `-g` instead, but I like being explicit
-complete -W "NSGlobalDomain" defaults
+complete -W "NSGlobalDomain" defaults;
# Add `killall` tab completion for common apps
-complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall
+complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall;
diff --git a/.bash_prompt b/.bash_prompt
index 83670e5..c9a821d 100644
--- a/.bash_prompt
+++ b/.bash_prompt
@@ -3,55 +3,55 @@
# Screenshot: http://i.imgur.com/s0Blh.png
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
- export TERM=gnome-256color
+ export TERM=gnome-256color;
elif infocmp xterm-256color >/dev/null 2>&1; then
- export TERM=xterm-256color
+ export TERM=xterm-256color;
fi
if tput setaf 1 &> /dev/null; then
- tput sgr0
+ tput sgr0; # reset colors
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
- MAGENTA=$(tput setaf 9)
- ORANGE=$(tput setaf 172)
- GREEN=$(tput setaf 190)
- PURPLE=$(tput setaf 141)
- WHITE=$(tput setaf 0)
+ MAGENTA=$(tput setaf 9);
+ ORANGE=$(tput setaf 172);
+ GREEN=$(tput setaf 190);
+ PURPLE=$(tput setaf 141);
+ WHITE=$(tput setaf 0);
else
- MAGENTA=$(tput setaf 5)
- ORANGE=$(tput setaf 4)
- GREEN=$(tput setaf 2)
- PURPLE=$(tput setaf 1)
- WHITE=$(tput setaf 7)
- fi
- BOLD=$(tput bold)
- RESET=$(tput sgr0)
+ MAGENTA=$(tput setaf 5);
+ ORANGE=$(tput setaf 4);
+ GREEN=$(tput setaf 2);
+ PURPLE=$(tput setaf 1);
+ WHITE=$(tput setaf 7);
+ fi;
+ BOLD=$(tput bold);
+ RESET=$(tput sgr0);
else
- MAGENTA="\033[1;31m"
- ORANGE="\033[1;33m"
- GREEN="\033[1;32m"
- PURPLE="\033[1;35m"
- WHITE="\033[1;37m"
- BOLD=""
- RESET="\033[m"
-fi
+ MAGENTA="\033[1;31m";
+ ORANGE="\033[1;33m";
+ GREEN="\033[1;32m";
+ PURPLE="\033[1;35m";
+ WHITE="\033[1;37m";
+ BOLD="";
+ RESET="\033[m";
+fi;
-export MAGENTA
-export ORANGE
-export GREEN
-export PURPLE
-export WHITE
-export BOLD
-export RESET
+export MAGENTA;
+export ORANGE;
+export GREEN;
+export PURPLE;
+export WHITE;
+export BOLD;
+export RESET;
function parse_git_branch() {
- local branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
+ local branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null);
if [ -n "${branch}" ]; then
- [ "${branch}" == "HEAD" ] && local branch=$(git rev-parse --short HEAD 2>/dev/null)
- local status=$(git status --porcelain 2>/dev/null)
- echo -n " on ${PURPLE}${branch}"
- [ -n "${status}" ] && echo -n "*"
- fi
+ [ "${branch}" == "HEAD" ] && local branch=$(git rev-parse --short HEAD 2>/dev/null);
+ local status=$(git status --porcelain 2>/dev/null);
+ echo -n " on ${PURPLE}${branch}";
+ [ -n "${status}" ] && echo -n "*";
+ fi;
}
-export PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]"
-export PS2="\[$ORANGE\]→ \[$RESET\]"
+export PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]";
+export PS2="\[$ORANGE\]→ \[$RESET\]";
diff --git a/.bashrc b/.bashrc
index 33cb4b6..1257002 100644
--- a/.bashrc
+++ b/.bashrc
@@ -1 +1 @@
-[ -n "$PS1" ] && source ~/.bash_profile
+[ -n "$PS1" ] && source ~/.bash_profile;
diff --git a/.exports b/.exports
index e60924d..25d913f 100644
--- a/.exports
+++ b/.exports
@@ -1,25 +1,25 @@
# Make vim the default editor
-export EDITOR="vim"
+export EDITOR="vim";
# Larger bash history (allow 32³ entries; default is 500)
-export HISTSIZE=32768
-export HISTFILESIZE=$HISTSIZE
-export HISTCONTROL=ignoredups
+export HISTSIZE=32768;
+export HISTFILESIZE=$HISTSIZE;
+export HISTCONTROL=ignoredups;
# Make some commands not show up in history
-export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help"
+export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help";
# Prefer US English and use UTF-8
-export LANG="en_US.UTF-8"
-export LC_ALL="en_US.UTF-8"
+export LANG="en_US.UTF-8";
+export LC_ALL="en_US.UTF-8";
# Highlight section titles in manual pages
-export LESS_TERMCAP_md="$ORANGE"
+export LESS_TERMCAP_md="${ORANGE}";
# Don’t clear the screen after quitting a manual page
-export MANPAGER="less -X"
+export MANPAGER="less -X";
# Always enable colored `grep` output
-export GREP_OPTIONS="--color=auto"
+export GREP_OPTIONS="--color=auto";
# Link Homebrew casks in `/Applications` rather than `~/Applications`
-export HOMEBREW_CASK_OPTS="--appdir=/Applications"
+export HOMEBREW_CASK_OPTS="--appdir=/Applications";
diff --git a/.functions b/.functions
index 40eba72..3f3ac9c 100644
--- a/.functions
+++ b/.functions
@@ -1,7 +1,7 @@
# Simple calculator
function calc() {
- local result=""
- result="$(printf "scale=10;$*\n" | bc --mathlib | tr -d '\\\n')"
+ local result="";
+ result="$(printf "scale=10;$*\n" | bc --mathlib | tr -d '\\\n')";
# └─ default (when `--mathlib` is used) is 20
#
if [[ "$result" == *.* ]]; then
@@ -9,171 +9,171 @@ function calc() {
printf "$result" |
sed -e 's/^\./0./' `# add "0" for cases like ".5"` \
-e 's/^-\./-0./' `# add "0" for cases like "-.5"`\
- -e 's/0*$//;s/\.$//' # remove trailing zeros
+ -e 's/0*$//;s/\.$//'; # remove trailing zeros
else
- printf "$result"
- fi
- printf "\n"
+ printf "$result";
+ fi;
+ printf "\n";
}
# Create a new directory and enter it
function mkd() {
- mkdir -p "$@" && cd "$@"
+ mkdir -p "$@" && cd "$@";
}
# Change working directory to the top-most Finder window location
function cdf() { # short for `cdfinder`
- cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')"
+ cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')";
}
# Create a .tar.gz archive, using `zopfli`, `pigz` or `gzip` for compression
function targz() {
- local tmpFile="${@%/}.tar"
- tar -cvf "${tmpFile}" --exclude=".DS_Store" "${@}" || return 1
+ local tmpFile="${@%/}.tar";
+ tar -cvf "${tmpFile}" --exclude=".DS_Store" "${@}" || return 1;
size=$(
stat -f"%z" "${tmpFile}" 2> /dev/null; # OS X `stat`
stat -c"%s" "${tmpFile}" 2> /dev/null # GNU `stat`
- )
+ );
- local cmd=""
+ local cmd="";
if (( size < 52428800 )) && hash zopfli 2> /dev/null; then
# the .tar file is smaller than 50 MB and Zopfli is available; use it
- cmd="zopfli"
+ cmd="zopfli";
else
if hash pigz 2> /dev/null; then
- cmd="pigz"
+ cmd="pigz";
else
- cmd="gzip"
- fi
- fi
+ cmd="gzip";
+ fi;
+ fi;
- echo "Compressing .tar using \`${cmd}\`…"
- "${cmd}" -v "${tmpFile}" || return 1
- [ -f "${tmpFile}" ] && rm "${tmpFile}"
- echo "${tmpFile}.gz created successfully."
+ echo "Compressing .tar using \`${cmd}\`…";
+ "${cmd}" -v "${tmpFile}" || return 1;
+ [ -f "${tmpFile}" ] && rm "${tmpFile}";
+ echo "${tmpFile}.gz created successfully.";
}
# Determine size of a file or total size of a directory
function fs() {
if du -b /dev/null > /dev/null 2>&1; then
- local arg=-sbh
+ local arg=-sbh;
else
- local arg=-sh
+ local arg=-sh;
fi
if [[ -n "$@" ]]; then
- du $arg -- "$@"
+ du $arg -- "$@";
else
- du $arg .[^.]* *
- fi
+ du $arg .[^.]* *;
+ fi;
}
# Use Git’s colored diff when available
-hash git &>/dev/null
+hash git &>/dev/null;
if [ $? -eq 0 ]; then
function diff() {
- git diff --no-index --color-words "$@"
+ git diff --no-index --color-words "$@";
}
-fi
+fi;
# Create a data URL from a file
function dataurl() {
- local mimeType=$(file -b --mime-type "$1")
+ local mimeType=$(file -b --mime-type "$1");
if [[ $mimeType == text/* ]]; then
- mimeType="${mimeType};charset=utf-8"
+ mimeType="${mimeType};charset=utf-8";
fi
- echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')"
+ 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 http://git.io/ -F "url=${2}" -F "code=${1}"
+ echo "Usage: \`gitio slug url\`";
+ return 1;
+ fi;
+ curl -i http://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}"
+ local port="${1:-8000}";
sleep 1 && open "http://localhost:${port}/" &
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
- python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
+ python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port";
}
# Start a PHP server from a directory, optionally specifying the port
# (Requires PHP 5.4.0+.)
function phpserver() {
- local port="${1:-4000}"
- local ip=$(ipconfig getifaddr en1)
+ local port="${1:-4000}";
+ local ip=$(ipconfig getifaddr en1);
sleep 1 && open "http://${ip}:${port}/" &
- php -S "${ip}:${port}"
+ php -S "${ip}:${port}";
}
# Compare original and gzipped file size
function gz() {
- local origsize=$(wc -c < "$1")
- local gzipsize=$(gzip -c "$1" | wc -c)
- local ratio=$(echo "$gzipsize * 100/ $origsize" | bc -l)
- printf "orig: %d bytes\n" "$origsize"
- printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio"
+ local origsize=$(wc -c < "$1");
+ local gzipsize=$(gzip -c "$1" | wc -c);
+ local ratio=$(echo "$gzipsize * 100 / $origsize" | bc -l);
+ printf "orig: %d bytes\n" "$origsize";
+ 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
+ python -mjson.tool <<< "$*" | pygmentize -l javascript;
else # pipe
- python -mjson.tool | pygmentize -l javascript
- fi
+ python -mjson.tool | pygmentize -l javascript;
+ fi;
}
-# All the dig info
+# Run `dig` and display the most useful info
function digga() {
- dig +nocmd "$1" any +multiline +noall +answer
+ dig +nocmd "$1" any +multiline +noall +answer;
}
-# Escape UTF-8 characters into their 3-byte format
+# UTF-8-encode a string of Unicode symbols
function escape() {
- printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u)
+ 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
+ echo ""; # newline
+ fi;
}
# Decode \x{ABCD}-style Unicode escape sequences
function unidecode() {
- perl -e "binmode(STDOUT, ':utf8'); print \"$@\""
+ 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
+ echo ""; # newline
+ fi;
}
# Get a character’s Unicode code point
function codepoint() {
- perl -e "use utf8; print sprintf('U+%04X', ord(\"$@\"))"
+ 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
+ echo ""; # newline
+ fi;
}
# Show all the names (CNs and SANs) listed in the SSL certificate
# for a given domain
function getcertnames() {
if [ -z "${1}" ]; then
- echo "ERROR: No domain specified."
- return 1
- fi
+ echo "ERROR: No domain specified.";
+ return 1;
+ fi;
- local domain="${1}"
- echo "Testing ${domain}…"
- echo # newline
+ local domain="${1}";
+ echo "Testing ${domain}…";
+ echo ""; # newline
local tmp=$(echo -e "GET / HTTP/1.0\nEOT" \
| openssl s_client -connect "${domain}:443" 2>&1);
@@ -182,136 +182,59 @@ function getcertnames() {
local certText=$(echo "${tmp}" \
| openssl x509 -text -certopt "no_header, no_serial, no_version, \
no_signame, no_validity, no_issuer, no_pubkey, no_sigdump, no_aux");
- echo "Common Name:"
- echo # newline
+ echo "Common Name:";
+ echo ""; # newline
echo "${certText}" | grep "Subject:" | sed -e "s/^.*CN=//";
- echo # newline
- echo "Subject Alternative Name(s):"
- echo # newline
+ echo ""; # newline
+ echo "Subject Alternative Name(s):";
+ echo ""; # newline
echo "${certText}" | grep -A 1 "Subject Alternative Name:" \
- | sed -e "2s/DNS://g" -e "s/ //g" | tr "," "\n" | tail -n +2
- return 0
+ | sed -e "2s/DNS://g" -e "s/ //g" | tr "," "\n" | tail -n +2;
+ return 0;
else
echo "ERROR: Certificate not found.";
- return 1
- fi
-}
-
-# Add note to Notes.app (OS X 10.8)
-# Usage: `note 'title' 'body'` or `echo 'body' | note`
-# Title is optional
-function note() {
- local title
- local body
- if [ -t 0 ]; then
- title="$1"
- body="$2"
- else
- title=$(cat)
- fi
- osascript >/dev/null <<EOF
-tell application "Notes"
- tell account "iCloud"
- tell folder "Notes"
- make new note with properties {name:"$title", body:"$title" & "<br><br>" & "$body"}
- end tell
- end tell
-end tell
-EOF
-}
-
-# Add reminder to Reminders.app (OS X 10.8)
-# Usage: `remind 'foo'` or `echo 'foo' | remind`
-function remind() {
- local text
- if [ -t 0 ]; then
- text="$1" # argument
- else
- text=$(cat) # pipe
- fi
- osascript >/dev/null <<EOF
-tell application "Reminders"
- tell the default list
- make new reminder with properties {name:"$text"}
- end tell
-end tell
-EOF
-}
-
-# Manually remove a downloaded app or file from the quarantine
-function unquarantine() {
- for attribute in com.apple.metadata:kMDItemDownloadedDate com.apple.metadata:kMDItemWhereFroms com.apple.quarantine; do
- xattr -r -d "$attribute" "$@"
- done
-}
-
-# Install Grunt plugins and add them as `devDependencies` to `package.json`
-# Usage: `gi contrib-watch contrib-uglify zopfli`
-function gi() {
- npm install --save-dev ${*/#/grunt-}
-}
-
-# `m` with no arguments opens the current directory in TextMate, otherwise
-# opens the given location
-function m() {
- if [ $# -eq 0 ]; then
- mate .
- else
- mate "$@"
- fi
+ return 1;
+ fi;
}
# `s` with no arguments opens the current directory in Sublime Text, otherwise
# opens the given location
function s() {
if [ $# -eq 0 ]; then
- subl .
+ subl .;
else
- subl "$@"
- fi
+ 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 .
+ atom .;
else
- atom "$@"
- fi
+ atom "$@";
+ fi;
}
# `v` with no arguments opens the current directory in Vim, otherwise opens the
# given location
function v() {
if [ $# -eq 0 ]; then
- vim .
+ vim .;
else
- vim "$@"
- fi
+ vim "$@";
+ fi;
}
-# `o` with no arguments opens current directory, otherwise opens the given
+# `o` with no arguments opens the current directory, otherwise opens the given
# location
function o() {
if [ $# -eq 0 ]; then
- open .
+ open .;
else
- open "$@"
- fi
-}
-
-# `np` with an optional argument `patch`/`minor`/`major`/`<version>`
-# defaults to `patch`
-function np() {
- git pull --rebase && \
- rm -rf node_modules && \
- npm install && \
- npm test && \
- npm version ${1:=patch} && \
- npm publish && \
- git push origin master && \
- git push origin master --tags
+ open "$@";
+ fi;
}
# `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring
@@ -319,5 +242,5 @@ function np() {
# `less` with options to preserve color and line numbers, unless the output is
# small enough for one screen.
function tre() {
- tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX
+ tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
}
diff --git a/.gitconfig b/.gitconfig
index a586fd0..e19fcd5 100644
--- a/.gitconfig
+++ b/.gitconfig
@@ -1,90 +1,128 @@
[alias]
+
# View abbreviated SHA, description, and history graph of the latest 20 commits
l = log --pretty=oneline -n 20 --graph --abbrev-commit
+
# View the current working tree status using the short format
s = status -s
+
# Show the diff between the latest commit and the current state
d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
+
# `git di $number` shows the diff between the state `$number` revisions ago and the current state
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"
+
# Clone a repository including all submodules
c = clone --recursive
+
# Commit all changes
ca = !git add -A && git commit -av
+
# Switch to a branch, creating it if necessary
go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f"
+
# Show verbose output about tags, branches or remotes
tags = tag -l
branches = branch -a
remotes = remote -v
+
# Credit an author on the latest commit
credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f"
+
# Interactive rebase with the given number of latest commits
reb = "!r() { git rebase -i HEAD~$1; }; r"
+
# Find branches containing commit
fb = "!f() { git branch -a --contains $1; }; f"
+
# Find tags containing commit
ft = "!f() { git describe --always --contains $1; }; f"
+
# Find commits by source code
fc = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -S$1; }; f"
+
# Find commits by commit message
fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f"
+
# Remove branches that have already been merged with master
dm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
[apply]
+
# Detect whitespace errors when applying a patch
whitespace = fix
[core]
+
# Use custom `.gitignore` and `.gitattributes`
excludesfile = ~/.gitignore
attributesfile = ~/.gitattributes
+
# Treat spaces before tabs and all kinds of trailing whitespace as an error.
# [default] trailing-space: looks for spaces at the end of a line
# [default] space-before-tab: looks for spaces before tabs at the beginning of
# a line
whitespace = space-before-tab,-indent-with-non-tab,trailing-space
+
# Make `git rebase` safer on OS X
# More info: <http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/>
trustctime = false
[color]
+
# Use colors in Git commands that are capable of colored output when
# outputting to the terminal. (This is the default setting in Git ≥ 1.8.4.)
ui = auto
+
[color "branch"]
+
current = yellow reverse
local = yellow
remote = green
+
[color "diff"]
+
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
+
[color "status"]
+
added = yellow
changed = green
untracked = cyan
+
[merge]
+
# Include summaries of merged commits in newly created merge commit messages
log = true
# URL shorthands
+
[url "git@github.com:"]
+
insteadOf = "gh:"
pushInsteadOf = "github:"
pushInsteadOf = "git://github.com/"
+
[url "git://github.com/"]
+
insteadOf = "github:"
+
[url "git@gist.github.com:"]
+
insteadOf = "gst:"
pushInsteadOf = "gist:"
pushInsteadOf = "git://gist.github.com/"
+
[url "git://gist.github.com/"]
+
insteadOf = "gist:"
[push]
+
default = matching
diff --git a/.osx b/.osx
index c0a41d8..9ae87fb 100755
--- a/.osx
+++ b/.osx
@@ -74,6 +74,9 @@ defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
# Disable the “Are you sure you want to open this application?” dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
+# Remove duplicates in the “Open With” menu (also see `lscleanup` alias)
+/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
+
# Display ASCII control characters using caret notation in standard text views
# Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt`
defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true
diff --git a/bootstrap.sh b/bootstrap.sh
index b4b8f96..e7b0f07 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,18 +1,22 @@
#!/usr/bin/env bash
-cd "$(dirname "${BASH_SOURCE}")"
-git pull origin master
+
+cd "$(dirname "${BASH_SOURCE}")";
+
+git pull origin master;
+
function doIt() {
rsync --exclude ".git/" --exclude ".DS_Store" --exclude "bootstrap.sh" \
- --exclude "README.md" --exclude "LICENSE-MIT.txt" -avh --no-perms . ~
- source ~/.bash_profile
+ --exclude "README.md" --exclude "LICENSE-MIT.txt" -avh --no-perms . ~;
+ source ~/.bash_profile;
}
+
if [ "$1" == "--force" -o "$1" == "-f" ]; then
- doIt
+ doIt;
else
- read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1
- echo
+ read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1;
+ echo "";
if [[ $REPLY =~ ^[Yy]$ ]]; then
- doIt
- fi
-fi
-unset doIt
+ doIt;
+ fi;
+fi;
+unset doIt;