Просмотр исходного кода

Adds auto-loading directories
cleans up bash and zsh,
adds zgen for zsh

Tom McKenzie 7 лет назад
Родитель
Сommit
fff63d2cb3
15 измененных файлов с 228 добавлено и 262 удалено
  1. 19 26
      .bashrc
  2. 20 6
      .gitconfig
  3. 3 24
      .gitignore
  4. 7 0
      .rc.d/aliases.sh
  5. 19 0
      .rc.d/applications.sh
  6. 17 0
      .rc.d/docker.sh
  7. 71 0
      .rc.d/git.sh
  8. 13 88
      .zshrc
  9. 21 0
      .zshrc.d/bindkey.sh
  10. 2 0
      .zshrc.d/iterm.zsh
  11. 26 0
      .zshrc.d/zgen.zsh
  12. 9 1
      README.md
  13. 0 88
      notes/ubuntusetup-apache-rails
  14. 0 28
      private.xml
  15. 1 1
      setup.sh

+ 19 - 26
.bashrc

@@ -1,40 +1,33 @@
-PS1="\[\e[1;32m\]\h:\W \u$\[\e[0m\] "
+if [[ $- != *i* ]] ; then
+  # shell is non-interactive. be done now!
+  return
+fi
 
-# cool aliases bro
-alias start-ubuntu="'`locate vmrun`' -T fusion start ~/Documents/Virtual\ Machines.localized/Ubuntu\ Server.vmwarevm nogui && open smb://ubuntu/share"
-alias restart-sound="sudo kill -9 `ps ax|grep 'coreaudio[a-z]' |awk '{print $1}'`"
-alias start-http='python -m SimpleHTTPServer'
+if [ -d $HOME/.bashrc.d ]; then
+  for file in $HOME/.bashrc.d/*.bash; do
+    source $file
+  done
+fi
 
-alias git-fancy-log="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(cyan)<%an>%Creset' --abbrev-commit --date=relative"
-alias git-timesheet='git log --pretty=format:"%C(yellow)%h%Creset  %C(green)%ad%Creset  %C(cyan)%s" --author="`git config --get user.name`" --since='6am''
+# load all files from .shell/rc.d directory
+if [ -d $HOME/.rc.d ]; then
+  for file in $HOME/.rc.d/*.sh; do
+    source $file
+  done
+fi
 
-alias production='export RAILS_ENV=production && echo "Rails: $RAILS_ENV"'
-alias development='export RAILS_ENV=development && echo "Rails: $RAILS_ENV"'
+# prompt
+PS1="\[\e[1;32m\]\h:\W \u$\[\e[0m\] "
 
 # some more ls aliases from ubuntu
 export CLICOLOR=1
-export LSCOLORS=ExGxBxDxCxEgEdxbxgxcxd 
+export LSCOLORS=ExGxBxDxCxEgEdxbxgxcxd
 eval `dircolors 2> /dev/null`
-alias ll='ls -alF'
-alias la='ls -A'
-alias l='ls -CF'
 
 # better back-searching
 bind '"\e[A": history-search-backward'
 bind '"\e[B": history-search-forward'
 
-# ssh coloring
-ssh() {
-    if command ssh "$@"; then
-    # reset iTerm session to Default
-        echo -e "\033]50;SetProfile=Default\a"
-    fi
-}
-
-if [ -d /usr/local/opt/android-sdk ]; then
-  export ANDROID_HOME=/usr/local/opt/android-sdk
-fi
-
 if [ -f `brew --prefix`/etc/bash_completion ]; then
-    . `brew --prefix`/etc/bash_completion
+  . `brew --prefix`/etc/bash_completion
 fi

+ 20 - 6
.gitconfig

@@ -1,6 +1,7 @@
 [user]
     email = tom@chillidonut.com
     name = Tom McKenzie
+    signingkey = 896D4BE5
 
 [color]
     branch = auto
@@ -26,15 +27,28 @@
 [help]
     autocorrect = 10
 
-[push]
-    default = simple
+[diff]
+    tool = default-difftool
+
+[difftool "default-difftool"]
+    cmd = code --wait --diff $LOCAL $REMOTE
 
 [alias]
-    fancy-log  = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(cyan)<%an>%Creset' --abbrev-commit --date=relative
-    branches = for-each-ref --sort='-authordate:iso8601' --format=' %(color:green)%(authordate:iso8601) %(color:white)%(objectname:short) %09%(color:yellow)%(refname:short) %09%(color:white)%(upstream:track) %(contents:subject)' refs/heads --no-merged
-    edit-conflicted = ! git diff --name-only | uniq | xargs subl
+    fancy-log = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(cyan)<%an>%Creset' --abbrev-commit --date=relative
+    branches = for-each-ref --sort='-authordate:iso8601' --format=' %(color:green)%(authordate:relative) %09%(color:white)%(objectname:short) %(color:yellow)%(refname:short) %09%(color:white)%(upstream:track) %(contents:subject)' refs/heads --no-merged
+    timesheet = log --pretty=format:"%C(yellow)%h%Creset  %C(green)%ad%Creset  %C(cyan)%s" --author="`git config --get user.name`" --since='6am'
+    edit-conflicted = ! git diff --name-only | uniq | xargs code
+    history = log -p --
+	pushf = push --force-with-lease
+
 [core]
-	editor = subl -w
+	editor = vim
 	excludesfile = ~/.gitignore-global
 	whitespace = tab-in-indent,trailing-space,space-before-tab
 	ignorecase = false
+
+[merge]
+	tool = code
+
+[push]
+	default = upstream

+ 3 - 24
.gitignore

@@ -1,4 +1,4 @@
-### OSX ###
+# OSX
 .DS_Store
 .AppleDouble
 .LSOverride
@@ -7,11 +7,7 @@ Icon
 # Thumbnails
 ._*
 
-# Files that might appear on external disk
-.Spotlight-V100
-.Trashes
-
-### SublimeText ###
+# Sublime3
 *.sublime-workspace
 Sublime3/User/Package Control.last-run
 Sublime3/User/Package Control.ca-list
@@ -20,22 +16,5 @@ Sublime3/User/Package Control.system-ca-bundle
 Sublime3/User/Package Control.cache/
 Sublime3/User/Package Control.ca-certs/
 
-### Rails ###
-*.rbc
-*.sassc
-.sass-cache
-.rspec
-.rvmrc
-/.bundle
-/vendor/bundle
-/log/*
-/tmp/*
-/db/*.sqlite3
-/public/system/*
-/coverage/
-/spec/tmp/*
-**.orig
-.project
-
-### Other
+# local backups
 bak/

+ 7 - 0
.rc.d/aliases.sh

@@ -0,0 +1,7 @@
+# ls
+alias ll='ls -alF'
+alias la='ls -A'
+alias l='ls -CF'
+
+# http
+alias start-http='python -m SimpleHTTPServer'

+ 19 - 0
.rc.d/applications.sh

@@ -0,0 +1,19 @@
+# nvm
+if [ -d "${HOME}/.nvm" ]; then
+  export NVM_DIR="$HOME/.nvm"
+  [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
+fi
+
+# export golang bin path
+if [ -d "/usr/local/opt/go/libexec" ]; then
+  export PATH=$PATH:/usr/local/opt/go/libexec/bin
+fi
+
+# thefuck
+command -v thefuck 1>/dev/null && eval "$(thefuck --alias)"
+
+# rbenv
+command -v rbenv 1>/dev/null && eval "$(rbenv init -)"
+
+# brew
+command -v brew 1>/dev/null && export PATH="$(brew --prefix qt@5.5)/bin:$PATH"

+ 17 - 0
.rc.d/docker.sh

@@ -0,0 +1,17 @@
+alias dredisflush="docker-compose exec redis redis-cli FLUSHALL"
+alias dnewmigration="docker-compose exec web bundle exec rails generate migration"
+alias dmigrate="docker-compose exec web bundle exec rake db:migrate"
+alias drollback="docker-compose exec web bundle exec rake db:rollback"
+alias dtestmigrate="docker-compose exec -e RAILS_ENV=test web bundle exec rake db:migrate"
+alias dbundle="docker-compose exec web bundle"
+alias dbi="docker-compose exec web bundle install"
+alias drspec="docker-compose exec -e RAILS_ENV=test web bundle exec rspec"
+alias dconsole="docker-compose exec web bundle exec rails c"
+alias dsidekiq="docker-compose restart sidekiq"
+alias dreset="docker-compose exec web bundle exec rake db:reset"
+alias dtestreset="docker-compose exec -e RAILS_ENV=test web bundle exec rake db:reset"
+alias dupdate="dbi && dreset && dtestreset && dredisflush && dsidekiq"
+alias dswap="sed -i '' \"s/gem 'ap_shared'.*/gem 'ap_shared', path: '\.\.\/ap_shared'/\" Gemfile && dbi"
+alias pryweb="docker attach $(docker ps -q --filter Name=apiactivepipecom_web_1)"
+alias pryprefs="docker attach $(docker ps -q --filter Name=apiactivepipecom_prefs_1)"
+alias prysidekiq="docker attach $(docker ps -q --filter Name=apiactivepipecom_sidekiq_1)"

