-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9b96bc0
Showing
26 changed files
with
1,787 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
bin/wp-completion.bash | ||
git/.gitconfig.local | ||
composer/.composer/auth.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Dotfiles | ||
|
||
After using some mixed, inconsistent configuration I eventually decided to clean everything up and put my dotfiles on GitHub. | ||
|
||
It's still work in progress, but it's already improved my workflow a lot so I figured i might just as well share it with the public. | ||
|
||
## Personal Highlights | ||
|
||
* Super useful aliases and functions | ||
* Nicer diffs | ||
* Sensible macOS defaults | ||
|
||
## Setup | ||
|
||
When switching computers, the following things need to be done on the old computer: | ||
|
||
Run `./migration/backup_homebrew` to get a list of installed brew packages. You can save the information to a bash file for example. | ||
|
||
Run `./migration/backup_mas`to get a list of installed apps from the Mac App Store. Note: This requires the `mas` utility available via homebrew. | ||
|
||
After that, check out `./migration/backup_old_machine` for some more commands to run on the old machine, step by step. | ||
|
||
On the new computer, copy the needed parts from `./migration/setup_new_machine` to install Xcode Command Line Tools, Homebrew, Composer, WP-CLI, et al. Use `./migration/configure_macos` to set some sensible OS defaults. | ||
|
||
The `stow` command at the end symlinks the bash and Git configuration to the home directory. Check out [this blog post](brandon.invergo.net/news/2012-05-26-using-gnu-stow-to-manage-your-dotfiles.html) for more information about `stow`. | ||
|
||
Bonus: change the Terminal theme as per [these instructions](https://github.com/paulmillr/dotfiles#additional-steps). | ||
|
||
## Credits | ||
|
||
This repository has been inspired by the awesome work of these fine folks: | ||
|
||
* [paulirish](https://github.com/paulirish/dotfiles) | ||
* [mathiasbynens](https://github.com/mathiasbynens/dotfiles/) | ||
* [paulmillr](https://github.com/paulmillr/dotfiles) | ||
* [gf3](https://github.com/gf3/dotfiles) | ||
* [alrra](https://github.com/alrra/dotfiles) | ||
|
||
Also: Stack Overflow, Twitter, and many more resources. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# For easier navigation | ||
|
||
alias cd..="cd .." | ||
alias ..="cd .." | ||
alias ...="cd ../.." | ||
alias ....="cd ../../.." | ||
alias .....="cd ../../../.." | ||
|
||
# Better safe than sorry | ||
alias mv='mv -v' | ||
alias rm='rm -i -v' | ||
alias cp='cp -v' | ||
|
||
# Better `ls` | ||
alias l="ls" | ||
alias ll="ls -l" | ||
alias la="ls -a" | ||
alias lh="ls -lh" | ||
alias lah="ls -lah" | ||
|
||
# Files | ||
alias fs="stat -f \"%z bytes\"" | ||
alias t="tail -F" | ||
|
||
# Trim new lines and copy to clipboard | ||
alias trimcopy="tr -d '\n' | pbcopy" | ||
|
||
# List processes | ||
alias paux="ps aux|grep -i" | ||
|
||
# Networking stuff | ||
# Networking. IP address, dig, DNS | ||
alias ip="dig +short myip.opendns.com @resolver1.opendns.com" | ||
alias wget="curl -O" | ||
|
||
alias hosts="open /etc/hosts -a Visual\ Studio\ Code.app"; | ||
|
||
# advanced-ssh-config | ||
alias ssh="assh wrapper ssh" | ||
|
||
# Flush Directory Service cache | ||
alias flush="dscacheutil -flushcache" | ||
|
||
# Homebrew | ||
alias cask="brew cask" | ||
alias brwe=brew | ||
|
||
# Convenience | ||
alias logout="clear; logout" | ||
alias where="which" | ||
|
||
# Recursively delete `.DS_Store` files | ||
alias cleanup="find . -name '*.DS_Store' -type f -ls -delete" | ||
|
||
alias diskspace_report="df -P -kHl" | ||
|
||
# Update all the things | ||
alias brew_update="brew -v update; brew upgrade --force-bottle --cleanup; brew cleanup; brew cask cleanup; brew prune; brew doctor; npm-check -g -u" | ||
alias update_all="brew_update; mas upgrade; softwareupdate -i; npm install npm -g; npm update -g; sudo gem update --system; sudo gem update --no-document" | ||
|
||
# Git | ||
alias g="git" | ||
alias gti="git" | ||
alias status="git fetch && git status" | ||
alias master="git checkout master" | ||
|
||
# Undo a `git push` | ||
alias undopush="git push -f origin HEAD^:master" | ||
|
||
# Java | ||
|
||
alias setJdk6='export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)' | ||
alias setJdk7='export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)' | ||
alias setJdk8='export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Load our dotfiles like ~/.bash_prompt, etc… | ||
# ~/.extra can be used for settings you don’t want to commit, | ||
# Use it to configure your PATH, thus it being first in line. | ||
for file in ~/.{extra,bash_prompt,exports,aliases,functions}; do | ||
[ -r "$file" ] && . "$file" | ||
done | ||
unset file | ||
|
||
# added by travis gem | ||
[ -f ~/.travis/travis.sh ] && . ~/.travis/travis.sh | ||
|
||
# Load the default .profile | ||
[[ -s "$HOME/.profile" ]] && . "$HOME/.profile" | ||
|
||
# Homebrew completion | ||
if which brew > /dev/null; then | ||
. "$(brew --prefix)/etc/bash_completion.d/brew" | ||
fi; | ||
|
||
# Bash completion | ||
if which brew > /dev/null && [ -f "$(brew --prefix)/share/bash-completion/bash_completion" ]; then | ||
. "$(brew --prefix)/share/bash-completion/bash_completion"; | ||
fi; | ||
|
||
# hub completion | ||
if which hub > /dev/null; then | ||
. "$(brew --prefix)/etc/bash_completion.d/hub.bash_completion.sh"; | ||
fi; | ||
|
||
# WP-CLI completion | ||
if [ -f ~/dotfiles/bin/wp-completion.bash ]; then | ||
. ~/dotfiles/bin/wp-completion.bash; | ||
fi; | ||
|
||
# Autocorrect typos in path names when using `cd` | ||
shopt -s cdspell; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
# This prompt inspired by gf3, sindresorhus, alrra, mathiasbynens, and paulirish. | ||
|
||
default_username='swissspidy' | ||
|
||
if which thefuck > /dev/null; then | ||
eval "$(thefuck --alias)" | ||
fi; | ||
|
||
|
||
if [[ -n "$ZSH_VERSION" ]]; then # quit now if in zsh | ||
return 1 2> /dev/null || exit 1; | ||
fi; | ||
|
||
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then | ||
export TERM=gnome-256color | ||
elif infocmp xterm-256color >/dev/null 2>&1; then | ||
export TERM=xterm-256color | ||
fi | ||
|
||
set_prompts() { | ||
|
||
local black="" blue="" bold="" cyan="" green="" orange="" \ | ||
purple="" red="" reset="" white="" yellow="" | ||
|
||
local dateCmd="" | ||
|
||
if [ -x /usr/bin/tput ] && tput setaf 1 &> /dev/null; then | ||
|
||
tput sgr0 # Reset colors | ||
|
||
bold=$(tput bold) | ||
reset=$(tput sgr0) | ||
|
||
# Solarized colors | ||
# (https://github.com/altercation/solarized/tree/master/iterm2-colors-solarized#the-values) | ||
black=$(tput setaf 0) | ||
blue=$(tput setaf 33) | ||
cyan=$(tput setaf 37) | ||
green=$(tput setaf 190) | ||
orange=$(tput setaf 172) | ||
purple=$(tput setaf 141) | ||
red=$(tput setaf 124) | ||
violet=$(tput setaf 61) | ||
magenta=$(tput setaf 9) | ||
white=$(tput setaf 8) | ||
yellow=$(tput setaf 136) | ||
|
||
else | ||
|
||
bold="" | ||
reset="\e[0m" | ||
|
||
black="\e[1;30m" | ||
blue="\e[1;34m" | ||
cyan="\e[1;36m" | ||
green="\e[1;32m" | ||
orange="\e[1;33m" | ||
purple="\e[1;35m" | ||
red="\e[1;31m" | ||
magenta="\e[1;31m" | ||
violet="\e[1;35m" | ||
white="\e[1;37m" | ||
yellow="\e[1;33m" | ||
|
||
fi | ||
|
||
# Only show username/host if not default | ||
function usernamehost() { | ||
|
||
# Highlight the user name when logged in as root. | ||
if [[ "${USER}" == *"root" ]]; then | ||
userStyle="${red}"; | ||
else | ||
userStyle="${magenta}"; | ||
fi; | ||
|
||
userhost="" | ||
userhost+="\[${userStyle}\]$USER " | ||
userhost+="${white}at " | ||
userhost+="${orange}$HOSTNAME " | ||
userhost+="${white}in" | ||
|
||
if [ $USER != "$default_username" ]; then echo $userhost ""; fi | ||
} | ||
|
||
function prompt_git() { | ||
# this is >5x faster than mathias's. | ||
|
||
# check if we're in a git repo. (fast) | ||
git rev-parse --is-inside-work-tree &>/dev/null || return | ||
|
||
# check for what branch we're on. (fast) | ||
# if… HEAD isn’t a symbolic ref (typical branch), | ||
# then… get a tracking remote branch or tag | ||
# otherwise… get the short SHA for the latest commit | ||
# lastly just 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 ~5s | ||
## also recommended (via goo.gl/wAVZLa ) : sudo sysctl kern.maxvnodes=$((512*1024)) | ||
repoUrl=$(git config --get remote.origin.url) | ||
if grep -q chromium.googlesource.com <<<$repoUrl; then | ||
dirty=" ⁂" | ||
else | ||
|
||
# check if it's dirty (slow) | ||
# technique via github.com/git/git/blob/355d4e173/contrib/completion/git-prompt.sh#L472-L475 | ||
dirty=$(git diff --no-ext-diff --quiet --ignore-submodules --exit-code || echo -e "*") | ||
|
||
# mathias has a few more checks some may like: | ||
# github.com/mathiasbynens/dotfiles/blob/a8bd0d4300/.bash_prompt#L30-L43 | ||
fi | ||
|
||
|
||
[ -n "${s}" ] && s=" [${s}]"; | ||
echo -e "${1}${branchName}${2}$dirty"; | ||
|
||
return | ||
} | ||
|
||
# ------------------------------------------------------------------ | ||
# | Prompt string | | ||
# ------------------------------------------------------------------ | ||
|
||
PS1="\[\033]0;\w\007\]" # terminal title (set to the current working directory) | ||
PS1+="\n\[$bold\]" | ||
PS1+="\[$(usernamehost)\]" # username at host | ||
PS1+="\[$green\]\w" # working directory | ||
PS1+="\$(prompt_git \"$white on $purple\" \"$cyan\")" # git repository details | ||
PS1+="\n" | ||
PS1+="\[$reset$white\]\\$ \[$reset\]" | ||
|
||
export PS1 | ||
|
||
# ------------------------------------------------------------------ | ||
# | Subshell prompt string | | ||
# ------------------------------------------------------------------ | ||
|
||
export PS2="⚡ " | ||
|
||
# ------------------------------------------------------------------ | ||
# | Debug prompt string (when using `set -x`) | | ||
# ------------------------------------------------------------------ | ||
|
||
# When debugging a shell script via `set -x` this tricked-out prompt is used. | ||
|
||
# The first character (+) is used and repeated for stack depth | ||
# Then, we log the current time, filename and line number, followed by function name, followed by actual source line | ||
|
||
# FWIW, I have spent hours attempting to get time-per-command in here, but it's not possible. ~paul | ||
export PS4='+ \011\e[1;30m\t\011\e[1;34m${BASH_SOURCE}\e[0m:\e[1;36m${LINENO}\e[0m \011 ${FUNCNAME[0]:+\e[0;35m${FUNCNAME[0]}\e[1;30m()\e[0m:\011\011 }' | ||
|
||
|
||
# shoutouts: | ||
# https://github.com/dholm/dotshell/blob/master/.local/lib/sh/profile.sh is quite nice. | ||
# zprof is also hot. | ||
|
||
} | ||
|
||
set_prompts | ||
unset set_prompts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ -n "$PS1" ] && source ~/.bash_profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# When following a redirect, automatically set the previous URL as referer. | ||
referer = ";auto" | ||
|
||
# Wait 60 seconds before timing out. | ||
connect-timeout = 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# vim as default | ||
export EDITOR="nano" | ||
|
||
# Prefer US English and use UTF-8 | ||
export LC_ALL="en_US.UTF-8" | ||
export LANG="en_US" | ||
|
||
export HOMEBREW_CASK_OPTS="--appdir=/Applications" | ||
|
||
# WordPress Unit Tests | ||
export WP_TESTS_DIR=~/Workspace/WordPress/develop.git.wordpress.org/tests/phpunit | ||
|
||
# GlotPress Unit Tests | ||
export GP_TESTS_DIR=~/Workspace/GitHub/GlotPress-WP/tests/phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export PATH=/usr/local/bin:$PATH | ||
|
||
# Android Studio | ||
export PATH=/Users/Pascal/Android/sdk/platform-tools:/Users/Pascal/Android/sdk/tools:$PATH | ||
|
||
# Global Composer packages like PHPCPD, PHPMD, PHP_CodeSniffer and PHPUnit | ||
export PATH=~/.composer/vendor/bin:$PATH | ||
|
||
export GOPATH=/usr/local/go | ||
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin |
Oops, something went wrong.