From f3123a736d2efa65ac2ef0c9e54ca89c3e7073d3 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Sat, 19 Jan 2013 17:18:29 +0400 Subject: [PATCH] Initial commit --- README.md | 8 ++++ git/.gitconfig | 29 ++++++++++++++ git/.gitignore | 3 ++ ruby/.aprc | 4 ++ ruby/.gemrc | 1 + ruby/config.zsh | 3 ++ ruby/rbenv/init.zsh | 1 + ruby/rbenv/install.zsh | 5 +++ setup.sh | 14 +++++++ sublime/config-dark | 19 +++++++++ sublime/config-light | 19 +++++++++ zsh/.zshrc | 22 +++++++++++ zsh/aliases.zsh | 13 ++++++ zsh/completion.zsh | 5 +++ zsh/config.zsh | 48 ++++++++++++++++++++++ zsh/functions/_brew | 66 +++++++++++++++++++++++++++++++ zsh/functions/_c | 2 + zsh/functions/_h | 2 + zsh/functions/_rake | 8 ++++ zsh/functions/c | 1 + zsh/functions/extract | 27 +++++++++++++ zsh/functions/h | 1 + zsh/functions/last_modified | 1 + zsh/functions/theme | 12 ++++++ zsh/functions/verbose_completion | 5 +++ zsh/paths.zsh | 1 + zsh/prompt.zsh | 68 ++++++++++++++++++++++++++++++++ zsh/ssh.zsh | 6 +++ zsh/window.zsh | 18 +++++++++ 29 files changed, 412 insertions(+) create mode 100644 README.md create mode 100644 git/.gitconfig create mode 100644 git/.gitignore create mode 100644 ruby/.aprc create mode 100644 ruby/.gemrc create mode 100644 ruby/config.zsh create mode 100644 ruby/rbenv/init.zsh create mode 100644 ruby/rbenv/install.zsh create mode 100755 setup.sh create mode 100644 sublime/config-dark create mode 100644 sublime/config-light create mode 100644 zsh/.zshrc create mode 100644 zsh/aliases.zsh create mode 100644 zsh/completion.zsh create mode 100644 zsh/config.zsh create mode 100644 zsh/functions/_brew create mode 100644 zsh/functions/_c create mode 100644 zsh/functions/_h create mode 100644 zsh/functions/_rake create mode 100644 zsh/functions/c create mode 100644 zsh/functions/extract create mode 100644 zsh/functions/h create mode 100644 zsh/functions/last_modified create mode 100644 zsh/functions/theme create mode 100644 zsh/functions/verbose_completion create mode 100644 zsh/paths.zsh create mode 100644 zsh/prompt.zsh create mode 100644 zsh/ssh.zsh create mode 100644 zsh/window.zsh diff --git a/README.md b/README.md new file mode 100644 index 0000000..1dfad52 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +## .dotfiles + +Installation: + +```bash +git clone git@github.com:magnolia-fan/dotfiles.git ~/.dotfiles +~/.dotfiles/setup.sh +``` diff --git a/git/.gitconfig b/git/.gitconfig new file mode 100644 index 0000000..14bf060 --- /dev/null +++ b/git/.gitconfig @@ -0,0 +1,29 @@ +[hub] + protocol = https +[user] + name = Gregory Eremin + email = magnolia_fan@me.com +[credential] + helper = osxkeychain +[alias] + co = checkout + br = checkout -b + st = status -sb + ci = commit -m + ca = commit -am +[color] + diff = auto + status = auto + branch = auto + ui = true +[core] + excludesfile = ~/.gitignore + editor = subl -n -w +[apply] + whitespace = nowarn +[mergetool] + keepBackup = false +[difftool] + prompt = false +[help] + autocorrect = 1 diff --git a/git/.gitignore b/git/.gitignore new file mode 100644 index 0000000..e6e4615 --- /dev/null +++ b/git/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +.bundle +.rake_tasks diff --git a/ruby/.aprc b/ruby/.aprc new file mode 100644 index 0000000..cd52d4e --- /dev/null +++ b/ruby/.aprc @@ -0,0 +1,4 @@ +AwesomePrint.defaults = { + indent: -2, + index: false +} diff --git a/ruby/.gemrc b/ruby/.gemrc new file mode 100644 index 0000000..6153a6e --- /dev/null +++ b/ruby/.gemrc @@ -0,0 +1 @@ +gem: --no-ri --no-rdoc diff --git a/ruby/config.zsh b/ruby/config.zsh new file mode 100644 index 0000000..54bf592 --- /dev/null +++ b/ruby/config.zsh @@ -0,0 +1,3 @@ +export RUBYOPT="-Ku" +export RUBY_GC_MALLOC_LIMIT=60000000 +export RUBY_FREE_MIN=200000 diff --git a/ruby/rbenv/init.zsh b/ruby/rbenv/init.zsh new file mode 100644 index 0000000..f2aa738 --- /dev/null +++ b/ruby/rbenv/init.zsh @@ -0,0 +1 @@ +eval "$(rbenv init -)" diff --git a/ruby/rbenv/install.zsh b/ruby/rbenv/install.zsh new file mode 100644 index 0000000..b1a98d3 --- /dev/null +++ b/ruby/rbenv/install.zsh @@ -0,0 +1,5 @@ +# if $(brew &>/dev/null) +# then +# brew install rbenv +# brew install ruby-build +# fi diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..e634776 --- /dev/null +++ b/setup.sh @@ -0,0 +1,14 @@ +cd ~ + +# Git +ln -s ~/.dotfiles/git/.gitconfig +ln -s ~/.dotfiles/git/.gitignore + +# ZSH +ln -s ~/.dotfiles/zsh/.zshrc + +# Ruby +ln -s ~/.dotfiles/ruby/.gemrc +ln -s ~/.dotfiles/ruby/.aprc + +cd - diff --git a/sublime/config-dark b/sublime/config-dark new file mode 100644 index 0000000..e267727 --- /dev/null +++ b/sublime/config-dark @@ -0,0 +1,19 @@ +{ + "color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow-Night.tmTheme", + "default_line_ending": "unix", + "drag_text": false, + "ensure_newline_at_eof_on_save": true, + "fallback_encoding": "Cyrillic (Windows 1251)", + "font_face": "Inconsolata", + "font_size": 16.0, + "highlight_line": true, + "ignored_packages": ["Vintage"], + "line_padding_bottom": 1, + "line_padding_top": 3, + "rulers": [120], + "tab_size": 2, + "theme": "Soda Dark.sublime-theme", + "translate_tabs_to_spaces": true, + "tree_animation_enabled": false, + "trim_trailing_white_space_on_save": true +} diff --git a/sublime/config-light b/sublime/config-light new file mode 100644 index 0000000..d9f5873 --- /dev/null +++ b/sublime/config-light @@ -0,0 +1,19 @@ +{ + "color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow.tmTheme", + "default_line_ending": "unix", + "drag_text": false, + "ensure_newline_at_eof_on_save": true, + "fallback_encoding": "Cyrillic (Windows 1251)", + "font_face": "Inconsolata", + "font_size": 16.0, + "highlight_line": true, + "ignored_packages": ["Vintage"], + "line_padding_bottom": 1, + "line_padding_top": 3, + "rulers": [120], + "tab_size": 2, + "theme": "Soda Light.sublime-theme", + "translate_tabs_to_spaces": true, + "tree_animation_enabled": false, + "trim_trailing_white_space_on_save": true +} diff --git a/zsh/.zshrc b/zsh/.zshrc new file mode 100644 index 0000000..5ceba48 --- /dev/null +++ b/zsh/.zshrc @@ -0,0 +1,22 @@ +# shortcut to this dotfiles path is $ZSH +export ZSH=$HOME/.dotfiles + +# your project folder that we can `c [tab]` to +export PROJECTS=~/Code + +# source every .zsh file in this rep +for config_file ($ZSH/**/*.zsh) source $config_file + +# use .localrc for SUPER SECRET CRAP that you don't +# want in your public, versioned repo. +if [[ -a ~/.localrc ]] +then + source ~/.localrc +fi + +# initialize autocomplete here, otherwise functions won't be loaded +autoload -U compinit +compinit + +# load every completion after autocomplete loads +# for config_file ($ZSH/**/completion.sh) source $config_file diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh new file mode 100644 index 0000000..e4abf15 --- /dev/null +++ b/zsh/aliases.zsh @@ -0,0 +1,13 @@ +alias reload!='. ~/.zshrc' +alias b='bundle exec' +alias please='sudo' + +# Services start-ups and shut-downs + +alias mysql-start="mysql.server start" +alias mysql-stop="mysql.server stop" +alias mysql-restart="mysql.server restart" + +alias redis-start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist" +alias redis-stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist" +alias redis-restart="redis-stop && redis-start" 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..a3d941e --- /dev/null +++ b/zsh/config.zsh @@ -0,0 +1,48 @@ +if [[ -n $SSH_CONNECTION ]]; then + export PS1='%m:%3~$(git_info_for_prompt)%# ' +else + export PS1='%3~$(git_info_for_prompt)%# ' +fi + +export LSCOLORS="exfxcxdxbxegedabagacad" +export CLICOLOR=true + +fpath=($ZSH/zsh/functions $fpath) + +autoload -U $ZSH/zsh/functions/*(:t) + +HISTFILE=~/.zsh_history +HISTSIZE=10000 +SAVEHIST=10000 + +setopt NO_BG_NICE # don't nice background tasks +setopt NO_HUP +setopt NO_LIST_BEEP +setopt LOCAL_OPTIONS # allow functions to have local options +setopt LOCAL_TRAPS # allow functions to have local traps +setopt HIST_VERIFY +setopt SHARE_HISTORY # share history between sessions ??? +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 + +zle -N newtab + +bindkey '^[^[[D' backward-word +bindkey '^[^[[C' forward-word +bindkey '^[[5D' beginning-of-line +bindkey '^[[5C' end-of-line +bindkey '^[[3~' delete-char +bindkey '^[^N' newtab +bindkey '^?' backward-delete-char diff --git a/zsh/functions/_brew b/zsh/functions/_brew new file mode 100644 index 0000000..f74ecd3 --- /dev/null +++ b/zsh/functions/_brew @@ -0,0 +1,66 @@ +#compdef brew + +# Brew ZSH completion function +# Drop this somewhere in your $fpath (like /usr/share/zsh/site-functions) +# and rename it _brew +# +# altered from _fink + +_brew_all_formulae() { + formulae=(`brew search`) +} + +_brew_installed_formulae() { + installed_formulae=(`brew list`) +} + +local -a _1st_arguments +_1st_arguments=( + 'install:install a formula' + 'remove:remove a formula' + 'search:search for a formula (/regex/ or string)' + 'list:list files in a formula or not-installed formulae' + 'link:link a formula' + 'unlink:unlink a formula' + 'home:visit the homepage of a formula or the brew project' + 'info:information about a formula' + 'prune:remove dead links' + 'update:freshen up links' + 'upgrade:upgrade outdated packages' + 'log:git commit log for a formula' + 'create:create a new formula' + 'edit:edit a formula' +) + +local expl +local -a formula installed_formulae + +_arguments \ + '(-v --verbose)'{-v,--verbose}'[verbose]' \ + '(--version)--version[version information]' \ + '(--prefix)--prefix[where brew lives on this system]' \ + '(--cache)--cache[brew cache]' \ + '*:: :->subcmds' && return 0 + +if (( CURRENT == 1 )); then + _describe -t commands "brew subcommand" _1st_arguments + return +fi + +case "$words[1]" in + list) + _arguments \ + '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \ + '1: :->forms' && return 0 + + if [[ "$state" == forms ]]; then + _brew_installed_formulae + _requested installed_formulae expl 'installed formulae' compadd -a installed_formulae + fi ;; + install|home|log|info) + _brew_all_formulae + _wanted formulae expl 'all formulae' compadd -a formulae ;; + remove|edit|xo) + _brew_installed_formulae + _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; +esac diff --git a/zsh/functions/_c b/zsh/functions/_c new file mode 100644 index 0000000..dc883c7 --- /dev/null +++ b/zsh/functions/_c @@ -0,0 +1,2 @@ +#compdef c +_files -W $PROJECTS -/ \ No newline at end of file diff --git a/zsh/functions/_h b/zsh/functions/_h new file mode 100644 index 0000000..725dc0a --- /dev/null +++ b/zsh/functions/_h @@ -0,0 +1,2 @@ +#compdef h +_files -W ~ -/ diff --git a/zsh/functions/_rake b/zsh/functions/_rake new file mode 100644 index 0000000..b448eda --- /dev/null +++ b/zsh/functions/_rake @@ -0,0 +1,8 @@ +#compdef rake +if [ -f Rakefile ]; then + recent=`last_modified .rake_tasks~ Rakefile **/*.rake` + if [[ $recent != '.rake_tasks~' ]]; then + rake --silent --tasks | cut -d " " -f 2 > .rake_tasks~ + fi + compadd `cat .rake_tasks~` +fi diff --git a/zsh/functions/c b/zsh/functions/c new file mode 100644 index 0000000..26caf9e --- /dev/null +++ b/zsh/functions/c @@ -0,0 +1 @@ +cd $PROJECTS/$1; \ No newline at end of file diff --git a/zsh/functions/extract b/zsh/functions/extract new file mode 100644 index 0000000..3acfb6d --- /dev/null +++ b/zsh/functions/extract @@ -0,0 +1,27 @@ +# credit: http://nparikh.org/notes/zshrc.txt +# Usage: smartextract +# Description: extracts archived files / mounts disk images +# Note: .dmg/hdiutil is Mac OS X-specific. +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 ;; + *.Z) uncompress $1 ;; + *) echo "'$1' cannot be extracted/mounted via smartextract()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} + diff --git a/zsh/functions/h b/zsh/functions/h new file mode 100644 index 0000000..1ab0d49 --- /dev/null +++ b/zsh/functions/h @@ -0,0 +1 @@ +cd ~/$1; diff --git a/zsh/functions/last_modified b/zsh/functions/last_modified new file mode 100644 index 0000000..bd996e4 --- /dev/null +++ b/zsh/functions/last_modified @@ -0,0 +1 @@ +ls -t $* 2> /dev/null | head -n 1 diff --git a/zsh/functions/theme b/zsh/functions/theme new file mode 100644 index 0000000..18d1b37 --- /dev/null +++ b/zsh/functions/theme @@ -0,0 +1,12 @@ +local sublime_conf_location=~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/Preferences.sublime-settings +local theme="$1" + +case $theme in +light|dark) + local sublime_conf_file="$ZSH/sublime/config-$theme" ;; +*) + local sublime_conf_file="$ZSH/sublime/config-dark" ;; +esac + +rm $sublime_conf_location +cp $sublime_conf_file $sublime_conf_location diff --git a/zsh/functions/verbose_completion b/zsh/functions/verbose_completion new file mode 100644 index 0000000..8ea1224 --- /dev/null +++ b/zsh/functions/verbose_completion @@ -0,0 +1,5 @@ +zstyle ':completion:*' verbose yes +zstyle ':completion:*:descriptions' format '%B%d%b' +zstyle ':completion:*:messages' format '%d' +zstyle ':completion:*:warnings' format 'No matches for: %d' +zstyle ':completion:*' group-name '' diff --git a/zsh/paths.zsh b/zsh/paths.zsh new file mode 100644 index 0000000..a38d7a7 --- /dev/null +++ b/zsh/paths.zsh @@ -0,0 +1 @@ +export PATH=~/.ssh_tunneler/bin:$PATH diff --git a/zsh/prompt.zsh b/zsh/prompt.zsh new file mode 100644 index 0000000..dc94e67 --- /dev/null +++ b/zsh/prompt.zsh @@ -0,0 +1,68 @@ +autoload colors && colors +# cheers, @ehrenmurdick +# http://github.com/ehrenmurdick/config/blob/master/zsh/prompt.zsh + +git_branch() { + echo $(/usr/bin/git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}) +} + +git_dirty() { + st=$(/usr/bin/git status 2>/dev/null | tail -n 1) + if [[ $st == "" ]] + then + echo "" + else + if [[ $st == "nothing to commit (working directory clean)" ]] + then + echo " %{$fg_bold[green]%}($(git_prompt_info))%{$reset_color%}" + else + echo " %{$fg_bold[red]%}($(git_prompt_info))%{$reset_color%}" + fi + fi +} + +git_prompt_info () { + ref=$(/usr/bin/git symbolic-ref HEAD 2>/dev/null) || return +# echo "(%{\e[0;33m%}${ref#refs/heads/}%{\e[0m%})" + echo "${ref#refs/heads/}" +} + +unpushed () { + /usr/bin/git cherry -v @{upstream} 2>/dev/null +} + +need_push () { + if [[ $(unpushed) == "" ]] + then + echo "" + else + echo " %{$fg_bold[magenta]%}➠%{$reset_color%}" + fi +} + +rb_prompt(){ + if $(which rbenv &> /dev/null) + then + echo "%{$fg_bold[cyan]%}$(rbenv version | awk '{print $1}')%{$reset_color%}" + else + echo "" + fi +} + +current_time(){ + echo 'date +"%d.%m.%Y %H:%M:%S"' +} + +directory_name(){ + echo "%{$fg_bold[blue]%}%1/%\%{$reset_color%}" +} + +export PROMPT=$'\n$(directory_name)$(git_dirty)$(need_push) › ' +set_prompt () { + export RPROMPT="$(rb_prompt)" +} + +precmd() { + title "zsh" "%m" "%55<...<%~" + set_prompt +} diff --git a/zsh/ssh.zsh b/zsh/ssh.zsh new file mode 100644 index 0000000..e886b27 --- /dev/null +++ b/zsh/ssh.zsh @@ -0,0 +1,6 @@ +# SSH Agent +result=$(ssh-add -L 2>/dev/null | tail -n 1) +if [[ $result == "The agent has no identities." ]] +then + ssh-add ~/.ssh/id_rsa 2>/dev/null +fi diff --git a/zsh/window.zsh b/zsh/window.zsh new file mode 100644 index 0000000..f07e67d --- /dev/null +++ b/zsh/window.zsh @@ -0,0 +1,18 @@ +# 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 +}