+ 71 - 0
.rc.d/git.sh

@@ -0,0 +1,71 @@
+alias g='git'
+
+alias ga='git add'
+alias gaa='git add --all'
+alias gapa='git add --patch'
+alias gau='git add --update'
+alias gap='git apply'
+
+alias gb='git branch'
+alias gba='git branch -a'
+alias gbd='git branch -d'
+alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
+alias gbl='git blame -b -w'
+alias gbnm='git branch --no-merged'
+alias gbr='git branch --remote'
+alias gbs='git bisect'
+alias gbsb='git bisect bad'
+alias gbsg='git bisect good'
+alias gbsr='git bisect reset'
+alias gbss='git bisect start'
+
+alias gc='git commit -v'
+alias gc!='git commit -v --amend'
+alias gcn!='git commit -v --no-edit --amend'
+alias gca='git commit -v -a'
+alias gca!='git commit -v -a --amend'
+alias gcan!='git commit -v -a --no-edit --amend'
+alias gcans!='git commit -v -a -s --no-edit --amend'
+alias gcam='git commit -a -m'
+alias gcsm='git commit -s -m'
+alias gcb='git checkout -b'
+alias gcf='git config --list'
+alias gcl='git clone --recursive'
+alias gclean='git clean -fd'
+alias gpristine='git reset --hard && git clean -dfx'
+alias gcmsg='git commit -m'
+alias gco='git checkout'
+alias gcount='git shortlog -sn'
+
+alias gcp='git cherry-pick'
+alias gcpa='git cherry-pick --abort'
+alias gcpc='git cherry-pick --continue'
+alias gcs='git commit -S'
+
+alias gd='git diff'
+alias gdca='git diff --cached'
+alias gdcw='git diff --cached --word-diff'
+alias gdct='git describe --tags `git rev-list --tags --max-count=1`'
+alias gdt='git diff-tree --no-commit-id --name-only -r'
+alias gdw='git diff --word-diff'
+
+alias gf='git fetch'
+alias gfa='git fetch --all --prune'
+alias gfo='git fetch origin'
+
+alias gsb='git status -sb'
+alias gsd='git svn dcommit'
+alias gsi='git submodule init'
+alias gsps='git show --pretty=short --show-signature'
+alias gsr='git svn rebase'
+alias gss='git status -s'
+alias gst='git status'
+alias gsta='git stash save'
+alias gstaa='git stash apply'
+alias gstc='git stash clear'
+alias gstd='git stash drop'
+alias gstl='git stash list'
+alias gstp='git stash pop'
+alias gsts='git stash show --text'
+alias gsu='git submodule update'
+

