GithubHelp home page GithubHelp logo

thoughtbot / dotfiles Goto Github PK

View Code? Open in Web Editor NEW
7.9K 201.0 1.9K 602 KB

A set of vim, zsh, git, and tmux configuration files.

Home Page: https://thoughtbot.com

License: Other

Shell 65.08% Vim Script 34.92%

dotfiles's Introduction

thoughtbot dotfiles

prompt

Requirements

Set zsh as your login shell:

chsh -s $(which zsh)

Install

Clone onto your laptop:

git clone [email protected]:thoughtbot/dotfiles.git ~/dotfiles

(Or, fork and keep your fork updated).

Install rcm:

brew install rcm

Install the dotfiles:

env RCRC=$HOME/dotfiles/rcrc rcup

After the initial installation, you can run rcup without the one-time variable RCRC being set (rcup will symlink the repo's rcrc to ~/.rcrc for future runs of rcup). See example.

This command will create symlinks for config files in your home directory. Setting the RCRC environment variable tells rcup to use standard configuration options:

  • Exclude the README.md, README-ES.md and LICENSE files, which are part of the dotfiles repository but do not need to be symlinked in.
  • Give precedence to personal overrides which by default are placed in ~/dotfiles-local
  • Please configure the rcrc file if you'd like to make personal overrides in a different directory

Update

From time to time you should pull down any updates to these dotfiles, and run

rcup

to link any new files and install new vim plugins. Note You must run rcup after pulling to ensure that all files in plugins are properly installed, but you can safely run rcup multiple times so update early and update often!

Make your own customizations

Create a directory for your personal customizations:

mkdir ~/dotfiles-local

Put your customizations in ~/dotfiles-local appended with .local:

  • ~/dotfiles-local/aliases.local
  • ~/dotfiles-local/git_template.local/*
  • ~/dotfiles-local/gitconfig.local
  • ~/dotfiles-local/psqlrc.local (we supply a blank .psqlrc.local to prevent psql from throwing an error, but you should overwrite the file with your own copy)
  • ~/dotfiles-local/tmux.conf.local
  • ~/dotfiles-local/vimrc.local
  • ~/dotfiles-local/vimrc.bundles.local
  • ~/dotfiles-local/zshrc.local
  • ~/dotfiles-local/zsh/configs/*

For example, your ~/dotfiles-local/aliases.local might look like this:

# Productivity
alias todo='$EDITOR ~/.todo'

Your ~/dotfiles-local/gitconfig.local might look like this:

[alias]
  l = log --pretty=colored
[pretty]
  colored = format:%Cred%h%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset
[user]
  name = Dan Croak
  email = [email protected]

Your ~/dotfiles-local/vimrc.local might look like this:

" Color scheme
colorscheme github
highlight NonText guibg=#060606
highlight Folded  guibg=#0A0A0A guifg=#9090D0

If you don't wish to install a vim plugin from the default set of vim plugins in .vimrc.bundles, you can ignore the plugin by calling it out with UnPlug in your ~/.vimrc.bundles.local.

" Don't install vim-scripts/tComment (notice the username of the plugin is
removed)

UnPlug 'tComment'

UnPlug can be used to install your own fork of a plugin or to install a shared plugin with different custom options.

" Only load vim-coffee-script if a Coffeescript buffer is created
UnPlug 'vim-coffee-script'
Plug 'kchmck/vim-coffee-script', { 'for': 'coffee' }

" Use a personal fork of vim-run-interactive
UnPlug 'vim-run-interactive'
Plug '$HOME/plugins/vim-run-interactive'

To extend your git hooks, create executable scripts in ~/dotfiles-local/git_template.local/hooks/* files.

Your ~/dotfiles-local/zshrc.local might look like this:

# load pyenv if available
if which pyenv &>/dev/null ; then
  eval "$(pyenv init -)"
fi

Your ~/dotfiles-local/vimrc.bundles.local might look like this:

Plug 'Lokaltog/vim-powerline'
Plug 'stephenmckinney/vim-solarized-powerline'

zsh Configurations

Additional zsh configuration can go under the ~/dotfiles-local/zsh/configs directory. This has two special subdirectories: pre for files that must be loaded first, and post for files that must be loaded last.

For example, ~/dotfiles-local/zsh/configs/pre/virtualenv makes use of various shell features which may be affected by your settings, so load it first:

# Load the virtualenv wrapper
. /usr/local/bin/virtualenvwrapper.sh

Setting a key binding can happen in ~/dotfiles-local/zsh/configs/keys:

# Grep anywhere with ^G
bindkey -s '^G' ' | grep '

Some changes, like chpwd, must happen in ~/dotfiles-local/zsh/configs/post/chpwd:

# Show the entries in a directory whenever you cd in
function chpwd {
  ls
}

This directory is handy for combining dotfiles from multiple teams; one team can add the virtualenv file, another keys, and a third chpwd.

The ~/dotfiles-local/zshrc.local is loaded after ~/dotfiles-local/zsh/configs.

vim Configurations

Similarly to the zsh configuration directory as described above, vim automatically loads all files in the ~/dotfiles-local/vim/plugin directory. This does not have the same pre or post subdirectory support that our zshrc has.

This is an example ~/dotfiles-local/vim/plugin/c.vim. It is loaded every time vim starts, regardless of the file name:

# Indent C programs according to BSD style(9)
set cinoptions=:0,t0,+4,(4
autocmd BufNewFile,BufRead *.[ch] setlocal sw=0 ts=8 noet

What's in it?

vim configuration:

  • fzf for fuzzy file/buffer/tag finding.
  • Rails.vim for enhanced navigation of Rails file structure via gf and :A (alternate), :Rextract partials, :Rinvert migrations, etc.
  • Run many kinds of tests from vim
  • Set <leader> to a single space.
  • Switch between the last two files with space-space.
  • Syntax highlighting for Markdown, HTML, JavaScript, Ruby, Go, Elixir, more.
  • Use Ag instead of Grep when available.
  • Map <leader>ct to re-index ctags.
  • Use vim-mkdir for automatically creating non-existing directories before writing the buffer.
  • Use vim-plug to manage plugins.

tmux configuration:

  • Improve color resolution.
  • Remove administrative debris (session name, hostname, time) in status bar.
  • Set prefix to Ctrl+s
  • Soften status bar color from harsh green to light gray.

git configuration:

  • Adds a co-upstream-pr $PR_NUMBER $LOCAL_BRANCH_NAME subcommand to checkout remote upstream branch into a local branch.
  • Adds a create-branch alias to create feature branches.
  • Adds a delete-branch alias to delete feature branches.
  • Adds a merge-branch alias to merge feature branches into master.
  • Adds an up alias to fetch and rebase origin/master into the feature branch. Use git up -i for interactive rebases.
  • Adds post-{checkout,commit,merge} hooks to re-index your ctags.
  • Adds pre-commit and prepare-commit-msg stubs that delegate to your local config.
  • Adds trust-bin alias to append a project's bin/ directory to $PATH.

Ruby configuration:

  • Add trusted binstubs to the PATH.
  • Load the ASDF version manager.

Rails

  • Adds railsrc with --database=postgresql. If you need to use another database, you can override this value like so: rails new my_app --database=mysql or rails new my_app --no_rc

Shell aliases and scripts:

  • ... for quicker navigation to the parent's parent directory.
  • b for bundle.
  • g with no arguments is git status and with arguments acts like git.
  • migrate for bin/rails db:migrate db:rollback && bin/rails db:migrate db:test:prepare.
  • mcd to make a directory and change into it.
  • replace foo bar **/*.rb to find and replace within a given list of files.
  • tat to attach to tmux session named the same as the current directory.
  • v for $VISUAL.

Thanks

Thank you, contributors! Also, thank you to Corey Haines, Gary Bernhardt, and others for sharing your dotfiles and other shell scripts from which we derived inspiration for items in this project.

License

dotfiles is copyright © 2009 thoughtbot. It is free software, and may be redistributed under the terms specified in the LICENSE file.

About thoughtbot

thoughtbot

This repo is maintained and funded by thoughtbot, inc. The names and logos for thoughtbot are trademarks of thoughtbot, inc.

We love open source software! See our other projects. We are available for hire.

dotfiles's People

Contributors

andyw8 avatar burnettk avatar calebhearth avatar christoomey avatar croaky avatar danbee avatar danielnolan avatar derekprior avatar geoffharcourt avatar iancanderson avatar iwz avatar jferris avatar joelq avatar joshuaclayton avatar mike-burns avatar mislav avatar purinkle avatar qrush avatar reshleman avatar rjdellecese avatar rodrigobdz avatar rofrol avatar rspeicher avatar rtaibah avatar seanpdoyle avatar stefannibrasil avatar sublimecoder avatar sviccari avatar tute avatar tysongach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotfiles's Issues

Add local config for zlogin?

Hi There,

I added the following to the the zlogin file in order to customize the command prompt:

# Local config
[[ -f ~/.zlogin.local ]] && source ~/.zlogin.local

If a user wants to customize their prompt (or as in my case use powerline) I think they will have to override the zlogin. Does that make sense?

Missing documentation about Vundle?

I'm not sure from the README file but it seems to imply that following the installation instructions should result in a working Vim install with configured vim bundles already installed. Is this correct?

I followed all the installation instructions and when I run vim I get the following output:

Error detected while processing /Users/sohara/.vimrc.bundles:
line    5:
E117: Unknown function: vundle#rc
line    8:
E492: Not an editor command: Bundle 'gmarik/vundle'
line   11:
E492: Not an editor command: Bundle 'croaky/vim-colors-github'
line   12:
E492: Not an editor command: Bundle 'danro/rename.vim'
line   13:
E492: Not an editor command: Bundle 'kchmck/vim-coffee-script'
line   14:
E492: Not an editor command: Bundle 'kien/ctrlp.vim'
line   15:
E492: Not an editor command: Bundle 'scrooloose/syntastic'
line   16:
E492: Not an editor command: Bundle 'thoughtbot/vim-rspec'
line   17:
E492: Not an editor command: Bundle 'tpope/vim-bundler'
line   18:
E492: Not an editor command: Bundle 'tpope/vim-cucumber'
line   19:
E492: Not an editor command: Bundle 'tpope/vim-endwise'
line   20:
E492: Not an editor command: Bundle 'tpope/vim-fugitive'
line   21:
E492: Not an editor command: Bundle 'tpope/vim-rails'
line   22:
E492: Not an editor command: Bundle 'tpope/vim-surround'
line   23:
E492: Not an editor command: Bundle 'tsaleh/vim-matchit'
line   24:
E492: Not an editor command: Bundle 'vim-scripts/ctags.vim'
line   25:
E492: Not an editor command: Bundle 'vim-scripts/tComment'
Error detected while processing /Users/sohara/.vimrc:
line   78:
E185: Cannot find color scheme 'github'

It seems as though there is some additional installation step which is not documented, e.g. installing the Vundle plugin manually.

I ran git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle then started Vim and ran :BundleInstall as suggested by the Readme on the Vundle project. However if this is normally a required step then I find it surprising that no reference is made to it in the documentation.

cannot load github color scheme

i have tried to install dotfiles script and laptop script in my ubuntu 13.04 after installing when i tried to start vim

Error detected while processing /home/dinakaran/.vimrc:
line 78:
E185: Cannot find color scheme github
Press ENTER or type command to continue

and the github color scheme is not loading

Vim should not highlight strings between quotes in Markdown files

In vim/syntax/mkd.vim, I suspect, strings between quotes, in any context, are being highlighted as if they mean something. This doesn't look so bad in:

He said to her, "Frankly, my dear, I don't give a damn."

But it definitely looks bad in:

Let's get started with a simple example. In this step, we'll look at RSpec.

Single or double quotes in a paragraph do not translate to any HTML tags, in a markdown file.

Also, I can't find what line(s) in mkd.vim that are causing this highlighting... but I suspected one of the HTMLHiLink lines...

Basic .gitconfig

I helped someone set up their laptop today for Rails development. One thing that bugged me about his thoughtbot/{laptop,dotfiles} setup was the git settings.

What if we added this as the basic gitconfig?

[push]
  default = tracking
[format]
  pretty = %Cblue%h%Creset %Cgreen[%ar]%Creset (%an) %s
[alias]
  up = !git fetch origin && git rebase origin/master
  down = !git fetch && git rebase origin/master && git checkout master && git merge @{-1} && git push

This is a file that also immediately gets edited (when Github encourages them to add their git user name and email). Is that okay? I guess most other files in dotfiles are similarly edited / modified heavily by the user.

How do I keep shell things out of dotfiles but loaded cleanly?

For example, I have this:

# RVM
[[ -s '/Users/croaky/.rvm/scripts/rvm' ]] && source '/Users/croaky/.rvm/scripts/rvm'

It's in ~/.zshrc, which is a symlink to what's in dotfiles. I don't want to accidentally commit it into dotfiles. Where should it go?

Figure out a strategy for [user]name, [user]email

Every time I commit with the intention of submitting a pull request to thoughtbot/dotfiles, I have to be careful not to commit this part of my ~/.gitconfig:

[user]
  name=Dan Croak
  [email protected]

It'd be great to come up with a strategy that we could apply to anything that we want to share in thoughtbot/dotfiles but that have parts of files that are not shareable.

Improve `migrate`

From Joe:

I think you could use redo to cut out one environment load, with rake db:migrate && rake db:redo && rake db:test:prepare. You may also be able to tack the db:test:prepare on the previous rake run so that only two loads are necessary. I haven't played with this in a while.

Cant find github color scheme

Error detected while processing /users/pyrat/.vimrc:
line   52:
E185: Cannot find color scheme github

Is this related to a recent change to the github color scheme?

code-review command

#!/bin/sh

code-review()
{
  branch=`git branch -r | ack $1 | sed 's/.*\///'`
  git checkout $branch
}

Map leader to space

Not sure why this is done. May have gotten it from Ben's vimcast?

" Leader
let mapleader = "<Space>"

Remove ctags.vim

Had seen a conflict with exuberant ctags some time back, the details of which I can't remember.

Should be unnecessary, able to invoke it with ctags -R from the command line or :Rtags from a Rails project?

Remove snippets

Does anyone use vim snippets? The only time I ever encounter them is (when I'm pairing) when I accidentally activate a snippet and have to figure out how to delete the mess. Therefore, I'm pushing to remove them from our official dotfiles. But if someone uses them, let's keep it.

Clean up vimrc

Starting to getting a little long. I think we can extract the "running specs from vim" code into maybe the vim/plugins directory? Same for the TabWrapper function?

Add db-load-production script

#!/bin/sh

# Load production data from Heroku into local Postgres database.
#
# Assumes conventions:
#
# App name is working directory name.
# Heroku app is appname-production.
# Local database is appname_development.
load-production()
{
  app=`pwd`
  path=`heroku pgbackups:url --app ${app}-production`
  db=`${app}_development`
  curl -o latest.dump $path
  pg_restore --verbose --clean --no-acl --no-owner -d $db latest.dump
  rm latest.dump
}

Change "DO NOT EDIT BELOW THIS LINE" to "DO NOT EDIT ABOVE THIS LINE"

I believe it was @jessieay who noticed she wanted to override a setting somewhere (.gitconfig?) but because the custom configurations are listed first, the default configurations override them.

What do we think about reversing how the "DO NOT EDIT BELOW THIS LINE" functionality of ./install.sh works to "DO NOT EDIT ABOVE THIS LINE"?

Use global bundle config for binstubs path

You can create a config file ~/.bundle/config and put this in it:

---                                                                             
  BUNDLE_BIN: ./.bundle/bin

The path can be whatever we standardize on, like ./bin/stubs, but I thought ./.bundle/bin was pretty self explanatory.

Anyway, setting the global bundler config like that will always install the bundle binaries into ./.bundle/bin by just running bundle or bundle install. You don't need to provide --binstubs flag.

Remove cucumber specific lines from vimrc

As a company we're moving away from Cucumber. It may make sense to remove these lines from vimrc:

" Cucumber navigation commands
autocmd User Rails Rnavcommand step features/step_definitions -glob=**/* -suffix=_steps.rb
" :Cuc my text (no quotes) -> runs cucumber scenarios containing "my text"
command! -nargs=+ Cuc :!ack --no-heading --no-break <q-args> | cut -d':' -f1,2 | xargs bundle exec cucumber --no-color

Restructure with pathogen

Hi there!

Is there a reason why you're not using Pathogen to manage plugins? I've run through them and > 90% (given that most of them are by Tim Pope himself) have a Github repository available that would be perfect with Pathogen.

See here: http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen/ for the benefit.

I've been doing it for a while with my previous Vim configuration and it rocks, you can easily update all of your plugins with

git submodule foreach git pull origin master

As a matter of fact, you could also structure the dot files themselves as a repo with submodules, having for example vimrc.local as a submodule you can maintain separately (everyone has its own preferences :-) ).

Scripts directory

What do we think about a convention of ~/bin or some other directory name that contains individual files for scripts?

Automatically remove trailing whitespace when a file is saved

I am surprised that we don't have a rule to do this already, this is pretty important to me and I expect everyone I work with who has vim to have a rule like this.

Here is what I have in my dotfiles:

" Copied from <http://vim.wikia.com/wiki/Remove_unwanted_spaces>
function! TrimWhiteSpace()
  " do not record the whitespace removal in the undo history
  " <http://vim.1045645.n5.nabble.com/there-s-undojoin-how-about-dotjoin-td1203135.html>
  try
    undojoin
  catch
    " probably an undo was just issued, and so there's no way to
    " join the undo. which sucks.
  endtry
  %s/\s*$//
  ''
endfunction

autocmd! FileWritePre * :call TrimWhiteSpace()
autocmd! FileAppendPre * :call TrimWhiteSpace()
autocmd! FilterWritePre * :call TrimWhiteSpace()
autocmd! BufWritePre * :call TrimWhiteSpace()

The only downside to this is that if you've undone something and then save, if you want to redo what you just undid you have to undo manually. To me this isn't a huge deal, as you'd have this problem anyway if you happened to make any other kind of change. So you learn to treat saving as making a change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.