diff options
-rw-r--r-- | .gitignore | 9 | ||||
-rw-r--r-- | LICENSE.md | 21 | ||||
-rw-r--r-- | README.md | 88 | ||||
-rwxr-xr-x | bin/beep | 1 | ||||
-rwxr-xr-x | bin/dualmon | 2 | ||||
-rwxr-xr-x | bin/passmenu | 26 | ||||
-rwxr-xr-x | bin/singlemon | 2 | ||||
-rw-r--r-- | git/gitconfig.symlink.example | 38 | ||||
-rw-r--r-- | git/gitignore.symlink | 3 | ||||
-rwxr-xr-x | script/bootstrap | 156 | ||||
-rwxr-xr-x | script/install | 10 | ||||
-rw-r--r-- | system/_path.zsh | 2 | ||||
-rw-r--r-- | system/env.zsh | 1 | ||||
-rw-r--r-- | vim/vimrc.symlink | 4 |
14 files changed, 363 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9466065 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +atom.symlink/.apm +atom.symlink/.node-gyp +atom.symlink/.storage +atom.symlink/compile-cache/ +atom.symlink/packages +atom.symlink/storage +atom.symlink/themes + +git/gitconfig.symlink 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 new file mode 100644 index 0000000..1f56baa --- /dev/null +++ b/README.md @@ -0,0 +1,88 @@ +# holman does dotfiles + +## dotfiles + +Your dotfiles are how you personalize your system. These are mine. + +I was a little tired of having long alias files and everything strewn about +(which is extremely common on other dotfiles projects, too). That led to this +project being much more topic-centric. I realized I could split a lot of things +up into the main areas I used (Ruby, git, system libraries, and so on), so I +structured the project accordingly. + +If you're interested in the philosophy behind why projects like these are +awesome, you might want to [read my post on the +subject](http://zachholman.com/2010/08/dotfiles-are-meant-to-be-forked/). + +## install + +Run this: + +```sh +git clone https://github.com/holman/dotfiles.git ~/.dotfiles +cd ~/.dotfiles +script/bootstrap +``` + +This will symlink the appropriate files in `.dotfiles` to your home directory. +Everything is configured and tweaked within `~/.dotfiles`. + +The main file you'll want to change right off the bat is `zsh/zshrc.symlink`, +which sets up a few paths that'll be different on your particular machine. + +`dot` is a simple script that installs some dependencies, sets sane OS X +defaults, and so on. Tweak this script, and occasionally run `dot` from +time to time to keep your environment fresh and up-to-date. You can find +this script in `bin/`. + +## topical + +Everything's built around topic areas. If you're adding a new area to your +forked dotfiles — say, "Java" — you can simply add a `java` directory and put +files in there. Anything with an extension of `.zsh` will get automatically +included into your shell. Anything with an extension of `.symlink` will get +symlinked without extension into `$HOME` when you run `script/bootstrap`. + +## what's inside + +A lot of stuff. Seriously, a lot of stuff. Check them out in the file browser +above and see what components may mesh up with you. +[Fork it](https://github.com/holman/dotfiles/fork), remove what you don't +use, and build on what you do use. + +## components + +There's a few special files in the hierarchy. + +- **bin/**: Anything in `bin/` will get added to your `$PATH` and be made + available everywhere. +- **topic/\*.zsh**: Any files ending in `.zsh` get loaded into your + environment. +- **topic/path.zsh**: Any file named `path.zsh` is loaded first and is + expected to setup `$PATH` or similar. +- **topic/completion.zsh**: Any file named `completion.zsh` is loaded + last and is expected to setup autocomplete. +- **topic/\*.symlink**: Any files ending in `*.symlink` get symlinked into + your `$HOME`. This is so you can keep all of those versioned in your dotfiles + but still keep those autoloaded files in your home directory. These get + symlinked in when you run `script/bootstrap`. + +## bugs + +I want this to work for everyone; that means when you clone it down it should +work for you even though you may not have `rbenv` installed, for example. That +said, I do use this as *my* dotfiles, so there's a good chance I may break +something if I forget to make a check for a dependency. + +If you're brand-new to the project and run into any blockers, please +[open an issue](https://github.com/holman/dotfiles/issues) on this repository +and I'd love to get it fixed for you! + +## thanks + +I forked [Ryan Bates](http://github.com/ryanb)' excellent +[dotfiles](http://github.com/ryanb/dotfiles) for a couple years before the +weight of my changes and tweaks inspired me to finally roll my own. But Ryan's +dotfiles were an easy way to get into bash customization, and then to jump ship +to zsh a bit later. A decent amount of the code in these dotfiles stem or are +inspired from Ryan's original project. diff --git a/bin/beep b/bin/beep new file mode 100755 index 0000000..edd6b63 --- /dev/null +++ b/bin/beep @@ -0,0 +1 @@ +echo -en "\a" > /dev/tty5 diff --git a/bin/dualmon b/bin/dualmon new file mode 100755 index 0000000..26fd972 --- /dev/null +++ b/bin/dualmon @@ -0,0 +1,2 @@ +#!/bin/bash +xrandr --output eDP1 --below HDMI2 --primary --output HDMI2 --auto diff --git a/bin/passmenu b/bin/passmenu new file mode 100755 index 0000000..9b5239d --- /dev/null +++ b/bin/passmenu @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +shopt -s nullglob globstar + +typeit=0 +if [[ $1 == "--type" ]]; then + typeit=1 + shift +fi + +prefix=${PASSWORD_STORE_DIR-~/.password-store} +password_files=( "$prefix"/**/*.gpg ) +password_files=( "${password_files[@]#"$prefix"/}" ) +password_files=( "${password_files[@]%.gpg}" ) + +password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@") + +[[ -n $password ]] || exit + +if [[ $typeit -eq 0 ]]; then + pass show -c "$password" 2>/dev/null +else + pass show "$password" | + awk 'BEGIN{ORS=""} {print; exit}' | + xdotool type --clearmodifiers --file - +fi diff --git a/bin/singlemon b/bin/singlemon new file mode 100755 index 0000000..b24869c --- /dev/null +++ b/bin/singlemon @@ -0,0 +1,2 @@ +#!/bin/bash +xrandr --output eDP1 --primary --auto --output HDMI2 --off diff --git a/git/gitconfig.symlink.example b/git/gitconfig.symlink.example new file mode 100644 index 0000000..0f12706 --- /dev/null +++ b/git/gitconfig.symlink.example @@ -0,0 +1,38 @@ +# Sample gitconfig +# + +[hub] + protocol = https +[user] + name = AUTHORNAME + email = AUTHOREMAIL +[credential] + helper = GIT_CREDENTIAL_HELPER +[alias] + co = checkout + promote = !$ZSH/bin/git-promote + wtf = !$ZSH/bin/git-wtf + rank-contributors = !$ZSH/bin/git-rank-contributors + count = !git shortlog -sn +[color] + diff = auto + status = auto + branch = auto + ui = true +[core] + excludesfile = ~/.gitignore + editor = vim +[apply] + whitespace = nowarn +[mergetool] + keepBackup = false +[difftool] + prompt = false +[help] + autocorrect = 1 +[push] + # See `git help config` (search for push.default) + # for more information on different options of the below setting. + # + # Setting to git 2.0 default to suppress warning message + default = simple diff --git a/git/gitignore.symlink b/git/gitignore.symlink new file mode 100644 index 0000000..6fd41c0 --- /dev/null +++ b/git/gitignore.symlink @@ -0,0 +1,3 @@ +.DS_Store +*~ +*.swp diff --git a/script/bootstrap b/script/bootstrap new file mode 100755 index 0000000..d817c18 --- /dev/null +++ b/script/bootstrap @@ -0,0 +1,156 @@ +#!/usr/bin/env bash +# +# bootstrap installs things. + +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.symlink ] + then + info 'setup gitconfig' + + git_credential='cache --timeout=3600' + 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.symlink.example > git/gitconfig.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') + 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..1887fc2 --- /dev/null +++ b/script/install @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# +# Run all dotfiles installers. + +set -e + +cd "$(dirname $0)"/.. + +# 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/env.zsh b/system/env.zsh new file mode 100644 index 0000000..c4620b4 --- /dev/null +++ b/system/env.zsh @@ -0,0 +1 @@ +export EDITOR='vim' 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 |