+ 13 - 88
.zshrc

@@ -1,96 +1,21 @@
-# Path to your oh-my-zsh installation.
-export ZSH=/Users/tom/.oh-my-zsh
-
-# Set name of the theme to load.
-# Look in ~/.oh-my-zsh/themes/
-# Optionally, if you set this to "random", it'll load a random theme each
-# time that oh-my-zsh is loaded.
-ZSH_THEME="robbyrussell"
-
-# Uncomment the following line to use case-sensitive completion.
-# CASE_SENSITIVE="true"
-
-# Uncomment the following line to use hyphen-insensitive completion. Case
-# sensitive completion must be off. _ and - will be interchangeable.
-# HYPHEN_INSENSITIVE="true"
-
-# Uncomment the following line to disable bi-weekly auto-update checks.
-# DISABLE_AUTO_UPDATE="true"
-
-# Uncomment the following line to change how often to auto-update (in days).
-# export UPDATE_ZSH_DAYS=13
-
-# Uncomment the following line to disable colors in ls.
-# DISABLE_LS_COLORS="true"
-
-# Uncomment the following line to disable auto-setting terminal title.
-# DISABLE_AUTO_TITLE="true"
-
-# Uncomment the following line to enable command auto-correction.
-# ENABLE_CORRECTION="true"
-
-# Uncomment the following line to display red dots whilst waiting for completion.
-COMPLETION_WAITING_DOTS="true"
-
-# Uncomment the following line if you want to disable marking untracked files
-# under VCS as dirty. This makes repository status check for large repositories
-# much, much faster.
-# DISABLE_UNTRACKED_FILES_DIRTY="true"
-
-# Uncomment the following line if you want to change the command execution time
-# stamp shown in the history command output.
-# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
-# HIST_STAMPS="mm/dd/yyyy"
-
-# Would you like to use another custom folder than $ZSH/custom?
-# ZSH_CUSTOM=/path/to/new-custom-folder
-
-# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
-# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
-# Example format: plugins=(rails git textmate ruby lighthouse)
-# Add wisely, as too many plugins slow down shell startup.
-plugins=(git nvm)
-
-# User configuration
-
-# export MANPATH="/usr/local/man:$MANPATH"
-
-source $ZSH/oh-my-zsh.sh
-
-# You may need to manually set your language environment
-# export LANG=en_US.UTF-8
-
-# Preferred editor for local and remote sessions
-# if [[ -n $SSH_CONNECTION ]]; then
-#   export EDITOR='vim'
-# else
-#   export EDITOR='mvim'
-# fi
-
-# Compilation flags
-# export ARCHFLAGS="-arch x86_64"
-
-# ssh
-# export SSH_KEY_PATH="~/.ssh/dsa_id"
+# load all files from .shell/zshrc.d directory
+if [ -d $HOME/.zshrc.d ]; then
+  for file in $HOME/.zshrc.d/*.zsh; do
+    source $file
+  done
+fi
 
-# Set personal aliases, overriding those provided by oh-my-zsh libs,
-# plugins, and themes. Aliases can be placed here, though oh-my-zsh
-# users are encouraged to define aliases within the ZSH_CUSTOM folder.
-# For a full list of active aliases, run `alias`.
-#
-# Example aliases
-# alias zshconfig="mate ~/.zshrc"
-# alias ohmyzsh="mate ~/.oh-my-zsh"
+# load all files from .shell/rc.d directory
+if [ -d $HOME/.rc.d ]; then
+  for file in $HOME/.rc.d/*.sh; do
+    source $file
+  done
+fi
 
 if [[ -n $SSH_CONNECTION ]]; then
   export EDITOR='vim'
 else
-  export EDITOR='subl'
+  export EDITOR='code'
 fi
 
 export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
-
-test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
-
-export NVM_DIR="/Users/tom/.nvm"
-[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

+ 21 - 0
.zshrc.d/bindkey.sh

@@ -0,0 +1,21 @@
+typeset -g -A key
+
+bindkey -e
+
+bindkey '^H' delete-word # iterm
+bindkey '^[[3~' delete-char # tmux
+
+bindkey '^[[1;9D' backward-word # iterm
+bindkey '^[^[[D' backward-word # tmux os x
+bindkey '^[[1;3D' backward-word # tmux ubuntu
+
+bindkey '^[[1;9C' forward-word # iterm
+bindkey '^[^[[C' forward-word # tmux os x
+bindkey '^[[1;3C' forward-word # tmux ubuntu
+
+
+bindkey '^[[H' beginning-of-line # iterm
+bindkey '^[[1~' beginning-of-line # tmux
+
+bindkey '^[[F' end-of-line # iterm
+bindkey '^[[4~' end-of-line # tmux

+ 2 - 0
.zshrc.d/iterm.zsh

@@ -0,0 +1,2 @@
+# iterm2
+test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"

+ 26 - 0
.zshrc.d/zgen.zsh

@@ -0,0 +1,26 @@
+# guard against no zgen installed
+if [ ! -d "${HOME}/.zgen" ]; then
+  echo "zgen not installed"
+  return
+fi
+
+
+# load zgen
+source "${HOME}/.zgen/zgen.zsh"
+
+# if the init scipt doesn't exist
+if ! zgen saved; then
+  echo "Saving zgen config"
+
+  # bulk load
+  zgen loadall <<EOPLUGINS
+    mreinhardt/sfz-prompt.zsh
+EOPLUGINS
+  # ^ can't indent this EOPLUGINS
+
+  # completions
+  zgen load zsh-users/zsh-completions src
+
+  # save all to init script
+  zgen save
+fi

+ 9 - 1
README.md

@@ -4,4 +4,12 @@ Not totally organised yet, but includes the important things.
 
 * iTerm profile setting
 * git and bash aliases
-* simpleHTTPServer etc. shortcuts 
+* simpleHTTPServer etc. shortcuts
+
+* Loads [zgen](https://github.com/tarjoilija/zgen) under zsh
+* `.rc.d` directory idea borrowed from https://github.com/chr4/shellrc
+
+
+# todo
+
+* Use `felixgravila/zsh-abbr-path` for RPROMPT

+ 0 - 88
notes/ubuntusetup-apache-rails

@@ -1,88 +0,0 @@
-# based on: https://gist.github.com/statique/3783870
-# http://askubuntu.com/questions/31922/problem-installing-ruby-and-gems/31924#31924
-# https://github.com/wavedigital/Wave-Digital/wiki/PasswordlessSsh
-
-
-
-# rbenv inspired by https://gist.github.com/1441139
-# make sure running as root user
-
-apt-get -y update
-apt-get install linux-headers-2.6.32-5-amd64
-apt-get -y upgrade
-apt-get -y install curl git-core python-software-properties build-essential git-core curl libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev libcurl4-openssl-dev libxslt-dev libxml2-dev
-
-# sudo apt-get update && sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev -y
-
-
-
-# add-apt-repository
-curl -o /usr/sbin/add-apt-repository  http://blog.anantshri.info/content/uploads/2010/09/add-apt-repository.sh.txtchmod o+x /usr/sbin/add-apt-repository
-chown root:root /usr/sbin/add-apt-repository
-
-# Apache
-apt-get install apache2
-apt-get install libapache2-mod-passenger
-service apache2 start
-
-# Node.jsadd-apt-repository ppa:chris-lea/node.js
-apt-get -y update
-apt-get -y install nodejs
-
-# Memcached
-apt-get -y install memcached
-service memcached start
-
-# Install Firewall
-apt-get -y install ufw
-ufw allow 22
-ufw allow 80
-ufw enable
-# rbenv
-
-# Install rbenv
-git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
-
-# Add rbenv to the path:
-echo '# rbenv setup' > /etc/profile.d/rbenv.sh
-echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh
-echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
-echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
-
-chmod +x /etc/profile.d/rbenv.sh
-source /etc/profile.d/rbenv.sh
-
-# Install ruby-build:
-pushd /tmp
-  git clone git://github.com/sstephenson/ruby-build.git
-  cd ruby-build
-  ./install.sh
-popd
-
-# Install Ruby 1.9.3-p194:
-rbenv install 1.9.3-p194
-rbenv global 1.9.3-p194
-
-cat << EOF > /root/.gemrc
----
-:verbose: true
-:bulk_threshold: 1000
-install: --no-ri --no-rdoc --env-shebang
-:sources:
-- http://gems.rubyforge.org/
-:benchmark: false
-:backtrace: false
-update: --no-ri --no-rdoc --env-shebang
-:update_sources: true
-EOF
-
-rbenv rehash
-
-gem update --system
-gem install bundler
-
-# Add deployer user
-adduser deployer --ingroup sudo
-su deployer
-
-shutdown -r now

+ 0 - 28
private.xml

@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<root>
-  <item>
-    <name>0. Custom stuff</name>
-    <item>
-      <name>Mouse5 (up) to Expose All</name>
-      <identifier>remap.mouse5toexposeall</identifier>
-      <autogen>
-        __PointingRelativeToScroll__
-        PointingButton::BUTTON5,
-
-        Option::POINTINGRELATIVETOSCROLL_TOKEYS,
-        KeyCode::EXPOSE_ALL, ,
-      </autogen>
-    </item>
-    <item>
-      <name>Mouse4 (down) to Expose App</name>
-      <identifier>remap.mouse4toexposeapp</identifier>
-      <autogen>
-        __PointingRelativeToScroll__
-        PointingButton::BUTTON4,
-
-        Option::POINTINGRELATIVETOSCROLL_TOKEYS,
-        KeyCode::EXPOSE_ALL, ModifierFlag::CONTROL_L,
-      </autogen>
-    </item>
-  </item>
-</root>

+ 1 - 1
setup.sh

@@ -1,7 +1,7 @@
 # symlink dotfiles
 dir=~/dotfiles
 olddir=~/dotfiles/bak   # backup directory
-files=".zshrc .bashrc .vimrc .bash_logout .gitconfig .gitignore .gemrc"    # list of files/folders to symlink in homedir
+files=".zshrc .zshrc.d .rc.d .bashrc .vimrc .bash_logout .gitconfig .gitignore .gemrc"    # list of files/folders to symlink in homedir
 
 ## create dotfiles_old in homedir
 mkdir -p $olddir