├── remote.yml ├── .gitignore ├── roles ├── dev │ ├── files │ │ ├── ideavimrc │ │ └── create_db_restore.sh │ └── tasks │ │ └── main.yml ├── python │ ├── files │ │ └── pip.conf │ └── tasks │ │ └── main.yml ├── homebrew │ └── tasks │ │ └── main.yml ├── golang │ └── tasks │ │ └── main.yml ├── utils │ ├── files │ │ ├── configure │ │ ├── reconfigure │ │ └── ripgreprc │ └── tasks │ │ └── main.yml ├── docker │ └── tasks │ │ └── main.yml ├── node │ └── tasks │ │ └── main.yml ├── git │ └── tasks │ │ └── main.yml ├── haskell │ └── tasks │ │ └── main.yml ├── postgresql │ ├── files │ │ └── psqlrc │ └── tasks │ │ └── main.yml ├── ruby │ ├── tasks │ │ └── main.yml │ └── files │ │ └── rvm_installer.sh ├── tmux │ ├── tasks │ │ └── main.yml │ └── files │ │ └── tmux.conf ├── zsh │ ├── tasks │ │ └── main.yml │ └── files │ │ └── zshrc ├── common │ └── tasks │ │ └── main.yml └── vim │ ├── tasks │ └── main.yml │ └── files │ ├── basic.vim │ └── pathogen-24.vim ├── hosts ├── ansible.cfg ├── .gitmodules ├── local.yml ├── bootstrap.sh └── README.md /remote.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.retry 2 | -------------------------------------------------------------------------------- /roles/dev/files/ideavimrc: -------------------------------------------------------------------------------- 1 | source ~/.vimrc 2 | -------------------------------------------------------------------------------- /roles/python/files/pip.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | index-url = https://pypi.io/simple 3 | -------------------------------------------------------------------------------- /hosts: -------------------------------------------------------------------------------- 1 | [local] 2 | localhost ansible_connection=local ansible_user=benlopatin 3 | -------------------------------------------------------------------------------- /ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | inventory = hosts 3 | transport = local 4 | become_user = root 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "wiki"] 2 | path = wiki 3 | url = git@github.com:bennylope/macbook-configuration.wiki.git 4 | -------------------------------------------------------------------------------- /roles/homebrew/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: update homebrew 3 | command: brew update 4 | when: ansible_os_family == 'Darwin' 5 | -------------------------------------------------------------------------------- /roles/golang/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install go (Mac) 3 | homebrew: 4 | name: 5 | - go 6 | state: present 7 | when: ansible_os_family == 'Darwin' 8 | -------------------------------------------------------------------------------- /roles/utils/files/configure: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Why this file, you ask? Because lazy. 4 | 5 | ansible-playbook ~/.config.d/local.yml -K -i ~/.config.d/hosts "$@" 6 | -------------------------------------------------------------------------------- /roles/docker/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install go (Mac) 3 | homebrew: 4 | name: 5 | - docker 6 | - docker-compose 7 | state: present 8 | when: ansible_os_family == 'Darwin' 9 | -------------------------------------------------------------------------------- /roles/node/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install Node (Mac) 3 | homebrew: 4 | name: 5 | - node 6 | - yarn 7 | state: present 8 | when: ansible_os_family == 'Darwin' 9 | tags: node 10 | -------------------------------------------------------------------------------- /roles/git/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install Git stuff 3 | homebrew: 4 | name: 5 | - git 6 | - git-extras 7 | - tig 8 | state: latest 9 | when: ansible_os_family == 'Darwin' 10 | tags: git 11 | -------------------------------------------------------------------------------- /roles/haskell/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install Haskell (Mac) 3 | homebrew: 4 | name: 5 | - ghc 6 | - haskell-stack 7 | state: present 8 | when: ansible_os_family == 'Darwin' 9 | tags: haskell 10 | -------------------------------------------------------------------------------- /roles/utils/files/reconfigure: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Why this file, you ask? Because lazy. 4 | 5 | cd ~/.config.d 6 | vim . 7 | git commit -a 8 | 9 | # This is *kind* of silly - it should be replaced by asking whether to run the configuration again. 10 | configure "$@" 11 | -------------------------------------------------------------------------------- /local.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: local 3 | roles: 4 | - homebrew 5 | - utils 6 | - tmux 7 | - git 8 | - zsh 9 | - vim 10 | - golang 11 | - docker 12 | - python 13 | - postgresql 14 | - haskell 15 | - node 16 | - dev 17 | - common 18 | #- ruby 19 | -------------------------------------------------------------------------------- /roles/postgresql/files/psqlrc: -------------------------------------------------------------------------------- 1 | \set QUIET 1 2 | \timing 3 | \set ON_ERROR_ROLLBACK interactive 4 | \set VERBOSITY verbose 5 | \x auto 6 | \set PROMPT1 '%[%033[1m%]%M/%/%R%[%033[0m%]%# ' 7 | \set PROMPT2 '' 8 | \set HISTFILE ~/.psql_history- :DBNAME 9 | \set HISTCONTROL ignoredups 10 | \pset null [null] 11 | \unset QUIET 12 | -------------------------------------------------------------------------------- /roles/ruby/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install rvm 3 | shell: > 4 | curl -L https://get.rvm.io | bash 5 | creates=~/.rvm 6 | 7 | - name: update rvm 8 | command: rvm get head 9 | 10 | - name: install Rubies 11 | command: rvm install {{ item }} 12 | with_items: 13 | - 1.9.3-p448 14 | - 2.0.0-p247 15 | -------------------------------------------------------------------------------- /roles/utils/files/ripgreprc: -------------------------------------------------------------------------------- 1 | # Don't let ripgrep vomit really long lines to my terminal, and show a preview. 2 | --max-columns=150 3 | --max-columns-preview 4 | 5 | # Add my 'web' type. 6 | --type-add 7 | web:*.{html,css,js}* 8 | 9 | --type-add 10 | vue:*.vue 11 | 12 | 13 | # Using glob patterns to include/exclude files or folders 14 | --glob=!git/* 15 | -------------------------------------------------------------------------------- /roles/dev/files/create_db_restore.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BACKUP_PATH="$HOME/Downloads/$(ls -t ~/Downloads | head -1)" 4 | DB=$1 5 | 6 | echo "Creating database name $DB" 7 | 8 | psql -c "CREATE DATABASE $DB;" "${@:2}" 9 | 10 | echo "Now restoring database $DB from $BACKUP_PATH" 11 | 12 | #pg_restore -O -x -d $1 "~/Downloads| head -1)" "${@:2}" 13 | pg_restore -O -x -d $DB $BACKUP_PATH "${@:2}" 14 | -------------------------------------------------------------------------------- /roles/postgresql/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install Postgres.app (Mac) 3 | homebrew_cask: name=postgres state=present install_options="appdir=/Applications" 4 | tags: postgres 5 | 6 | - name: Add psql config 7 | copy: src=psqlrc dest=~/.psqlrc 8 | tags: postgres 9 | 10 | - name: Install PostgreSQL pref pane 11 | homebrew_cask: 12 | name: postgrespreferencepane 13 | state: installed 14 | when: ansible_os_family == 'Darwin' 15 | tags: postgres 16 | -------------------------------------------------------------------------------- /roles/tmux/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install tmux 3 | homebrew: 4 | name: 5 | - tmux 6 | state: latest 7 | when: ansible_os_family == 'Darwin' 8 | tags: tmux 9 | 10 | - name: Add tmux.conf 11 | copy: src=tmux.conf dest=~/.tmux.conf 12 | tags: tmux 13 | 14 | 15 | - name: Add .tmux plugins directory 16 | file: 17 | name: ~/.tmux/plugins 18 | state: directory 19 | recurse: yes 20 | tags: tmux 21 | 22 | - name: Add tmux plugin manager 23 | git: repo=https://github.com/tmux-plugins/tpm.git 24 | dest=~/.tmux/plugins/tpm 25 | version=v3.0.0 26 | tags: tmux 27 | -------------------------------------------------------------------------------- /roles/utils/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install CLI tools 3 | homebrew: 4 | name: 5 | - tree 6 | - readline 7 | - wget 8 | - ack 9 | - ctags 10 | - sloccount 11 | - autoenv 12 | - ripgrep 13 | - jq 14 | - hledger 15 | - mutt 16 | #- hub 17 | #- s3cmd 18 | #- siege 19 | state: present 20 | when: ansible_os_family == 'Darwin' 21 | tags: utils 22 | 23 | - name: Miscellany 24 | homebrew: 25 | name: 26 | - privoxy 27 | state: present 28 | when: ansible_os_family == 'Darwin' 29 | tags: utils 30 | 31 | - name: Add configuration script 32 | file: 33 | src: ~/.config.d/roles/utils/files/configure 34 | dest: /usr/local/bin/configure 35 | state: link 36 | tags: utils 37 | 38 | - name: Add reconfiguration script 39 | file: 40 | src: ~/.config.d/roles/utils/files/reconfigure 41 | dest: /usr/local/bin/reconfigure 42 | state: link 43 | tags: utils 44 | -------------------------------------------------------------------------------- /roles/python/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install virtualenv 3 | command: > 4 | /usr/local/bin/pip install virtualenv 5 | creates=/usr/local/bin/virtualenv 6 | tags: python 7 | 8 | - name: Install virtualenvwrapper 9 | pip: 10 | name: 11 | - virtualenvwrapper 12 | tags: python 13 | 14 | - name: Install OpenSSL for Python 15 | homebrew: 16 | name: openssl 17 | state: linked 18 | tags: python 19 | 20 | - name: Tap older Python repo 21 | homebrew_tap: name=derekkwok/python 22 | tags: python 23 | 24 | - name: Install Python versions 25 | homebrew: 26 | name: 27 | - python 28 | - python3 29 | - python33 30 | - python34 31 | - python35 32 | - pypy 33 | state: present 34 | tags: python 35 | 36 | - name: Add pip directory 37 | file: 38 | name: ~/.pip 39 | state: directory 40 | tags: python 41 | 42 | - name: Setup pip configuration 43 | copy: > 44 | dest=~/.pip/pip.conf 45 | src=pip.conf 46 | tags: python 47 | -------------------------------------------------------------------------------- /roles/zsh/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install zsh 3 | homebrew: name=zsh state=latest 4 | when: ansible_os_family == 'Darwin' 5 | tags: zsh 6 | 7 | - name: add zsh to list of shells 8 | lineinfile: > 9 | backup=yes 10 | dest=/etc/shells 11 | regexp=^/usr/local/bin/zsh 12 | line=/usr/local/bin/zsh 13 | when: ansible_os_family == 'Darwin' 14 | become: true 15 | 16 | - name: change to zsh (Mac) 17 | shell: chsh -s /usr/local/bin/zsh {{ ansible_env.USER }} 18 | when: ansible_os_family == 'Darwin' 19 | 20 | - name: change to zsh (Ubuntu) 21 | shell: chsh -s /usr/bin/zsh {{ ansible_env.USER }} 22 | when: ansible_os_family == 'Ubuntu' 23 | 24 | - name: install oh-my-zsh 25 | git: repo=https://github.com/robbyrussell/oh-my-zsh.git 26 | dest=~/.oh-my-zsh 27 | recursive=yes 28 | tags: zsh 29 | 30 | - name: Ensure oh-my-zsh-custom directory 31 | file: 32 | name: ~/.oh-my-zsh-custom 33 | state: directory 34 | tags: zsh 35 | 36 | - name: add zshrc file 37 | copy: src=zshrc dest=~/.zshrc 38 | tags: zsh 39 | -------------------------------------------------------------------------------- /roles/common/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Add browsers 3 | homebrew_cask: 4 | name: 5 | - firefox 6 | - google-chrome 7 | - opera 8 | state: present 9 | when: ansible_os_family == 'Darwin' 10 | tags: common 11 | 12 | - name: Add desktop utility tools 13 | homebrew_cask: 14 | name: 15 | - cloak 16 | - dash 17 | - alfred 18 | - flux 19 | - cleanmymac 20 | - caffeine 21 | - airfoil 22 | - smcfancontrol 23 | - gpgtools 24 | - keybase 25 | - java 26 | - handbrake 27 | state: present 28 | when: ansible_os_family == 'Darwin' 29 | tags: common 30 | 31 | - name: Add general desktop tools 32 | homebrew_cask: 33 | name: 34 | - iterm2 35 | - libreoffice 36 | - balsamiq-mockups 37 | - airfoil 38 | - dropbox 39 | - google-drive 40 | - send-to-kindle 41 | - skype 42 | - transmit 43 | - keepassx 44 | - fluid 45 | state: present 46 | when: ansible_os_family == 'Darwin' 47 | tags: common 48 | 49 | - name: Add screenshots directory 50 | file: 51 | path: "~/Desktop/Screenshots" 52 | state: directory 53 | when: ansible_os_family == 'Darwin' 54 | tags: 55 | - common 56 | - macos 57 | 58 | - name: Get current screenshot directory 59 | command: defaults read com.apple.screencapture location 60 | register: current_screenshot_directory 61 | when: ansible_os_family == 'Darwin' 62 | tags: 63 | - common 64 | - macos 65 | 66 | -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Purpose: 3 | # * bootstrap machine in order to prepare for ansible playbook run 4 | 5 | set -e 6 | 7 | # Download and install Command Line Tools if no developer tools exist 8 | # * previous evaluation didn't work completely, due to gcc binary existing for vanilla os x install 9 | # * gcc output on vanilla osx box: 10 | # * 'xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. 11 | # * Choose an option in the dialog to download the command line developer tools' 12 | # 13 | # Evaluate 2 conditions 14 | # * ensure dev tools are installed by checking the output of gcc 15 | # * check to see if gcc binary even exists ( original logic ) 16 | # if either of the conditions are met, install dev tools 17 | if [[ $(/usr/bin/gcc 2>&1) =~ "no developer tools were found" ]] || [[ ! -x /usr/bin/gcc ]]; then 18 | echo "Info | Install | xcode" 19 | xcode-select --install 20 | fi 21 | 22 | # Download and install Homebrew 23 | if [[ ! -x /usr/local/bin/brew ]]; then 24 | echo "Info | Install | homebrew" 25 | ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" 26 | fi 27 | 28 | 29 | # Download and install Ansible 30 | if [[ ! -x /usr/local/bin/ansible ]]; then 31 | echo "Info | Install | Ansible" 32 | brew update 33 | brew install ansible 34 | fi 35 | 36 | # Modify the PATH 37 | # This should be subsequently updated in shell settings 38 | export PATH=/usr/local/bin:$PATH 39 | 40 | ansible-playbook local.yml -K 41 | -------------------------------------------------------------------------------- /roles/zsh/files/zshrc: -------------------------------------------------------------------------------- 1 | # Path to your oh-my-zsh configuration. 2 | ZSH=$HOME/.oh-my-zsh 3 | 4 | ZSH_CUSTOM=$HOME/.oh-my-zsh-custom 5 | 6 | # Set name of the theme to load. 7 | # Look in ~/.oh-my-zsh/themes/ 8 | # Optionally, if you set this to "random", it'll load a random theme each 9 | # time that oh-my-zsh is loaded. 10 | ZSH_THEME="ys" 11 | 12 | export EDITOR='vim' 13 | 14 | # Example aliases 15 | # alias zshconfig="mate ~/.zshrc" 16 | # alias ohmyzsh="mate ~/.oh-my-zsh" 17 | 18 | 19 | # Uncomment this to disable bi-weekly auto-update checks 20 | # DISABLE_AUTO_UPDATE="true" 21 | 22 | # Uncomment to change how often before auto-updates occur? (in days) 23 | # export UPDATE_ZSH_DAYS=13 24 | 25 | 26 | # Uncomment following line if you want to disable autosetting terminal title. 27 | # DISABLE_AUTO_TITLE="true" 28 | 29 | # Uncomment following line if you want to disable command autocorrection 30 | # DISABLE_CORRECTION="true" 31 | 32 | # Uncomment following line if you want red dots to be displayed while waiting for completion 33 | COMPLETION_WAITING_DOTS="true" 34 | 35 | # Uncomment following line if you want to disable marking untracked files under 36 | # VCS as dirty. This makes repository status check for large repositories much, 37 | # much faster. 38 | # DISABLE_UNTRACKED_FILES_DIRTY="true" 39 | 40 | # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) 41 | # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ 42 | # Example format: plugins=(rails git textmate ruby lighthouse) 43 | plugins=(git heroku) 44 | 45 | source $ZSH/oh-my-zsh.sh 46 | 47 | # Customize to your needs... 48 | 49 | #PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting 50 | # source /usr/local/opt/autoenv/activate.sh 51 | -------------------------------------------------------------------------------- /roles/tmux/files/tmux.conf: -------------------------------------------------------------------------------- 1 | #### COLOUR (Solarized light) 2 | 3 | # default statusbar colors 4 | set-option -g status-bg colour231 #base2 5 | set-option -g status-fg colour130 #yellow 6 | set-option -g status-attr default 7 | 8 | # default window title colors 9 | set-window-option -g window-status-fg colour180 #base00 10 | set-window-option -g window-status-bg default 11 | #set-window-option -g window-status-attr dim 12 | 13 | # active window title colors 14 | set-window-option -g window-status-current-fg colour196 #orange 15 | set-window-option -g window-status-current-bg default 16 | #set-window-option -g window-status-current-attr bright 17 | 18 | # pane border 19 | set-option -g pane-border-fg colour231 #base2 20 | set-option -g pane-active-border-fg colour051 #base1 21 | 22 | # message text 23 | set-option -g message-bg colour231 #base2 24 | set-option -g message-fg colour196 #orange 25 | 26 | # pane number display 27 | set-option -g display-panes-active-colour colour20 #blue 28 | set-option -g display-panes-colour colour196 #orange 29 | 30 | # clock 31 | set-window-option -g clock-mode-colour colour40 #green 32 | 33 | ### WINDOWS 34 | 35 | # naming 36 | set-option -g allow-rename off 37 | 38 | # vim-bindings for pane traversal 39 | bind h select-pane -L 40 | bind j select-pane -D 41 | bind k select-pane -U 42 | bind l select-pane -R 43 | 44 | # scrolling 45 | set -g mouse on 46 | 47 | ### MISC 48 | 49 | # Hot reload tmux configuration 50 | bind r source-file ~/.tmux.conf \; display-message "Config reloaded." 51 | 52 | ### PLUGINS 53 | set -g @plugin 'tmux-plugins/tpm' # tmux plugin manager 54 | set -g @plugin 'tmux-plugins/tmux-resurrect' # tmux session saving/restore 55 | set -g @plugin 'tmux-plugins/tmux-continuum' # tmux auto-session saving 56 | set -g @plugin 'tmux-plugins/tmux-yank' # vim like link yanking 57 | set -g @plugin 'tmux-plugins/tmux-copycat' # regex searches in tmux 58 | # Keep this line at the very bottom 59 | run '~/.tmux/plugins/tpm/tpm' 60 | -------------------------------------------------------------------------------- /roles/vim/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install vim (Mac) 3 | homebrew: 4 | name: 5 | - vim 6 | state: present 7 | when: ansible_os_family == 'Darwin' 8 | tags: vim 9 | 10 | - name: tap neovim (Mac) 11 | homebrew_tap: 12 | name: neovim/neovim 13 | state: present 14 | when: ansible_os_family == 'Darwin' 15 | tags: vim 16 | 17 | - name: install neovim (Mac) 18 | homebrew: 19 | name: 20 | - neovim 21 | state: present 22 | when: ansible_os_family == 'Darwin' 23 | tags: vim 24 | 25 | - name: install vim (Ubuntu) 26 | apt: pkg=vim state=present 27 | when: ansible_os_family == 'Ubuntu' 28 | tags: vim 29 | 30 | - name: add vim autoload dir 31 | file: 32 | name: ~/.vim/autoload 33 | state: directory 34 | recurse: yes 35 | tags: vim 36 | 37 | - name: add vim bundle dir 38 | file: 39 | name: ~/.vim/bundle 40 | state: directory 41 | recurse: yes 42 | tags: vim 43 | 44 | - name: install Pathogen 45 | copy: 46 | src: pathogen-24.vim 47 | dest: ~/.vim/autoload/pathogen.vim 48 | tags: vim 49 | 50 | - name: add vimrc 51 | copy: src=basic.vim dest=~/.vimrc 52 | tags: vim 53 | 54 | - name: install vim plugins 55 | git: repo={{ item.repo}} dest=~/.vim/bundle/{{ item.name }} 56 | with_items: 57 | - { repo: "https://github.com/scrooloose/nerdtree.git", name: "nerdtree", force: "yes" } 58 | - { repo: "https://github.com/ctrlpvim/ctrlp.vim.git", name: "ctrlp", force: "yes" } 59 | - { repo: "https://github.com/vim-syntastic/syntastic.git", name: "syntastic", force: "yes" } 60 | - { repo: "https://github.com/altercation/vim-colors-solarized.git", name: "solarized", force: "yes" } 61 | - { repo: "https://github.com/nvie/vim-flake8.git", name: "flake8", force: "yes" } 62 | - { repo: "https://github.com/davidhalter/jedi-vim.git", name: "jedi-vim", force: "yes" } 63 | - { repo: "https://github.com/jremmen/vim-ripgrep", name: "vim-ripgrep", force: "yes" } 64 | tags: vim 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Personal computer configuration. 2 | 3 | This is my personal MacBook configuration. There are many like it, but 4 | this one is mine. 5 | 6 | For that reason it's largely set up for my particular needs. If you want 7 | to use it yourself I'd recommend reading through it first. Remove as 8 | much as possible and build up, making changes as you go, so it fits your 9 | needs. 10 | 11 | ### Set up 12 | 13 | Run the bootstrap script. This will ensure gcc, 14 | [Homebrew](http://brew.sh/), and [Ansible](http://docs.ansible.com/) are 15 | installed: 16 | 17 | $ ./bootstrap.sh 18 | 19 | After installing the prerequisites this will run the `local` playbook 20 | for the first time. The script `configure` is now in `/usr/local/bin` 21 | and you can just execute that script: 22 | 23 | $ configure 24 | 25 | It's a shortcut to this command, as it would be run from the 26 | configuration directory: 27 | 28 | $ ansible-playbook install.yml -K 29 | 30 | The `-K` flag means that Ansible will prompt you for your sudo password 31 | before it executes the playbook. 32 | 33 | If it's your first time, go brew some coffee or tea because this will 34 | take some time building packages. 35 | 36 | ### Why? 37 | 38 | When planning to replace my previous computer I wanted to make sure I 39 | could replicate the environment. More specifically, only the aspects of 40 | the previous environment that I wanted to keep. 41 | 42 | GitHub's Boxen looked great but overkill, and I wanted to learn Ansible, 43 | so here we are. 44 | 45 | ### Credits 46 | 47 | The original inspiration was Michael Griffin's 48 | [ansible-playbooks](https://github.com/MWGriffin/ansible-playbooks) 49 | repository. That collection is far more complete. 50 | 51 | I later borrowed some bootstrap scripting from Daniel Jaouen's 52 | blog post, [How I Fully Automated OS X Provisioning With 53 | Ansible](http://il.luminat.us/2014/04/19/how-i-fully-automated-os-x-with-ansible.html). 54 | 55 | ### License 56 | 57 | This work is in the public domain. 58 | -------------------------------------------------------------------------------- /roles/dev/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install development libraries (Mac) 3 | homebrew: 4 | name: 5 | - libevent 6 | - libmemcached 7 | - libxml2 8 | - libffi 9 | - gdal 10 | - gmp 11 | state: present 12 | when: ansible_os_family == 'Darwin' 13 | tags: dev 14 | 15 | #- name: unlink keg only 16 | #command: brew unlink {{ item}} 17 | #with_items: 18 | # - libxml2 19 | #when: ansible_os_family == 'Darwin' 20 | 21 | - name: install dev CLI tools 22 | homebrew: 23 | name: 24 | - heroku 25 | - rg 26 | - bat 27 | - z 28 | - fd 29 | - exa 30 | - shellcheck 31 | state: present 32 | when: ansible_os_family == 'Darwin' 33 | tags: dev 34 | 35 | - name: install testing tools 36 | homebrew: 37 | name: 38 | - chromedriver 39 | state: present 40 | when: ansible_os_family == 'Darwin' 41 | tags: 42 | - dev 43 | - testing 44 | 45 | - name: install backing services (Mac) 46 | homebrew: 47 | name: 48 | - redis 49 | - memcached 50 | - mysql 51 | #- elasticsearch 52 | state: present 53 | when: ansible_os_family == 'Darwin' 54 | tags: dev 55 | 56 | - name: Add development desktop tools 57 | homebrew_cask: 58 | name: 59 | - pycharm 60 | - sequel-pro 61 | - postico 62 | - ngrok 63 | - aws-vault 64 | state: present 65 | when: ansible_os_family == 'Darwin' 66 | tags: dev 67 | 68 | - name: Virtualization for dev 69 | homebrew_cask: 70 | name: 71 | - virtualbox 72 | - vagrant 73 | - docker 74 | state: present 75 | when: ansible_os_family == 'Darwin' 76 | tags: dev 77 | 78 | - name: Add ideavimrc 79 | copy: 80 | src: ideavimrc 81 | dest: ~/.ideavimrc 82 | tags: dev 83 | 84 | - name: Add DB restoration helper 85 | copy: 86 | src: create_db_restore.sh 87 | dest: ~/create_db_restore.sh 88 | mode: preserve 89 | tags: dev 90 | 91 | # These are libraries that are installed but the Homebrew *module* fails on; 92 | # not Homebrew by itself. At the end b/c they will fail but that's okay. 93 | # They're here to track config until the problem can be identified and solved. 94 | #- name: install problem libraries (Mac) 95 | # homebrew: name={{ item }} state=present 96 | # with_items: 97 | # - libgeoip 98 | # when: ansible_os_family == 'Darwin' 99 | -------------------------------------------------------------------------------- /roles/vim/files/basic.vim: -------------------------------------------------------------------------------- 1 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 2 | " Maintainer: 3 | " Amir Salihefendic 4 | " http://amix.dk - amix@amix.dk 5 | " 6 | " Version: 7 | " 5.0 - 29/05/12 15:43:36 8 | " 9 | " Blog_post: 10 | " http://amix.dk/blog/post/19691#The-ultimate-Vim-configuration-on-Github 11 | " 12 | " Awesome_version: 13 | " Get this config, nice color schemes and lots of plugins! 14 | " 15 | " Install the awesome version from: 16 | " 17 | " https://github.com/amix/vimrc 18 | " 19 | " Syntax_highlighted: 20 | " http://amix.dk/vim/vimrc.html 21 | " 22 | " Raw_version: 23 | " http://amix.dk/vim/vimrc.txt 24 | " 25 | " Sections: 26 | " -> General 27 | " -> VIM user interface 28 | " -> Colors and Fonts 29 | " -> Files and backups 30 | " -> Text, tab and indent related 31 | " -> Visual mode related 32 | " -> Moving around, tabs and buffers 33 | " -> Status line 34 | " -> Editing mappings 35 | " -> vimgrep searching and cope displaying 36 | " -> Spell checking 37 | " -> Misc 38 | " -> Helper functions 39 | " 40 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 41 | 42 | 43 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 44 | " => General 45 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 46 | " Sets how many lines of history VIM has to remember 47 | set history=500 48 | 49 | " Enable filetype plugins 50 | filetype plugin on 51 | filetype indent on 52 | 53 | " Set to auto read when a file is changed from the outside 54 | set autoread 55 | 56 | " With a map leader it's possible to do extra key combinations 57 | " like w saves the current file 58 | let mapleader = "," 59 | let g:mapleader = "," 60 | 61 | " Fast saving 62 | nmap w :w! 63 | 64 | " :W sudo saves the file 65 | " (useful for handling the permission-denied error) 66 | command W w !sudo tee % > /dev/null 67 | 68 | 69 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 70 | " => VIM user interface 71 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 72 | " Set 7 lines to the cursor - when moving vertically using j/k 73 | set so=7 74 | 75 | " Avoid garbled characters in Chinese language windows OS 76 | let $LANG='en' 77 | set langmenu=en 78 | source $VIMRUNTIME/delmenu.vim 79 | source $VIMRUNTIME/menu.vim 80 | 81 | " Turn on the WiLd menu 82 | set wildmenu 83 | 84 | " Ignore compiled files 85 | set wildignore=*.o,*~,*.pyc 86 | if has("win16") || has("win32") 87 | set wildignore+=.git\*,.hg\*,.svn\* 88 | else 89 | set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store 90 | endif 91 | 92 | "Always show current position 93 | set ruler 94 | 95 | " Height of the command bar 96 | set cmdheight=2 97 | 98 | " A buffer becomes hidden when it is abandoned 99 | set hid 100 | 101 | " Configure backspace so it acts as it should act 102 | set backspace=eol,start,indent 103 | set whichwrap+=<,>,h,l 104 | 105 | " Ignore case when searching 106 | set ignorecase 107 | 108 | " When searching try to be smart about cases 109 | set smartcase 110 | 111 | " Highlight search results 112 | set hlsearch 113 | 114 | " Makes search act like search in modern browsers 115 | set incsearch 116 | 117 | " Don't redraw while executing macros (good performance config) 118 | set lazyredraw 119 | 120 | " For regular expressions turn magic on 121 | set magic 122 | 123 | " Show matching brackets when text indicator is over them 124 | set showmatch 125 | " How many tenths of a second to blink when matching brackets 126 | set mat=2 127 | 128 | " No annoying sound on errors 129 | set noerrorbells 130 | set novisualbell 131 | set t_vb= 132 | set tm=500 133 | 134 | 135 | " Add a bit extra margin to the left 136 | set foldcolumn=1 137 | 138 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 139 | " => Files, backups and undo 140 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 141 | " Turn backup off, since most stuff is in SVN, git et.c anyway... 142 | set nobackup 143 | set nowb 144 | set noswapfile 145 | 146 | 147 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 148 | " => Text, tab and indent related 149 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 150 | " Use spaces instead of tabs 151 | set expandtab 152 | 153 | " Be smart when using tabs ;) 154 | set smarttab 155 | 156 | " 1 tab == 4 spaces 157 | set shiftwidth=4 158 | set tabstop=4 159 | 160 | " Linebreak on 500 characters 161 | set lbr 162 | set tw=500 163 | 164 | set ai "Auto indent 165 | set si "Smart indent 166 | set wrap "Wrap lines 167 | 168 | 169 | """""""""""""""""""""""""""""" 170 | " => Visual mode related 171 | """""""""""""""""""""""""""""" 172 | " Visual mode pressing * or # searches for the current selection 173 | " Super useful! From an idea by Michael Naumann 174 | vnoremap * :call VisualSelection('', '')/=@/ 175 | vnoremap # :call VisualSelection('', '')?=@/ 176 | 177 | 178 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 179 | " => Moving around, tabs, windows and buffers 180 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 181 | " Map to / (search) and Ctrl- to ? (backwards search) 182 | map / 183 | map ? 184 | 185 | " Disable highlight when is pressed 186 | map :noh 187 | 188 | " Smart way to move between windows 189 | map j 190 | map k 191 | map h 192 | map l 193 | 194 | " Close the current buffer 195 | map bd :Bclose:tabclosegT 196 | 197 | " Close all the buffers 198 | map ba :bufdo bd 199 | 200 | map l :bnext 201 | map h :bprevious 202 | 203 | " Useful mappings for managing tabs 204 | map tn :tabnew 205 | map to :tabonly 206 | map tc :tabclose 207 | map tm :tabmove 208 | map t :tabnext 209 | 210 | " Let 'tl' toggle between this and the last accessed tab 211 | let g:lasttab = 1 212 | nmap tl :exe "tabn ".g:lasttab 213 | au TabLeave * let g:lasttab = tabpagenr() 214 | 215 | 216 | " Opens a new tab with the current buffer's path 217 | " Super useful when editing files in the same directory 218 | map te :tabedit =expand("%:p:h")/ 219 | 220 | " Switch CWD to the directory of the open buffer 221 | map cd :cd %:p:h:pwd 222 | 223 | " Specify the behavior when switching between buffers 224 | try 225 | set switchbuf=useopen,usetab,newtab 226 | set stal=2 227 | catch 228 | endtry 229 | 230 | " Return to last edit position when opening files (You want this!) 231 | au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif 232 | 233 | 234 | """""""""""""""""""""""""""""" 235 | " => Status line 236 | """""""""""""""""""""""""""""" 237 | " Always show the status line 238 | set laststatus=2 239 | 240 | " Format the status line 241 | set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c 242 | 243 | 244 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 245 | " => Editing mappings 246 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 247 | " Remap VIM 0 to first non-blank character 248 | map 0 ^ 249 | 250 | " Move a line of text using ALT+[jk] or Command+[jk] on mac 251 | nmap mz:m+`z 252 | nmap mz:m-2`z 253 | vmap :m'>+`mzgv`yo`z 254 | vmap :m'<-2`>my` 258 | nmap 259 | vmap 260 | vmap 261 | endif 262 | 263 | " Delete trailing white space on save, useful for Python and CoffeeScript ;) 264 | func! DeleteTrailingWS() 265 | exe "normal mz" 266 | %s/\s\+$//ge 267 | exe "normal `z" 268 | endfunc 269 | autocmd BufWrite *.py :call DeleteTrailingWS() 270 | autocmd BufWrite *.coffee :call DeleteTrailingWS() 271 | 272 | 273 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 274 | " => Ag searching and cope displaying 275 | " requires ag.vim - it's much better than vimgrep/grep 276 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 277 | " When you press gv you Ag after the selected text 278 | vnoremap gv :call VisualSelection('gv', '') 279 | 280 | " Open Ag and put the cursor in the right position 281 | map g :Ag 282 | 283 | " When you press r you can search and replace the selected text 284 | vnoremap r :call VisualSelection('replace', '') 285 | 286 | " Do :help cope if you are unsure what cope is. It's super useful! 287 | " 288 | " When you search with Ag, display your results in cope by doing: 289 | " cc 290 | " 291 | " To go to the next search result do: 292 | " n 293 | " 294 | " To go to the previous search results do: 295 | " p 296 | " 297 | map cc :botright cope 298 | map co ggVGy:tabnew:set syntax=qfpgg 299 | map n :cn 300 | map p :cp 301 | 302 | 303 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 304 | " => Spell checking 305 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 306 | " Pressing ,ss will toggle and untoggle spell checking 307 | map ss :setlocal spell! 308 | 309 | " Shortcuts using 310 | map sn ]s 311 | map sp [s 312 | map sa zg 313 | map s? z= 314 | 315 | 316 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 317 | " => Misc 318 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 319 | " Remove the Windows ^M - when the encodings gets messed up 320 | noremap m mmHmt:%s///ge'tzt'm 321 | 322 | " Quickly open a buffer for scribble 323 | map q :e ~/buffer 324 | 325 | " Quickly open a markdown buffer for scribble 326 | map x :e ~/buffer.md 327 | 328 | " Toggle paste mode on and off 329 | map pp :setlocal paste! 330 | 331 | 332 | 333 | 334 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 335 | " => Helper functions 336 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 337 | function! CmdLine(str) 338 | exe "menu Foo.Bar :" . a:str 339 | emenu Foo.Bar 340 | unmenu Foo 341 | endfunction 342 | 343 | function! VisualSelection(direction, extra_filter) range 344 | let l:saved_reg = @" 345 | execute "normal! vgvy" 346 | 347 | let l:pattern = escape(@", '\\/.*$^~[]') 348 | let l:pattern = substitute(l:pattern, "\n$", "", "") 349 | 350 | if a:direction == 'gv' 351 | call CmdLine("Ag \"" . l:pattern . "\" " ) 352 | elseif a:direction == 'replace' 353 | call CmdLine("%s" . '/'. l:pattern . '/') 354 | endif 355 | 356 | let @/ = l:pattern 357 | let @" = l:saved_reg 358 | endfunction 359 | 360 | 361 | " Returns true if paste mode is enabled 362 | function! HasPaste() 363 | if &paste 364 | return 'PASTE MODE ' 365 | endif 366 | return '' 367 | endfunction 368 | 369 | " Don't close window, when deleting a buffer 370 | command! Bclose call BufcloseCloseIt() 371 | function! BufcloseCloseIt() 372 | let l:currentBufNum = bufnr("%") 373 | let l:alternateBufNum = bufnr("#") 374 | 375 | if buflisted(l:alternateBufNum) 376 | buffer # 377 | else 378 | bnext 379 | endif 380 | 381 | if bufnr("%") == l:currentBufNum 382 | new 383 | endif 384 | 385 | if buflisted(l:currentBufNum) 386 | execute("bdelete! ".l:currentBufNum) 387 | endif 388 | endfunction 389 | 390 | " Make VIM remember position in file after reopen 391 | " if has("autocmd") 392 | " au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif 393 | "endif 394 | 395 | execute pathogen#infect() 396 | 397 | 398 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 399 | " => Colors and Fonts 400 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 401 | " Enable syntax highlighting 402 | syntax enable 403 | set background=dark 404 | colorscheme solarized 405 | 406 | 407 | " Set utf8 as standard encoding and en_US as the standard language 408 | set encoding=utf8 409 | 410 | " Use Unix as the standard file type 411 | set ffs=unix,dos,mac 412 | 413 | " Map the key combo 'jk' to the Escape key 414 | :imap jk 415 | 416 | set number 417 | set relativenumber 418 | -------------------------------------------------------------------------------- /roles/vim/files/pathogen-24.vim: -------------------------------------------------------------------------------- 1 | " pathogen.vim - path option manipulation 2 | " Maintainer: Tim Pope 3 | " Version: 2.4 4 | 5 | " Install in ~/.vim/autoload (or ~\vimfiles\autoload). 6 | " 7 | " For management of individually installed plugins in ~/.vim/bundle (or 8 | " ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your 9 | " .vimrc is the only other setup necessary. 10 | " 11 | " The API is documented inline below. 12 | 13 | if exists("g:loaded_pathogen") || &cp 14 | finish 15 | endif 16 | let g:loaded_pathogen = 1 17 | 18 | " Point of entry for basic default usage. Give a relative path to invoke 19 | " pathogen#interpose() (defaults to "bundle/{}"), or an absolute path to invoke 20 | " pathogen#surround(). Curly braces are expanded with pathogen#expand(): 21 | " "bundle/{}" finds all subdirectories inside "bundle" inside all directories 22 | " in the runtime path. 23 | function! pathogen#infect(...) abort 24 | for path in a:0 ? filter(reverse(copy(a:000)), 'type(v:val) == type("")') : ['bundle/{}'] 25 | if path =~# '^\%({\=[$~\\/]\|{\=\w:[\\/]\).*[{}*]' 26 | call pathogen#surround(path) 27 | elseif path =~# '^\%([$~\\/]\|\w:[\\/]\)' 28 | call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') 29 | call pathogen#surround(path . '/{}') 30 | elseif path =~# '[{}*]' 31 | call pathogen#interpose(path) 32 | else 33 | call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') 34 | call pathogen#interpose(path . '/{}') 35 | endif 36 | endfor 37 | call pathogen#cycle_filetype() 38 | if pathogen#is_disabled($MYVIMRC) 39 | return 'finish' 40 | endif 41 | return '' 42 | endfunction 43 | 44 | " Split a path into a list. 45 | function! pathogen#split(path) abort 46 | if type(a:path) == type([]) | return a:path | endif 47 | if empty(a:path) | return [] | endif 48 | let split = split(a:path,'\\\@]','\\&','') 244 | endif 245 | endfunction 246 | 247 | " Like findfile(), but hardcoded to use the runtimepath. 248 | function! pathogen#runtime_findfile(file,count) abort 249 | let rtp = pathogen#join(1,pathogen#split(&rtp)) 250 | let file = findfile(a:file,rtp,a:count) 251 | if file ==# '' 252 | return '' 253 | else 254 | return fnamemodify(file,':p') 255 | endif 256 | endfunction 257 | 258 | " Section: Deprecated 259 | 260 | function! s:warn(msg) abort 261 | echohl WarningMsg 262 | echomsg a:msg 263 | echohl NONE 264 | endfunction 265 | 266 | " Prepend all subdirectories of path to the rtp, and append all 'after' 267 | " directories in those subdirectories. Deprecated. 268 | function! pathogen#runtime_prepend_subdirectories(path) abort 269 | call s:warn('Change pathogen#runtime_prepend_subdirectories('.string(a:path).') to pathogen#infect('.string(a:path.'/{}').')') 270 | return pathogen#surround(a:path . pathogen#slash() . '{}') 271 | endfunction 272 | 273 | function! pathogen#incubate(...) abort 274 | let name = a:0 ? a:1 : 'bundle/{}' 275 | call s:warn('Change pathogen#incubate('.(a:0 ? string(a:1) : '').') to pathogen#infect('.string(name).')') 276 | return pathogen#interpose(name) 277 | endfunction 278 | 279 | " Deprecated alias for pathogen#interpose(). 280 | function! pathogen#runtime_append_all_bundles(...) abort 281 | if a:0 282 | call s:warn('Change pathogen#runtime_append_all_bundles('.string(a:1).') to pathogen#infect('.string(a:1.'/{}').')') 283 | else 284 | call s:warn('Change pathogen#runtime_append_all_bundles() to pathogen#infect()') 285 | endif 286 | return pathogen#interpose(a:0 ? a:1 . '/{}' : 'bundle/{}') 287 | endfunction 288 | 289 | if exists(':Vedit') 290 | finish 291 | endif 292 | 293 | let s:vopen_warning = 0 294 | 295 | function! s:find(count,cmd,file,lcd) 296 | let rtp = pathogen#join(1,pathogen#split(&runtimepath)) 297 | let file = pathogen#runtime_findfile(a:file,a:count) 298 | if file ==# '' 299 | return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'" 300 | endif 301 | if !s:vopen_warning 302 | let s:vopen_warning = 1 303 | let warning = '|echohl WarningMsg|echo "Install scriptease.vim to continue using :V'.a:cmd.'"|echohl NONE' 304 | else 305 | let warning = '' 306 | endif 307 | if a:lcd 308 | let path = file[0:-strlen(a:file)-2] 309 | execute 'lcd `=path`' 310 | return a:cmd.' '.pathogen#fnameescape(a:file) . warning 311 | else 312 | return a:cmd.' '.pathogen#fnameescape(file) . warning 313 | endif 314 | endfunction 315 | 316 | function! s:Findcomplete(A,L,P) 317 | let sep = pathogen#slash() 318 | let cheats = { 319 | \'a': 'autoload', 320 | \'d': 'doc', 321 | \'f': 'ftplugin', 322 | \'i': 'indent', 323 | \'p': 'plugin', 324 | \'s': 'syntax'} 325 | if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0]) 326 | let request = cheats[a:A[0]].a:A[1:-1] 327 | else 328 | let request = a:A 329 | endif 330 | let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*' 331 | let found = {} 332 | for path in pathogen#split(&runtimepath) 333 | let path = expand(path, ':p') 334 | let matches = split(glob(path.sep.pattern),"\n") 335 | call map(matches,'isdirectory(v:val) ? v:val.sep : v:val') 336 | call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]') 337 | for match in matches 338 | let found[match] = 1 339 | endfor 340 | endfor 341 | return sort(keys(found)) 342 | endfunction 343 | 344 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(,'edit',,0) 345 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(,'edit',,0) 346 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(,'edit',,1) 347 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(,'split',,1) 348 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(,'vsplit',,1) 349 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(,'tabedit',,1) 350 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(,'pedit',,1) 351 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(,'read',,1) 352 | 353 | " vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^\"\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=': 354 | -------------------------------------------------------------------------------- /roles/ruby/files/rvm_installer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | shopt -s extglob 4 | set -o errtrace 5 | set -o errexit 6 | 7 | rvm_install_initialize() 8 | { 9 | DEFAULT_SOURCES=(github.com/wayneeseguin/rvm bitbucket.org/mpapis/rvm) 10 | 11 | BASH_MIN_VERSION="3.2.25" 12 | if 13 | [[ -n "${BASH_VERSION:-}" && 14 | "$(\printf "%b" "${BASH_VERSION:-}\n${BASH_MIN_VERSION}\n" | LC_ALL=C \sort -n -t"." | \head -n1)" != "${BASH_MIN_VERSION}" 15 | ]] 16 | then 17 | echo "BASH ${BASH_MIN_VERSION} required (you have $BASH_VERSION)" 18 | exit 1 19 | fi 20 | 21 | export HOME PS4 22 | export rvm_trace_flag rvm_debug_flag rvm_user_install_flag rvm_ignore_rvmrc rvm_prefix rvm_path 23 | 24 | PS4="+ \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > " 25 | } 26 | 27 | log() { printf "%b\n" "$*"; } 28 | debug(){ [[ ${rvm_debug_flag:-0} -eq 0 ]] || printf "Running($#): $*"; } 29 | fail() { log "\nERROR: $*\n" ; exit 1 ; } 30 | 31 | rvm_install_commands_setup() 32 | { 33 | \which which >/dev/null 2>&1 || fail "Could not find 'which' command, make sure it's available first before continuing installation." 34 | if 35 | [[ -z "${rvm_tar_command:-}" ]] && builtin command -v gtar >/dev/null 36 | then 37 | rvm_tar_command=gtar 38 | elif 39 | ${rvm_tar_command:-tar} --help 2>&1 | GREP_OPTIONS="" \grep -- --strip-components >/dev/null 40 | then 41 | rvm_tar_command="${rvm_tar_command:-tar}" 42 | else 43 | case "$(uname)" in 44 | (OpenBSD) 45 | log "Trying to install GNU version of tar, might require sudo password" 46 | if (( UID )) 47 | then sudo pkg_add -z gtar-1 48 | else pkg_add -z gtar-1 49 | fi 50 | rvm_tar_command=gtar 51 | ;; 52 | (Darwin|FreeBSD|DragonFly) # it's not possible to autodetect on OSX, the help/man does not mention all flags 53 | rvm_tar_command=tar 54 | ;; 55 | (SunOS) 56 | case "$(uname -r)" in 57 | (5.10) 58 | log "Trying to install GNU version of tar, might require sudo password" 59 | if (( UID )) 60 | then 61 | if \which sudo >/dev/null 2>&1 62 | then sudo_10=sudo 63 | elif \which /opt/csw/bin/sudo >/dev/null 2>&1 64 | then sudo_10=/opt/csw/bin/sudo 65 | else fail "sudo is required but not found. You may install sudo from OpenCSW repository (http://opencsw.org/about)" 66 | fi 67 | pkginfo -q CSWpkgutil || $sudo_10 pkgadd -a $rvm_path/config/solaris/noask -d http://get.opencsw.org/now CSWpkgutil 68 | sudo /opt/csw/bin/pkgutil -iy CSWgtar -t http://mirror.opencsw.org/opencsw/unstable 69 | else 70 | pkginfo -q CSWpkgutil || pkgadd -a $rvm_path/config/solaris/noask -d http://get.opencsw.org/now CSWpkgutil 71 | /opt/csw/bin/pkgutil -iy CSWgtar -t http://mirror.opencsw.org/opencsw/unstable 72 | fi 73 | rvm_tar_command=/opt/csw/bin/gtar 74 | ;; 75 | (*) 76 | rvm_tar_command=tar 77 | ;; 78 | esac 79 | esac 80 | builtin command -v ${rvm_tar_command:-gtar} >/dev/null || 81 | fail "Could not find GNU compatible version of 'tar' command, make sure it's available first before continuing installation." 82 | fi 83 | if 84 | [[ ! " ${rvm_tar_options:-} " =~ " --no-same-owner " ]] && 85 | $rvm_tar_command --help 2>&1 | GREP_OPTIONS="" \grep -- --no-same-owner >/dev/null 86 | then 87 | rvm_tar_options="${rvm_tar_options:-}${rvm_tar_options:+ }--no-same-owner" 88 | fi 89 | } 90 | 91 | usage() 92 | { 93 | printf "%b" " 94 | 95 | Usage 96 | 97 | rvm-installer [options] [action] 98 | 99 | Options 100 | 101 | [[--]version] 102 | 103 | The version or tag to install. Valid values are: 104 | 105 | latest - The latest tagged version. 106 | latest-minor - The latest minor version of the current major version. 107 | latest- - The latest minor version of version x. 108 | latest-. - The latest patch version of version x.y. 109 | .. - Major version x, minor version y and patch z. 110 | 111 | [--]branch 112 | 113 | The name of the branch from which RVM is installed. This option can be used 114 | with the following formats for : 115 | 116 | / 117 | 118 | If account is wayneeseguin or mpapis, installs from one of the following: 119 | 120 | https://github.com/wayneeseguin/rvm/archive/master.tar.gz 121 | https://bitbucket.org/mpapis/rvm/get/master.tar.gz 122 | 123 | Otherwise, installs from: 124 | 125 | https://github.com//rvm/archive/master.tar.gz 126 | 127 | / 128 | 129 | If account is wayneeseguin or mpapis, installs from one of the following: 130 | 131 | https://github.com/wayneeseguin/rvm/archive/.tar.gz 132 | https://bitbucket.org/mpapis/rvm/get/.tar.gz 133 | 134 | Otherwise, installs from: 135 | 136 | https://github.com//rvm/archive/.tar.gz 137 | 138 | [/] 139 | 140 | Installs the branch from one of the following: 141 | 142 | https://github.com/wayneeseguin/rvm/archive/.tar.gz 143 | https://bitbucket.org/mpapis/rvm/get/.tar.gz 144 | 145 | [--]source 146 | 147 | Defines the repository from which RVM is retrieved and installed in the format: 148 | 149 | // 150 | 151 | Where: 152 | 153 | - Is bitbucket.org, github.com or a github enterprise site serving 154 | an RVM repository. 155 | - Is the user account in which the RVM repository resides. 156 | - Is the name of the RVM repository. 157 | 158 | Note that when using the [--]source option, one should only use the [/]branch format 159 | with the [--]branch option. Failure to do so will result in undefined behavior. 160 | 161 | --trace 162 | 163 | Provides debug logging for the installation script. 164 | Actions 165 | 166 | master - Installs RVM from the master branch at wayneeseguin/rvm on github or mpapis/rvm 167 | on bitbucket.org. 168 | stable - Installs RVM from the stable branch a wayneeseguin/rvm on github or mpapis/rvm 169 | on bitbucket.org. 170 | help - Displays this output. 171 | 172 | " 173 | } 174 | 175 | ## duplication marker 32fosjfjsznkjneuera48jae 176 | __rvm_curl_output_control() 177 | { 178 | if 179 | (( ${rvm_quiet_curl_flag:-0} == 1 )) 180 | then 181 | __flags+=( "--silent" "--show-error" ) 182 | elif 183 | [[ " $*" =~ " -s" || " $*" =~ " --silent" ]] 184 | then 185 | # make sure --show-error is used with --silent 186 | [[ " $*" =~ " -S" || " $*" =~ " -sS" || " $*" =~ " --show-error" ]] || 187 | { 188 | __flags+=( "--show-error" ) 189 | } 190 | fi 191 | } 192 | 193 | ## duplication marker 32fosjfjsznkjneuera48jae 194 | # -S is automatically added to -s 195 | __rvm_curl() 196 | ( 197 | __rvm_which curl >/dev/null || 198 | { 199 | rvm_error "RVM requires 'curl'. Install 'curl' first and try again." 200 | return 200 201 | } 202 | 203 | typeset -a __flags 204 | __flags=( --fail --location --max-redirs 10 ) 205 | 206 | [[ "$*" == *"--max-time"* ]] || 207 | [[ "$*" == *"--connect-timeout"* ]] || 208 | __flags+=( --connect-timeout 30 --retry-delay 2 --retry 3 ) 209 | 210 | if [[ -n "${rvm_proxy:-}" ]] 211 | then __flags+=( --proxy "${rvm_proxy:-}" ) 212 | fi 213 | 214 | __rvm_curl_output_control 215 | 216 | unset curl 217 | __rvm_debug_command \curl "${__flags[@]}" "$@" || return $? 218 | ) 219 | 220 | rvm_error() { printf "ERROR: %b\n" "$*"; } 221 | __rvm_which(){ which "$@" || return $?; true; } 222 | __rvm_debug_command() 223 | { 224 | debug "Running($#): $*" 225 | "$@" || return $? 226 | true 227 | } 228 | rvm_is_a_shell_function() 229 | { 230 | [[ -t 0 && -t 1 ]] || return $? 231 | return ${rvm_is_not_a_shell_function:-0} 232 | } 233 | 234 | # Searches the tags for the highest available version matching a given pattern. 235 | # fetch_version (github.com/wayneeseguin/rvm bitbucket.org/mpapis/rvm) 1.10. -> 1.10.3 236 | # fetch_version (github.com/wayneeseguin/rvm bitbucket.org/mpapis/rvm) 1.10. -> 1.10.3 237 | # fetch_version (github.com/wayneeseguin/rvm bitbucket.org/mpapis/rvm) 1. -> 1.11.0 238 | # fetch_version (github.com/wayneeseguin/rvm bitbucket.org/mpapis/rvm) "" -> 2.0.1 239 | fetch_version() 240 | { 241 | typeset _account _domain _pattern _repo _sources _values _version 242 | _sources=(${!1}) 243 | _pattern=$2 244 | for _source in "${_sources[@]}" 245 | do 246 | IFS='/' read -r _domain _account _repo <<< "${_source}" 247 | _version="$( 248 | fetch_versions ${_domain} ${_account} ${_repo} | 249 | GREP_OPTIONS="" \grep "^${_pattern:-}" | tail -n 1 250 | )" 251 | if 252 | [[ -n ${_version} ]] 253 | then 254 | echo "${_version}" 255 | return 0 256 | fi 257 | done 258 | } 259 | 260 | # Returns a sorted list of all version tags from a repository 261 | fetch_versions() 262 | { 263 | typeset _account _domain _repo _url 264 | _domain=$1 265 | _account=$2 266 | _repo=$3 267 | case ${_domain} in 268 | (bitbucket.org) 269 | _url=https://${_domain}/api/1.0/repositories/${_account}/${_repo}/branches-tags 270 | ;; 271 | (github.com) 272 | _url=https://api.${_domain}/repos/${_account}/${_repo}/tags 273 | ;; 274 | 275 | (*) 276 | _url=https://${_domain}/api/v3/repos/${_account}/${_repo}/tags 277 | ;; 278 | esac 279 | __rvm_curl -s ${_url} | 280 | \awk -v RS=',' -v FS='"' '$2=="name"{print $4}' | 281 | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n 282 | } 283 | 284 | install_release() 285 | { 286 | typeset _source _sources _url _version 287 | _sources=(${!1}) 288 | _version=$2 289 | debug "Downloading RVM version ${_version}" 290 | for _source in "${_sources[@]}" 291 | do 292 | case ${_source} in 293 | (bitbucket.org*) 294 | _url=https://${_source}/get/${_version}.tar.gz 295 | ;; 296 | (*) 297 | _url=https://${_source}/archive/${_version}.tar.gz 298 | ;; 299 | esac 300 | get_and_unpack ${_url} rvm-${_version}.tgz && return 301 | done 302 | return $? 303 | } 304 | 305 | install_head() 306 | { 307 | typeset _branch _source _sources _url 308 | _sources=(${!1}) 309 | _branch=$2 310 | debug "Selected RVM branch ${_branch}" 311 | for _source in "${_sources[@]}" 312 | do 313 | case ${_source} in 314 | (bitbucket.org*) 315 | _url=https://${_source}/get/${_branch}.tar.gz 316 | ;; 317 | (*) 318 | _url=https://${_source}/archive/${_branch}.tar.gz 319 | ;; 320 | esac 321 | get_and_unpack ${_url} rvm-${_branch//\//_}.tgz && return 322 | done 323 | return $? 324 | } 325 | 326 | # duplication marker dfkjdjngdfjngjcszncv 327 | # Drop in cd which _doesn't_ respect cdpath 328 | __rvm_cd() 329 | { 330 | typeset old_cdpath ret 331 | ret=0 332 | old_cdpath="${CDPATH}" 333 | CDPATH="." 334 | chpwd_functions="" builtin cd "$@" || ret=$? 335 | CDPATH="${old_cdpath}" 336 | return $ret 337 | } 338 | 339 | get_and_unpack() 340 | { 341 | typeset _url _file _patern _return 342 | _url=$1 343 | _file=$2 344 | 345 | log "Downloading ${_url}" 346 | __rvm_curl -sS ${_url} -o ${rvm_archives_path}/${_file} || 347 | { 348 | _return=$? 349 | case $_return in 350 | # duplication marker lfdgzkngdkjvnfjknkjvcnbjkncvjxbn 351 | (60) 352 | log " 353 | Could not download '${_url}', you can read more about it here: 354 | https://rvm.io/support/fixing-broken-ssl-certificates/ 355 | To continue in insecure mode run 'echo insecure >> ~/.curlrc'. 356 | " 357 | ;; 358 | # duplication marker lfdgzkngdkjvnfjknkjvcnbjkncvjxbn 359 | (77) 360 | log " 361 | It looks like you have old certificates, you can read more about it here: 362 | https://rvm.io/support/fixing-broken-ssl-certificates/ 363 | " 364 | ;; 365 | # duplication marker lfdgzkngdkjvnfjknkjvcnbjkncvjxbn 366 | (141) 367 | log " 368 | Curl returned 141 - it is result of a segfault which means it's Curls fault. 369 | Try again and if it crashes more than a couple of times you either need to 370 | reinstall Curl or consult with your distribution manual and contact support. 371 | " 372 | ;; 373 | (*) 374 | log " 375 | Could not download '${_url}'. 376 | curl returned status '$_return'. 377 | " 378 | ;; 379 | esac 380 | return $_return 381 | } 382 | 383 | [[ -d "${rvm_src_path}/rvm" ]] || \mkdir -p "${rvm_src_path}/rvm" 384 | __rvm_cd "${rvm_src_path}/rvm" || 385 | { 386 | _return=$? 387 | log "Could not change directory '${rvm_src_path}/rvm'." 388 | return $_return 389 | } 390 | 391 | rm -rf ${rvm_src_path}/rvm/* 392 | __rvm_debug_command $rvm_tar_command xzf ${rvm_archives_path}/${_file} ${rvm_tar_options:-} --strip-components 1 || 393 | { 394 | _return=$? 395 | log "Could not extract RVM sources." 396 | return $_return 397 | } 398 | } 399 | 400 | rvm_install_default_settings() 401 | { 402 | # Tracing, if asked for. 403 | if 404 | [[ "$*" =~ --trace ]] || (( ${rvm_trace_flag:-0} > 0 )) 405 | then 406 | set -o xtrace 407 | rvm_trace_flag=1 408 | fi 409 | 410 | # Variable initialization, remove trailing slashes if they exist on HOME 411 | true \ 412 | ${rvm_trace_flag:=0} ${rvm_debug_flag:=0}\ 413 | ${rvm_ignore_rvmrc:=0} HOME="${HOME%%+(\/)}" 414 | 415 | if 416 | (( rvm_ignore_rvmrc == 0 )) 417 | then 418 | for rvmrc in /etc/rvmrc "$HOME/.rvmrc" 419 | do 420 | if 421 | [[ -s "$rvmrc" ]] 422 | then 423 | if 424 | GREP_OPTIONS="" \grep '^\s*rvm .*$' "$rvmrc" >/dev/null 2>&1 425 | then 426 | printf "%b" " 427 | Error: $rvmrc is for rvm settings only. 428 | rvm CLI may NOT be called from within $rvmrc. 429 | Skipping the loading of $rvmrc 430 | " 431 | exit 1 432 | else 433 | source "$rvmrc" 434 | fi 435 | fi 436 | done 437 | fi 438 | 439 | if 440 | [[ -z "${rvm_path:-}" ]] 441 | then 442 | if 443 | (( UID == 0 )) 444 | then 445 | rvm_user_install_flag=0 446 | rvm_prefix="/usr/local" 447 | rvm_path="${rvm_prefix}/rvm" 448 | else 449 | rvm_user_install_flag=1 450 | rvm_prefix="$HOME" 451 | rvm_path="${rvm_prefix}/.rvm" 452 | fi 453 | fi 454 | if [[ -z "${rvm_prefix}" ]] 455 | then rvm_prefix=$( dirname $rvm_path ) 456 | fi 457 | 458 | # duplication marker kkdfkgnjfndgjkndfjkgnkfjdgn 459 | case "$rvm_path" in 460 | (/usr/local/rvm) rvm_user_install_flag=0 ;; 461 | ($HOME/*|/${USER// /_}*) rvm_user_install_flag=1 ;; 462 | (*) rvm_user_install_flag=0 ;; 463 | esac 464 | } 465 | 466 | rvm_install_parse_params() 467 | { 468 | install_rubies=() 469 | install_gems=() 470 | flags=() 471 | forwarded_flags=() 472 | while 473 | (( $# > 0 )) 474 | do 475 | token="$1" 476 | shift 477 | case "$token" in 478 | 479 | (--trace) 480 | set -o xtrace 481 | rvm_trace_flag=1 482 | flags+=( "$token" ) 483 | forwarded_flags+=( "$token" ) 484 | ;; 485 | 486 | (--debug|--quiet-curl) 487 | flags+=( "$token" ) 488 | forwarded_flags+=( "$token" ) 489 | token=${token#--} 490 | token=${token//-/_} 491 | export "rvm_${token}_flag"=1 492 | printf "%b" "Turning on ${token/_/ } mode.\n" 493 | ;; 494 | 495 | (--path) 496 | if [[ -n "${1:-}" ]] 497 | then 498 | rvm_path="$1" 499 | shift 500 | else 501 | fail "--path must be followed by a path." 502 | fi 503 | ;; 504 | 505 | (--branch|branch) # Install RVM from a given branch 506 | if [[ -n "${1:-}" ]] 507 | then 508 | case "$1" in 509 | (/*) 510 | branch=${1#/} 511 | ;; 512 | (*/) 513 | branch=master 514 | if [[ "${1%/}" -ne wayneeseguin ]] && [[ "${1%/}" -ne mpapis ]] 515 | then sources=(github.com/${1%/}/rvm) 516 | fi 517 | ;; 518 | (*/*) 519 | branch=${1#*/} 520 | if [[ "${1%%/*}" -ne wayneeseguin ]] && [[ "${1%%/*}" -ne mpapis ]] 521 | then sources=(github.com/${1%%/*}/rvm) 522 | fi 523 | ;; 524 | (*) 525 | branch="$1" 526 | ;; 527 | esac 528 | shift 529 | else 530 | fail "--branch must be followed by a branchname." 531 | fi 532 | ;; 533 | 534 | (--source|source) 535 | if [[ -n "${1:-}" ]] 536 | then 537 | if [[ "$1" = */*/* ]] 538 | then 539 | sources=($1) 540 | shift 541 | else 542 | fail "--source must be in the format //." 543 | fi 544 | else 545 | fail "--source must be followed by a source." 546 | fi 547 | ;; 548 | 549 | (--user-install|--ignore-dotfiles) 550 | token=${token#--} 551 | token=${token//-/_} 552 | export "rvm_${token}_flag"=1 553 | printf "%b" "Turning on ${token/_/ } mode.\n" 554 | ;; 555 | 556 | (--auto-dotfiles) 557 | flags+=( "$token" ) 558 | export "rvm_auto_dotfiles_flag"=1 559 | printf "%b" "Turning on auto dotfiles mode.\n" 560 | ;; 561 | 562 | (--auto) 563 | export "rvm_auto_dotfiles_flag"=1 564 | printf "%b" "Warning, --auto is deprecated in favor of --auto-dotfiles.\n" 565 | ;; 566 | 567 | (--verify-downloads) 568 | if [[ -n "${1:-}" ]] 569 | then 570 | export rvm_verify_downloads_flag="$1" 571 | forwarded_flags+=( "$token" "$1" ) 572 | shift 573 | else 574 | fail "--verify-downloads must be followed by level(0|1|2)." 575 | fi 576 | ;; 577 | 578 | (--autolibs=*) 579 | flags+=( "$token" ) 580 | export rvm_autolibs_flag="${token#--autolibs=}" 581 | forwarded_flags+=( "$token" ) 582 | ;; 583 | 584 | (--without-gems=*|--with-gems=*|--with-default-gems=*) 585 | flags+=( "$token" ) 586 | value="${token#*=}" 587 | token="${token%%=*}" 588 | token="${token#--}" 589 | token="${token//-/_}" 590 | export "rvm_${token}"="${value}" 591 | printf "%b" "Installing RVM ${token/_/ }: ${value}.\n" 592 | ;; 593 | 594 | (--version|version) 595 | version="$1" 596 | shift 597 | ;; 598 | 599 | (head) 600 | version="head" 601 | branch="master" 602 | ;; 603 | 604 | (stable|master) 605 | version="head" 606 | branch="$token" 607 | ;; 608 | 609 | (latest|latest-*|+([[:digit:]]).+([[:digit:]]).+([[:digit:]])) 610 | version="$token" 611 | ;; 612 | 613 | (--ruby) 614 | install_rubies+=( ruby ) 615 | ;; 616 | 617 | (--ruby=*) 618 | token=${token#--ruby=} 619 | install_rubies+=( ${token//,/ } ) 620 | ;; 621 | 622 | (--rails) 623 | install_gems+=( rails ) 624 | ;; 625 | 626 | (--gems=*) 627 | token=${token#--gems=} 628 | install_gems+=( ${token//,/ } ) 629 | ;; 630 | 631 | (--add-to-rvm-group) 632 | export rvm_add_users_to_rvm_group="$1" 633 | shift 634 | ;; 635 | 636 | (help|usage) 637 | usage 638 | exit 0 639 | ;; 640 | 641 | (*) 642 | usage 643 | exit 1 644 | ;; 645 | 646 | esac 647 | done 648 | 649 | if (( ${#install_gems[@]} > 0 && ${#install_rubies[@]} == 0 )) 650 | then install_rubies=( ruby ) 651 | fi 652 | 653 | true "${version:=head}" 654 | true "${branch:=master}" 655 | 656 | if [[ -z "${sources[@]}" ]] 657 | then sources=("${DEFAULT_SOURCES[@]}") 658 | fi 659 | 660 | rvm_src_path="$rvm_path/src" 661 | rvm_archives_path="$rvm_path/archives" 662 | rvm_releases_url="https://rvm.io/releases" 663 | } 664 | 665 | rvm_install_validate_rvm_path() 666 | { 667 | case "$rvm_path" in 668 | (*[[:space:]]*) 669 | printf "%b" " 670 | It looks you are one of the happy *space* users(in home dir name), 671 | RVM is not yet fully ready for it, use this trick to fix it: 672 | 673 | sudo mkdir -p /${USER// /_}.rvm 674 | sudo chown -R \"$USER:\" /${USER// /_}.rvm 675 | echo \"export rvm_path=/${USER// /_}.rvm\" >> \"$HOME/.rvmrc\" 676 | 677 | and start installing again. 678 | 679 | " 680 | exit 2 681 | ;; 682 | (/usr/share/ruby-rvm) 683 | printf "%b" " 684 | It looks you are one of the happy Ubuntu users, 685 | RVM packaged by Ubuntu is old and broken, 686 | follow this link for details how to fix: 687 | 688 | http://stackoverflow.com/a/9056395/497756 689 | 690 | " 691 | [[ "${rvm_uses_broken_ubuntu_path:-no}" == "yes" ]] || exit 3 692 | ;; 693 | esac 694 | 695 | if [[ "$rvm_path" != /* ]] 696 | then fail "The rvm install path must be fully qualified. Tried $rvm_path" 697 | fi 698 | } 699 | 700 | rvm_install_select_and_get_version() 701 | { 702 | for dir in "$rvm_src_path" "$rvm_archives_path" 703 | do 704 | [[ -d "$dir" ]] || mkdir -p "$dir" 705 | done 706 | 707 | case "${version}" in 708 | (head) 709 | echo "${branch}" > "$rvm_path/RELEASE" 710 | install_head sources[@] ${branch:-master} || exit $? 711 | ;; 712 | 713 | (latest) 714 | echo "${version}" > "$rvm_path/RELEASE" 715 | install_release sources[@] $(fetch_version sources[@]) || exit $? 716 | ;; 717 | 718 | (latest-minor) 719 | echo "${version}" > "$rvm_path/RELEASE" 720 | version="$(\cat "$rvm_path/VERSION")" 721 | install_release sources[@] $(fetch_version sources[@] ${version%.*}) || exit $? 722 | ;; 723 | 724 | (latest-*) 725 | echo "${version}" > "$rvm_path/RELEASE" 726 | install_release sources[@] $(fetch_version sources[@] ${version#latest-}) || exit $? 727 | ;; 728 | 729 | (+([[:digit:]]).+([[:digit:]]).+([[:digit:]])) # x.y.z 730 | echo "version" > "$rvm_path/RELEASE" 731 | install_release sources[@] ${version} || exit $? 732 | ;; 733 | 734 | (*) 735 | fail "Something went wrong, unrecognized version '$version'" 736 | ;; 737 | esac 738 | } 739 | 740 | rvm_install_main() 741 | { 742 | # required flag - path to install 743 | flags+=( --path "$rvm_path" ) 744 | chmod +x ./scripts/install 745 | ./scripts/install "${flags[@]}" 746 | } 747 | 748 | rvm_install_ruby_and_gems() 749 | ( 750 | if 751 | (( ${#install_rubies[@]} > 0 )) 752 | then 753 | source ${rvm_scripts_path:-${rvm_path}/scripts}/rvm 754 | source ${rvm_scripts_path:-${rvm_path}/scripts}/version 755 | __rvm_version 756 | 757 | for _ruby in ${install_rubies[@]} 758 | do command rvm "${forwarded_flags[@]}" install ${_ruby} -j 2 759 | done 760 | # set the first one as default, skip rest 761 | for _ruby in ${install_rubies[@]} 762 | do 763 | rvm "${forwarded_flags[@]}" alias create default ${_ruby} 764 | break 765 | done 766 | 767 | for _gem in ${install_gems[@]} 768 | do rvm "${forwarded_flags[@]}" all do gem install ${_gem} 769 | done 770 | 771 | printf "%b" " 772 | * To start using RVM you need to run \`source $rvm_path/scripts/rvm\` 773 | in all your open shell windows, in rare cases you need to reopen all shell windows. 774 | " 775 | 776 | if 777 | [[ "${install_gems[*]}" =~ "rails" ]] 778 | then 779 | printf "%b" " 780 | * To start using rails you need to run \`rails new \`. 781 | " 782 | fi 783 | fi 784 | ) 785 | 786 | rvm_install() 787 | { 788 | rvm_install_initialize 789 | rvm_install_commands_setup 790 | rvm_install_default_settings 791 | rvm_install_parse_params "$@" 792 | rvm_install_validate_rvm_path 793 | rvm_install_select_and_get_version 794 | rvm_install_main 795 | rvm_install_ruby_and_gems 796 | } 797 | 798 | rvm_install "$@" 799 | --------------------------------------------------------------------------------