From 3dde85aa72f5f808214197b365621ca60d704800 Mon Sep 17 00:00:00 2001 From: Stefan Pasch Date: Thu, 1 Dec 2016 08:58:43 +0100 Subject: [PATCH] Initial dotfiles rework. --- .gitignore | 1 + Brewfile | 82 ++++++++++++++++++++ LICENSE.md | 21 ++++++ README.md | 24 +++++- bin/dot | 21 ++++++ bin/e | 16 ++++ bin/set-defaults | 5 ++ functions/extract | 30 ++++++++ git/aliases.zsh | 8 ++ git/completion.zsh | 9 +++ git/gitconfig.symlink | 130 ++++++++++++++++++++++++++++++++ git/gitignore.symlink | 18 +++++ homebrew/install.sh | 24 ++++++ macos/install.sh | 7 ++ macos/set-defaults.sh | 68 +++++++++++++++++ ruby/completion.zsh | 22 ++++++ ruby/gemrc.symlink | 6 ++ ruby/rbenv.zsh | 5 ++ script/bootstrap | 170 ++++++++++++++++++++++++++++++++++++++++++ script/install | 14 ++++ system/_path.zsh | 2 + system/aliases.zsh | 10 +++ system/env.zsh | 1 + system/grc.zsh | 5 ++ system/keys.zsh | 2 + vim/vimrc.symlink | 4 + zsh/aliases.zsh | 2 + zsh/completion.zsh | 5 ++ zsh/config.zsh | 37 +++++++++ zsh/fpath.zsh | 2 + zsh/prompt.zsh | 82 ++++++++++++++++++++ zsh/window.zsh | 19 +++++ zsh/zshrc.symlink | 38 ++++++++++ 33 files changed, 888 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Brewfile create mode 100644 LICENSE.md create mode 100755 bin/dot create mode 100755 bin/e create mode 100755 bin/set-defaults create mode 100644 functions/extract create mode 100644 git/aliases.zsh create mode 100644 git/completion.zsh create mode 100644 git/gitconfig.symlink create mode 100644 git/gitignore.symlink create mode 100755 homebrew/install.sh create mode 100755 macos/install.sh create mode 100755 macos/set-defaults.sh create mode 100644 ruby/completion.zsh create mode 100644 ruby/gemrc.symlink create mode 100644 ruby/rbenv.zsh create mode 100755 script/bootstrap create mode 100755 script/install create mode 100644 system/_path.zsh create mode 100644 system/aliases.zsh create mode 100644 system/env.zsh create mode 100644 system/grc.zsh create mode 100644 system/keys.zsh create mode 100644 vim/vimrc.symlink create mode 100644 zsh/aliases.zsh create mode 100644 zsh/completion.zsh create mode 100644 zsh/config.zsh create mode 100644 zsh/fpath.zsh create mode 100644 zsh/prompt.zsh create mode 100644 zsh/window.zsh create mode 100644 zsh/zshrc.symlink diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1b67d59 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +git/gitconfig.local.symlink diff --git a/Brewfile b/Brewfile new file mode 100644 index 0000000..0476c36 --- /dev/null +++ b/Brewfile @@ -0,0 +1,82 @@ +cask_args appdir: '/Applications' + +tap 'caskroom/cask' +tap 'caskroom/fonts' +tap 'caskroom/versions' + +tap 'homebrew/bundle' +tap 'homebrew/completions' +tap 'homebrew/core' +tap 'homebrew/dupes' +tap 'homebrew/php' +tap 'homebrew/services' +tap 'homebrew/versions' + +brew 'ansible' +brew 'assh' +brew 'coreutils' +brew 'curl' +brew 'go' +brew 'grc' +brew 'docker' +brew 'docker-machine' +brew 'docker-compose' +brew 'imagemagick' +brew 'libgit2' +brew 'openssl' +brew 'mas' +brew 'node' +brew 'readline' +brew 'ruby-build' +brew 'rbenv' +brew 'python' +brew 'tmate' +brew 'unrar' +brew 'wget' +brew 'zsh' +brew 'zsh-completions' +brew 'suspicious-package' +brew 'quicklook-json' +brew 'qlmarkdown' +brew 'qlstephen' +brew 'qlcolorcode' +brew 'p4mergetool' + +brew 'homebrew/completions/brew-cask-completion' +brew 'homebrew/dupes/grep' +brew 'homebrew/dupes/make' +brew 'homebrew/dupes/ncurses' +brew 'homebrew/dupes/nano' +brew 'homebrew/dupes/unzip' +brew 'homebrew/dupes/whois' +brew 'homebrew/php/php56' +brew 'homebrew/php/php56-xdebug' +brew 'homebrew/php/php70' +brew 'homebrew/php/php70-imagick' +brew 'homebrew/php/php70-xdebug' +brew 'homebrew/php/php71' + +cask '1password' +cask 'cleanmymac' +cask 'dropbox' +cask 'firefox' +cask 'franz' +cask 'google-chrome' +cask 'google-drive' +cask 'gpgtools' +cask 'phpstorm' +cask 'poedit' +cask 'sequel-pro' +cask 'slack' +cask 'skype' +cask 'sublime-text' +cask 'transmit' +cask 'tower' +cask 'vagrant' +cask 'virtualbox' +cask 'vlc' + +mas 'Xcode', id: 497799835 +mas 'Pages', id: 409201541 +mas 'Harvest', id: 506189836 +mas 'iA Writer', id: 775737590 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..1622cb1 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) Zach Holman, http://zachholman.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index 9d29c89..28a945d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,22 @@ -# dotfiles -My dotfiles. +# Paschi's dotfiles + +Your dotfiles are how you personalize your system. These are mine. They are basically forked from +[Holman](https://github.com/holman/dotfiles)' great dotfiles. See the description for detailed infos. + +## install + +Run this: + +```sh +git clone https://github.com/hubersen/dotfiles.git ~/.dotfiles +cd ~/.dotfiles +script/bootstrap +``` + +## thanks + +Thank's to all of your dotfiles. Mine where built out of yours. + +[Holman](https://github.com/holman/dotfiles) +[Paul Millr](https://github.com/paulmillr/dotfiles) +[Pascal Birchler](https://github.com/swissspidy/dotfiles) diff --git a/bin/dot b/bin/dot new file mode 100755 index 0000000..4d34556 --- /dev/null +++ b/bin/dot @@ -0,0 +1,21 @@ +#!/bin/sh +# +# dot +# +# `dot` handles installation, updates, things like that. Run it periodically +# to make sure you're on the latest and greatest. +export ZSH=$HOME/.dotfiles + +# Set macOS defaults +$ZSH/macos/set-defaults.sh + +# Install homebrew +$ZSH/homebrew/install.sh 2>&1 + +# Upgrade homebrew +echo "› brew update" +brew update + +# Install software +echo "› $ZSH/script/install" +$ZSH/script/install diff --git a/bin/e b/bin/e new file mode 100755 index 0000000..501ad6e --- /dev/null +++ b/bin/e @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Quick shortcut to an editor. +# +# This means that as I travel back and forth between editors, hey, I don't have +# to re-learn any arcane commands. Neat. +# +# USAGE: +# +# $ e +# # => opens the current directory in your editor +# +# $ e . +# $ e /usr/local +# # => opens the specified directory in your editor +exec "$EDITOR" "${1:-.}" diff --git a/bin/set-defaults b/bin/set-defaults new file mode 100755 index 0000000..3338596 --- /dev/null +++ b/bin/set-defaults @@ -0,0 +1,5 @@ +#!/bin/sh +# +# Sets macOS defaults by running $ZSH/macos/set-defaults.sh. + +exec $ZSH/macos/set-defaults.sh diff --git a/functions/extract b/functions/extract new file mode 100644 index 0000000..16640fe --- /dev/null +++ b/functions/extract @@ -0,0 +1,30 @@ +#!/bin/sh +# +# Usage: extract +# Description: extracts archived files / mounts disk images +# Note: .dmg/hdiutil is macOS-specific. +# +# credit: http://nparikh.org/notes/zshrc.txt +extract () { + if [ -f $1 ]; then + case $1 in + *.tar.bz2) tar -jxvf $1 ;; + *.tar.gz) tar -zxvf $1 ;; + *.bz2) bunzip2 $1 ;; + *.dmg) hdiutil mount $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar -xvf $1 ;; + *.tbz2) tar -jxvf $1 ;; + *.tgz) tar -zxvf $1 ;; + *.zip) unzip $1 ;; + *.ZIP) unzip $1 ;; + *.pax) cat $1 | pax -r ;; + *.pax.Z) uncompress $1 --stdout | pax -r ;; + *.rar) unrar x $1 ;; + *.Z) uncompress $1 ;; + *) echo "'$1' cannot be extracted/mounted via extract()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} diff --git a/git/aliases.zsh b/git/aliases.zsh new file mode 100644 index 0000000..b95c9e3 --- /dev/null +++ b/git/aliases.zsh @@ -0,0 +1,8 @@ +alias glog="git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative" + +# Remove `+` and `-` from start of diff lines; just rely upon color. +alias gd='git diff --color | sed "s/^\([^-+ ]*\)[-+ ]/\\1/" | less -r' + +alias gc='git commit' +alias gca='git commit -a' +alias gco='git checkout' diff --git a/git/completion.zsh b/git/completion.zsh new file mode 100644 index 0000000..81fd2ec --- /dev/null +++ b/git/completion.zsh @@ -0,0 +1,9 @@ +# Uses git's autocompletion for inner commands. Assumes an install of git's +# bash `git-completion` script at $completion below (this is where Homebrew +# tosses it, at least). +completion='$(brew --prefix)/share/zsh/site-functions/_git' + +if test -f $completion +then + source $completion +fi diff --git a/git/gitconfig.symlink b/git/gitconfig.symlink new file mode 100644 index 0000000..6e4dd65 --- /dev/null +++ b/git/gitconfig.symlink @@ -0,0 +1,130 @@ +[alias] + c = commit -am + up = pull + p = push + s = status + co = checkout + cp = cherry-pick + df = diff --color --color-words --abbrev + l = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -- + + # 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" + + # See https://johnblackbourn.com/git-changelog-generator + changelog = "!_() { t=$(git describe --abbrev=0 --tags); git log ${t}..HEAD --no-merges --pretty=format:'* %s'; }; _" + + # Save patch file to Desktop + patch = "!f() { \ + git add . && git diff --cached > ~/Desktop/$1.diff; \ + }; f" + + # Find commits by source code. + cc = "!f() { \ + git log --pretty=custom --decorate --date=short -S\"$1\"; \ + }; f" + + # Find commits by commit message. + cm = "!f() { \ + git log --pretty=custom --decorate --date=short --grep=\"$1\"; \ + }; f" + + # Remove the tag with the specified tag name if exists and tag the latest commit with that name. + retag = "!f() { \ + git tag -d "$1" &> /dev/null; \ + git tag $1; \ + }; f" +[color] + ui = always + +[color "diff"] + meta = yellow bold + commit = green bold + frag = magenta bold + old = red bold + new = green bold + whitespace = red reverse + +[color "diff-highlight"] + oldNormal = red bold + oldHighlight = "red bold 52" + newNormal = "green bold" + newHighlight = "green bold 22" + +[color "branch"] + current = yellow reverse + local = yellow + remote = green + +[color "status"] + added = yellow + changed = green + untracked = cyan + +[commit] + gpgsign = true + +[core] + attributesfile = ~/.gitattributes + excludesfile = ~/.gitignore + autocrlf = false + editor = nano + pager = diff-so-fancy | less --tabs=4 -RFX + +[diff] + noprefix = true + mnemonicprefix = false + compactionHeuristic = true + tool = p4mergetool + +[difftool "p4mergetool"] + cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge $LOCAL $REMOTE + +[fetch] + prune = true + +[gpg] + program = /usr/local/bin/gpg_wrap + +[help] + # correct typos + autocorrect = 1 + +[merge] + tool = p4mergetool + +[mergetool "p4mergetool"] + cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge $PWD/$BASE $PWD/$REMOTE $PWD/$LOCAL $PWD/$MERGED + trustExitCode = false + +[mergetool] + keepBackup = false + +[pretty] + custom = "%C(magenta)%h%C(red)%d %C(yellow)%ar %C(green)%s %C(yellow)(%an)" + # │ │ │ │ └─ author name + # │ │ │ └─ message + # │ │ └─ date (relative) + # │ └─ decorations (branch, heads or tags) + # └─ hash (abbreviated) + +[push] + # push easily. http://stackoverflow.com/a/23918418/89484 + default = current + followTags = true + +[rebase] + autostash = true + +[stash] + showPatch = true + +[user] + # Don't guess the user's identity. + # https://github.com/git/git/blob/90f7b16b3adc78d4bbabbd426fb69aa78c714f71/Documentation/config.txt#L2847-L2855 + useConfigOnly = true + +[include] + # use separate file for username / github token / etc. + # at the end so it can override any of the above configs + path = ~/.gitconfig.local \ No newline at end of file diff --git a/git/gitignore.symlink b/git/gitignore.symlink new file mode 100644 index 0000000..99eb062 --- /dev/null +++ b/git/gitignore.symlink @@ -0,0 +1,18 @@ +# Linux +*~ + +# macOS +._* +.DS_Store +.Trashes + +# Intellj +.idea + +# Windows +Thumbs.db + +# Miscellaneous +*.pyc +node_modules +npm-debug.log \ No newline at end of file diff --git a/homebrew/install.sh b/homebrew/install.sh new file mode 100755 index 0000000..1921f00 --- /dev/null +++ b/homebrew/install.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# +# Homebrew +# +# This installs some of the common dependencies needed (or at least desired) +# using Homebrew. + +# Check for Homebrew +if test ! $(which brew) +then + echo " Installing Homebrew for you." + + # Install the correct homebrew for each OS type + if test "$(uname)" = "Darwin" + then + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + elif test "$(expr substr $(uname -s) 1 5)" = "Linux" + then + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)" + fi + +fi + +exit 0 diff --git a/macos/install.sh b/macos/install.sh new file mode 100755 index 0000000..b8a11de --- /dev/null +++ b/macos/install.sh @@ -0,0 +1,7 @@ +# The Brewfile handles Homebrew-based app and library installs, but there may +# still be updates and installables in the Mac App Store. There's a nifty +# command line interface to it that we can use to just install everything, so +# yeah, let's do that. + +echo "› sudo softwareupdate -i -a" +sudo softwareupdate -i -a diff --git a/macos/set-defaults.sh b/macos/set-defaults.sh new file mode 100755 index 0000000..d4b7497 --- /dev/null +++ b/macos/set-defaults.sh @@ -0,0 +1,68 @@ +# Sets reasonable macOS defaults. +# +# Or, in other words, set shit how I like in macOS. +# +# Settings are based on some other dotfiles: +# https://github.com/holman/dotfiles/ +# +# Run ./set-defaults.sh and you'll be good to go. + +# Disable press-and-hold for keys in favor of key repeat. +defaults write -g ApplePressAndHoldEnabled -bool false + +# Use AirDrop over every interface. srsly this should be a default. +defaults write com.apple.NetworkBrowser BrowseAllInterfaces 1 + +# Always open everything in Finder's list view. This is important. +defaults write com.apple.Finder FXPreferredViewStyle Nlsv + +# Show the ~/Library folder. +chflags nohidden ~/Library + +# Set a really fast key repeat. +defaults write NSGlobalDomain KeyRepeat -int 0 + +# Set the Finder prefs for showing a few different volumes on the Desktop. +defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true +defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true + +# Set up Safari for development. +defaults write com.apple.Safari IncludeInternalDebugMenu -bool true +defaults write com.apple.Safari IncludeDevelopMenu -bool true +defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true +defaults write com.apple.Safari "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" -bool true +defaults write NSGlobalDomain WebKitDeveloperExtras -bool true + +# Check for software updates daily, not just once per week +defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1 + +# Save screenshots to the downlaods. +defaults write com.apple.screencapture location "$HOME/Downloads/" + +# Trackpad: enable tap to click for this user and for the login screen +defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true +defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 +defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 +sudo defaults write com.apple.AppleMultitouchTrackpad Clicking 1 + +# Prevent Time Machine from prompting to use new hard drives as backup volume +defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true + +# Disable the sudden motion sensor as it’s not useful for SSDs +sudo pmset -a sms 0 + +# Finder: show all filename extensions +defaults write NSGlobalDomain AppleShowAllExtensions -bool true + +# Disable the warning when changing a file extension +defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false + +# When performing a search, search the current folder by default +defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" + +# Disable the warning before emptying the Trash +defaults write com.apple.finder WarnOnEmptyTrash -bool false + +# Copy email addresses as `foo@example.com` instead of `Foo Bar ` in Mail.app +defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false + diff --git a/ruby/completion.zsh b/ruby/completion.zsh new file mode 100644 index 0000000..87bdc54 --- /dev/null +++ b/ruby/completion.zsh @@ -0,0 +1,22 @@ +# Stolen from +# https://github.com/sstephenson/rbenv/blob/master/completions/rbenv.zsh + +if [[ ! -o interactive ]]; then + return +fi + +compctl -K _rbenv rbenv + +_rbenv() { + local word words completions + read -cA words + word="${words[2]}" + + if [ "${#words}" -eq 2 ]; then + completions="$(rbenv commands)" + else + completions="$(rbenv completions "${word}")" + fi + + reply=("${(ps:\n:)completions}") +} \ No newline at end of file diff --git a/ruby/gemrc.symlink b/ruby/gemrc.symlink new file mode 100644 index 0000000..63e8ac2 --- /dev/null +++ b/ruby/gemrc.symlink @@ -0,0 +1,6 @@ +--- +:update_sources: true +:verbose: true +:backtrace: false +:benchmark: false +gem: --no-document diff --git a/ruby/rbenv.zsh b/ruby/rbenv.zsh new file mode 100644 index 0000000..cb93d58 --- /dev/null +++ b/ruby/rbenv.zsh @@ -0,0 +1,5 @@ +# init according to man page +if (( $+commands[rbenv] )) +then + eval "$(rbenv init -)" +fi diff --git a/script/bootstrap b/script/bootstrap new file mode 100755 index 0000000..7a879e0 --- /dev/null +++ b/script/bootstrap @@ -0,0 +1,170 @@ +#!/usr/bin/env bash +# +# bootstrap installs things. + +dev="$HOME/Development" +pushd . +mkdir -p $dev +cd $dev + +echo 'Enter new hostname of the machine (e.g. mbp-paschi)' + read hostname + echo "Setting new hostname to $hostname..." + scutil --set HostName "$hostname" + compname=$(sudo scutil --get HostName | tr '-' '.') + echo "Setting computer name to $compname" + scutil --set ComputerName "$compname" + sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$compname" + +cd "$(dirname "$0")/.." +DOTFILES_ROOT=$(pwd -P) + +set -e + +echo '' + +info () { + printf "\r [ \033[00;34m..\033[0m ] $1\n" +} + +user () { + printf "\r [ \033[0;33m??\033[0m ] $1\n" +} + +success () { + printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n" +} + +fail () { + printf "\r\033[2K [\033[0;31mFAIL\033[0m] $1\n" + echo '' + exit +} + +setup_gitconfig () { + if ! [ -f git/gitconfig.local.symlink ] + then + info 'setup gitconfig' + + git_credential='cache' + if [ "$(uname -s)" == "Darwin" ] + then + git_credential='osxkeychain' + fi + + user ' - What is your github author name?' + read -e git_authorname + user ' - What is your github author email?' + read -e git_authoremail + + sed -e "s/AUTHORNAME/$git_authorname/g" -e "s/AUTHOREMAIL/$git_authoremail/g" -e "s/GIT_CREDENTIAL_HELPER/$git_credential/g" git/gitconfig.local.symlink.example > git/gitconfig.local.symlink + + success 'gitconfig' + fi +} + + +link_file () { + local src=$1 dst=$2 + + local overwrite= backup= skip= + local action= + + if [ -f "$dst" -o -d "$dst" -o -L "$dst" ] + then + + if [ "$overwrite_all" == "false" ] && [ "$backup_all" == "false" ] && [ "$skip_all" == "false" ] + then + + local currentSrc="$(readlink $dst)" + + if [ "$currentSrc" == "$src" ] + then + + skip=true; + + else + + user "File already exists: $dst ($(basename "$src")), what do you want to do?\n\ + [s]kip, [S]kip all, [o]verwrite, [O]verwrite all, [b]ackup, [B]ackup all?" + read -n 1 action + + case "$action" in + o ) + overwrite=true;; + O ) + overwrite_all=true;; + b ) + backup=true;; + B ) + backup_all=true;; + s ) + skip=true;; + S ) + skip_all=true;; + * ) + ;; + esac + + fi + + fi + + overwrite=${overwrite:-$overwrite_all} + backup=${backup:-$backup_all} + skip=${skip:-$skip_all} + + if [ "$overwrite" == "true" ] + then + rm -rf "$dst" + success "removed $dst" + fi + + if [ "$backup" == "true" ] + then + mv "$dst" "${dst}.backup" + success "moved $dst to ${dst}.backup" + fi + + if [ "$skip" == "true" ] + then + success "skipped $src" + fi + fi + + if [ "$skip" != "true" ] # "false" or empty + then + ln -s "$1" "$2" + success "linked $1 to $2" + fi +} + +install_dotfiles () { + info 'installing dotfiles' + + local overwrite_all=false backup_all=false skip_all=false + + for src in $(find -H "$DOTFILES_ROOT" -maxdepth 2 -name '*.symlink' -not -path '*.git*') + do + dst="$HOME/.$(basename "${src%.*}")" + link_file "$src" "$dst" + done +} + +setup_gitconfig +install_dotfiles + +# If we're on a Mac, let's install and setup homebrew. +if [ "$(uname -s)" == "Darwin" ] +then + info "installing dependencies" + if source bin/dot > /tmp/dotfiles-dot 2>&1 + then + success "dependencies installed" + else + fail "error installing dependencies" + fi +fi + +echo '' +echo ' All installed!' diff --git a/script/install b/script/install new file mode 100755 index 0000000..8d516b2 --- /dev/null +++ b/script/install @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# +# Run all dotfiles installers. + +set -e + +cd "$(dirname $0)"/.. + +# Run Homebrew through the Brewfile +echo "› brew bundle" +brew bundle + +# find the installers and run them iteratively +find . -name install.sh | while read installer ; do sh -c "${installer}" ; done diff --git a/system/_path.zsh b/system/_path.zsh new file mode 100644 index 0000000..255c2cf --- /dev/null +++ b/system/_path.zsh @@ -0,0 +1,2 @@ +export PATH="./bin:/usr/local/bin:/usr/local/sbin:$ZSH/bin:$PATH" +export MANPATH="/usr/local/man:/usr/local/mysql/man:/usr/local/git/man:$MANPATH" diff --git a/system/aliases.zsh b/system/aliases.zsh new file mode 100644 index 0000000..d11780c --- /dev/null +++ b/system/aliases.zsh @@ -0,0 +1,10 @@ +# grc overides for ls +# Made possible through contributions from generous benefactors like +# `brew install coreutils` +if $(gls &>/dev/null) +then + alias ls="gls -F --color" + alias l="gls -lAh --color" + alias ll="gls -l --color" + alias la='gls -A --color' +fi \ No newline at end of file diff --git a/system/env.zsh b/system/env.zsh new file mode 100644 index 0000000..cab2fc2 --- /dev/null +++ b/system/env.zsh @@ -0,0 +1 @@ +export EDITOR='subl' diff --git a/system/grc.zsh b/system/grc.zsh new file mode 100644 index 0000000..23dbb39 --- /dev/null +++ b/system/grc.zsh @@ -0,0 +1,5 @@ +# GRC colorizes nifty unix tools all over the place +if (( $+commands[grc] )) && (( $+commands[brew] )) +then + source `brew --prefix`/etc/grc.bashrc +fi diff --git a/system/keys.zsh b/system/keys.zsh new file mode 100644 index 0000000..cf4fe31 --- /dev/null +++ b/system/keys.zsh @@ -0,0 +1,2 @@ +# Pipe my public key to my clipboard. +alias pubkey="more ~/.ssh/id_rsa.pub | pbcopy | echo '=> Public key copied to pasteboard.'" diff --git a/vim/vimrc.symlink b/vim/vimrc.symlink new file mode 100644 index 0000000..0463e21 --- /dev/null +++ b/vim/vimrc.symlink @@ -0,0 +1,4 @@ +syntax on + +" Wrap gitcommit file types at the appropriate length +filetype indent plugin on diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh new file mode 100644 index 0000000..21aeb3e --- /dev/null +++ b/zsh/aliases.zsh @@ -0,0 +1,2 @@ +alias reload!='. ~/.zshrc' +alias cls='clear' # Good 'ol Clear Screen command diff --git a/zsh/completion.zsh b/zsh/completion.zsh new file mode 100644 index 0000000..1862eec --- /dev/null +++ b/zsh/completion.zsh @@ -0,0 +1,5 @@ +# matches case insensitive for lowercase +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' + +# pasting with tabs doesn't perform completion +zstyle ':completion:*' insert-tab pending diff --git a/zsh/config.zsh b/zsh/config.zsh new file mode 100644 index 0000000..4c9d5cc --- /dev/null +++ b/zsh/config.zsh @@ -0,0 +1,37 @@ +export LSCOLORS="exfxcxdxbxegedabagacad" +export CLICOLOR=true + +fpath=($ZSH/functions $fpath) + +autoload -U $ZSH/functions/*(:t) + +HISTFILE=~/.zsh_history +HISTSIZE=10000 +SAVEHIST=10000 + +setopt NO_BG_NICE # don't nice background tasks +setopt NO_HUP +setopt LOCAL_OPTIONS # allow functions to have local options +setopt LOCAL_TRAPS # allow functions to have local traps +setopt HIST_VERIFY +setopt EXTENDED_HISTORY # add timestamps to history +setopt PROMPT_SUBST +setopt CORRECT +setopt COMPLETE_IN_WORD +setopt IGNORE_EOF + +setopt APPEND_HISTORY # adds history +setopt INC_APPEND_HISTORY SHARE_HISTORY # adds history incrementally and share it across sessions +setopt HIST_IGNORE_ALL_DUPS # don't record dupes in history +setopt HIST_REDUCE_BLANKS + +# don't expand aliases _before_ completion has finished +# like: git comm-[tab] +setopt complete_aliases + +bindkey '^[^[[D' backward-word +bindkey '^[^[[C' forward-word +bindkey '^[[5D' beginning-of-line +bindkey '^[[5C' end-of-line +bindkey '^[[3~' delete-char +bindkey '^?' backward-delete-char diff --git a/zsh/fpath.zsh b/zsh/fpath.zsh new file mode 100644 index 0000000..eaff4f4 --- /dev/null +++ b/zsh/fpath.zsh @@ -0,0 +1,2 @@ +#add each topic folder to fpath so that they can add functions and completion scripts +for topic_folder ($ZSH/*) if [ -d $topic_folder ]; then fpath=($topic_folder $fpath); fi; diff --git a/zsh/prompt.zsh b/zsh/prompt.zsh new file mode 100644 index 0000000..2e96295 --- /dev/null +++ b/zsh/prompt.zsh @@ -0,0 +1,82 @@ +autoload colors && colors +# cheers, @ehrenmurdick +# http://github.com/ehrenmurdick/config/blob/master/zsh/prompt.zsh + +if (( $+commands[git] )) +then + git="$commands[git]" +else + git="/usr/bin/git" +fi + +git_branch() { + echo $($git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}) +} + +git_dirty() { + if $(! $git status -s &> /dev/null) + then + echo "" + else + if [[ $($git status --porcelain) == "" ]] + then + echo "on %{$fg_bold[green]%}$(git_prompt_info)%{$reset_color%}" + else + echo "on %{$fg_bold[red]%}$(git_prompt_info)%{$reset_color%}" + fi + fi +} + +git_prompt_info () { + ref=$($git symbolic-ref HEAD 2>/dev/null) || return +# echo "(%{\e[0;33m%}${ref#refs/heads/}%{\e[0m%})" + echo "${ref#refs/heads/}" +} + +unpushed () { + $git cherry -v @{upstream} 2>/dev/null +} + +need_push () { + if [[ $(unpushed) == "" ]] + then + echo " " + else + echo " with %{$fg_bold[magenta]%}unpushed%{$reset_color%} " + fi +} + +ruby_version() { + if (( $+commands[rbenv] )) + then + echo "$(rbenv version | awk '{print $1}')" + fi + + if (( $+commands[rvm-prompt] )) + then + echo "$(rvm-prompt | awk '{print $1}')" + fi +} + +rb_prompt() { + if ! [[ -z "$(ruby_version)" ]] + then + echo "%{$fg_bold[yellow]%}$(ruby_version)%{$reset_color%} " + else + echo "" + fi +} + +directory_name() { + echo "%{$fg_bold[cyan]%}%1/%\/%{$reset_color%}" +} + +export PROMPT=$'\n$(rb_prompt)in $(directory_name) $(git_dirty)$(need_push)\n› ' +set_prompt () { + export RPROMPT="%{$fg_bold[cyan]%}%{$reset_color%}" +} + +precmd() { + title "zsh" "%m" "%55<...<%~" + set_prompt +} diff --git a/zsh/window.zsh b/zsh/window.zsh new file mode 100644 index 0000000..805cb92 --- /dev/null +++ b/zsh/window.zsh @@ -0,0 +1,19 @@ +# From http://dotfiles.org/~_why/.zshrc +# Sets the window title nicely no matter where you are +function title() { + # escape '%' chars in $1, make nonprintables visible + a=${(V)1//\%/\%\%} + + # Truncate command, and join lines. + a=$(print -Pn "%40>...>$a" | tr -d "\n") + + case $TERM in + screen) + print -Pn "\ek$a:$3\e\\" # screen title (in ^A") + ;; + xterm*|rxvt) + print -Pn "\e]2;$2\a" # plain xterm title ($3 for pwd) + ;; + esac +} + diff --git a/zsh/zshrc.symlink b/zsh/zshrc.symlink new file mode 100644 index 0000000..9fd9a89 --- /dev/null +++ b/zsh/zshrc.symlink @@ -0,0 +1,38 @@ +# shortcut to this dotfiles path is $ZSH +export ZSH=$HOME/.dotfiles + +# Stash your environment variables in ~/.localrc. This means they'll stay out +# of your main dotfiles repository (which may be public, like this one), but +# you'll have access to them in your scripts. +if [[ -a ~/.localrc ]] +then + source ~/.localrc +fi + +# all of our zsh files +typeset -U config_files +config_files=($ZSH/**/*.zsh) + +# load the path files +for file in ${(M)config_files:#*/path.zsh} +do + source $file +done + +# load everything but the path and completion files +for file in ${${config_files:#*/path.zsh}:#*/completion.zsh} +do + source $file +done + +# initialize autocomplete here, otherwise functions won't be loaded +autoload -U compinit +compinit + +# load every completion after autocomplete loads +for file in ${(M)config_files:#*/completion.zsh} +do + source $file +done + +unset config_files