Commit graph

438 commits

Author SHA1 Message Date
Teo Ljungberg
d98d06a905 Add ctags support for attr_ definitions
This change adds `ctags` support for `attr_{reader,writer,accessor)` in
Ruby files.
2015-11-06 15:31:34 -05:00
Mike Burns
31b6ad4f3f Split zsh configuration into smaller files
This allows people to incorporate the thoughtbot dotfiles into their own
dotfiles in a more fine-grained manner.

I left some things in zshrc that we should eventually handle more
precisely:

- Load `.zsh/functions/*`. This could instead be replaced with: `mv
  .zsh/functions/* .zsh/configs`.
- Load `.aliases`. This could instead be replaced with: `mv .aliases
  .zsh/configs/aliases.zsh`.
- Load `.zshrc.local`. This file can realistically go away entirely,
  with people adding their own files to `.zsh/configs`.

A further refactoring, which I have done locally, is to introduce a
`~/.sh/configs` directory, in which people can put POSIX-specific
configuration that can be shared between GNU Bash, zsh, ksh, etc:
aliases, functions, paths, prompts, and so on. But one step at a time.

Other changes:
* Move aliases setup to occur after loading other config, as some of our
  aliases depend on environment variables having been set, so alias
  loading must come last after we've sourced `zsh/configs`.

* Move autocompletion for `g` function from the function definition to
  to `zsh/completions/_g`

* Move `PATH` setup to `zsh/configs/post` to ensure it happens after
  other configuration that might alter the `PATH`
2015-11-06 15:03:05 -05:00
Sean Doyle
4c68f6c819 Recognize JS Linter configuration files as JSON
Unfortunately, the convention for most JavaScript linters is to name
their configuration `.${TOOL}rc`.

In spite of this name, the configuration files are `JSON`. Forcing vim
to recognize them as JSON would enable syntax highlighting and linting
plugins (like syntastic) to recognize invalidly structured JSON.
2015-11-04 07:55:46 -05:00
Geoff Harcourt
219079887c Update Bundler completion to include newer subcommands, fix help
The zsh-completions repository has some additional Bundler subcommands
in their completion since we first implemented it a couple years ago.
This change updates our `_bundle` autocompletion definition to include
the subcommands `outdated` and `platform`, as well as separating values
for `bundle help`.

Separating the individual commands when defining candidates for `bundle
help` allows tab-completion of those subcommands (e.g. hitting `<TAB>`
with `bundle help in` would suggest `init` and `install` and tab
complete either option.

Changes imported from
a59f5c3a0a/src/_bundle
2015-10-30 15:11:19 -04:00
Geoff Harcourt
21830dd035 Bring more shell syntax into shellcheck compliance
**Bring executables into better shellcheck compliance**

While evaluating linting and testing options for our shell
configuration, a run of Shellcheck against our executables turned up
some places where we could use more consistent syntax across our
executables, such as always using a shebang or quoting `$HOME` when we
build up a larger directory.

**Update syntax for zsh functions and completions**

A few changes found while linting zsh configs with shellcheck:

* thoughtbot's [style guide] [guide] calls for `$(..)` over backticks
  when capturing command output
* use `-gt` to test array length in arguments

[guide]: https://github.com/thoughtbot/guides/tree/master/best-practices
2015-10-30 12:50:02 -04:00
Greg Lazarev
31a8dd34f0 Provide an example of specifying dotfiles dir
Why:

* There can be confusion on how to tell `rcup` where local dotfiles
  have been installed.
2015-10-23 17:28:11 -04:00
Mislav Marohnić
901faec464 Only colorize warning messages if stderr is a tty
This is to avoid outputting ANSI escape codes to scripts and log files.
2015-10-23 12:26:11 -04:00
Mislav Marohnić
16219a31db Move broken OS X /etc/zshenv detection to post-up hook
This is so it doesn't run every time when zsh starts in interactive
mode, but just once per `rcup`.
2015-10-23 12:26:11 -04:00
Mislav Marohnić
5d397e6fa5 Detect OS X broken /etc/zshenv and suggest rename
If `/etc/zshenv` that calls `path_helper` is found on the system, assume
OS X version pre-El Capitan and suggest that this file gets renamed to
`zprofile` so that it only gets sourced on login shells and doesn't mess
up PATH order on nested invocation of zsh.
2015-10-23 12:26:11 -04:00
Mislav Marohnić
ed8619e0ab Detect if ~/.zshenv.local changes PATH and suggest .zshrc instead
Warn people who might have PATH and similar configuration in their
`~/.zshenv.local` that they should upgrade to `~/.zshrc.local` since
that's a much better phase for such configuration. This is for backwards
compatibility with people's personal configurations from pre-El Capitan
days.

The generic `.zshenv` file from zsh distribution[1] advises:

> .zshenv is sourced on ALL invocations of the shell, unless the -f
> option is set. It should NOT normally contain commands to set the
> command search path, or other common environment variables unless you
> really know what you're doing. E.g. running `PATH=/custom/path gdb program`
> sources this file (when gdb runs the program via $SHELL), so you want
> to be sure not to override a custom environment in such cases. Note
> also that .zshenv should not contain commands that produce output or
> assume the shell is attached to a tty.

[1]: http://sourceforge.net/p/zsh/code/ci/master/tree/StartupFiles/zshenv
2015-10-23 12:26:10 -04:00
Mislav Marohnić
6c0a559afd Avoid suggesting that people use .zshenv.local
`.zshenv` is executed for all zsh programs, even those run from
executables and not as an interactive shell, and furthermore due to
OS X's use of `path_helper` in `/etc/zprofile` which runs after that,
it's not a good place to configure additional PATH entries.

From zsh(1) man page:

> As /etc/zshenv is run for all instances of zsh, it is important that
> it be kept as small as possible.

So `.zshenv` is generally considered advanced usage and is not
recommended that people drop their casual login shell config in here.
Because of people's historical misuse of `.zshenv`, stop documenting it
in the README and suggest that people do their PATH and other
configuration in `.zshrc`.
2015-10-23 12:26:07 -04:00
Mislav Marohnić
febd718efe Move EDITOR and PATH tweaks from .zshenv to .zshrc
Making tweaks such as setting EDITOR or changing PATH only makes sense
for interactive shells, e.g. those that open in your Terminal window or
when you log in to a server. Non-interactive shells (such as those
started by running `zsh myscript.zsh` or any executable with `zsh`
shebang) should instead inherit those values from the environment.

Furthermore, changing PATH in `~/.zshenv` is not advised since stock
OS X `/etc/zprofile` will reoder PATH by means of `path_helper`, so it's
better to make any additional PATH manipulation in `~/.zprofile` or
`~/.zshrc`.
2015-10-23 12:24:51 -04:00
Mislav Marohnić
f159f1a326 Revert "Add instructions to fix path on OS X El Capitan"
For years, OS X has mistakently invoked `path_helper` in `/etc/zshenv`
(affecting all zsh runtimes, even non-interactive shells such as
scripts) instead of from `/etc/zprofile` where it should have been
because it needs to only run once for a login shell.

This frustrated a lot of users since `path_helper` would unexpectedly
reorder their PATH by putting system paths first during nested
invocations of zsh. Many have disabled their `path_helper` because they
believed it to be the culprit. Instead, what they should have done is
fixed the OS X configuration bug and renamed their `/etc/zshenv` to
`/etc/zprofile`.

Recently, El Capitan shipped and users of zsh rejoiced because it has
finally fixed its faulty zsh configuration: the `path_helper` is now
correctly invoked from `/etc/zprofile`. This was a deliberate change on
Apple's part and is a BUG FIX, NOT A REGRESSION.

However, now this project suggests the opposite: revert the El Capitan
fix and move `/etc/zprofile` to `/etc/zshenv`. This is unwise since it
teleports us to the olden days of broken zsh configuration. Please don't
instruct users to break their system.

This reverts commit 15de0bcfee.
2015-10-23 12:23:19 -04:00
Geoff Harcourt
3b4de90ab4 Fix minor spelling error in command code comment 2015-10-21 08:19:17 -04:00
Sean Doyle
7733711c3b Add git pf alias
Using `--force-with-lease` allows one to force push without the risk of
unintentionally overwriting someone else's work.

The git-push(1) man page states:

> Usually, "git push" refuses to update a remote ref that is not an
> ancestor of the local ref used to overwrite it.
>
> This option overrides this restriction if the current value of the
> remote ref is the expected value. "git push" fails otherwise.
>
> --force-with-lease alone, without specifying the details, will protect
> all remote refs that are going to be updated by requiring their
> current value to be the same as the remote-tracking branch we have for
> them.
>
> --@calleerlandsson
> -- https://github.com/thoughtbot/guides/pull/363
2015-10-16 11:47:58 -04:00
Geoff Harcourt
8441455538 Remove zsh jj keybinding
As reported in #405, the `jj` keybinding is problematic for some users
as it enters vi-mode whenever a user types a string that actually
contains two consecutive `j`s.

While consecutive `j`s are unusual in English, usernames with
consecutive `j`s such as that of the contributor who reported the
problem (@jjlangholtz) are common enough that we shouldn't force this
mapping on users.

Users can add their own keybinding to their local configuration or use
the already-provided `Esc` binding to enter vi-mode.

PR #405 contains other keybinding changes that we don't want to apply,
this commit addresses only the `jj` binding.
2015-10-16 09:12:40 -04:00
Valentino
9aa2cd5026 Use command -v instead of which in conditionals
Reason: https://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script/677212#677212
2015-10-16 09:03:28 -04:00
Mike Burns
24634ada70
Remove unused Easter egg
The `ranch` subcommand is annoying to skip and adds clutter to our
system, which only encourages people not to use our dotfiles as a base.
Remove it to get customizability back.
2015-10-09 13:17:54 +02:00
Joël Quenneville
dbb72cea5f Add custom git command git ranch
Sometimes when typing `git branch` I leave off the leading `b`, leading
to the boring message:

> git: 'ranch' is not a git command. See 'git --help'.

This adds a custom `git ranch` command with a friendlier funny message.
2015-10-09 11:53:36 +01:00
Andy Waite
66d40a1969 Clarify integration with Exuberant Ctags
The ctags.vim plugin was removed in #375. I updated the README to
document the Vim mapping for re-indexing a project's ctags.
2015-10-08 22:36:17 +01:00
Geoff Harcourt
a67c2823b7 Use vim-projectionist and vim-rake
vim-projectionist provides vim-rails-like shortcuts for alternate and
related files. It allows users to provide a custom set of "projections"
that map filetypes to their alternate and related counterparts. Custom
mappings can be declared in a JSON-like syntax.

This change provides authors of gems and other non-Rails Ruby projects
with access to the alternate file `:A` shortcuts to navigate between
code and specs. vim-rake automatically maps code/spec mappings for Ruby
files if vim-projectionist is available.

Close #381.
2015-10-03 11:26:03 -04:00
Geoff Harcourt
644c65df95 Merge pull request #424 from zillou/readme-command-fix
Fix syntax for OS X path_helper directions in README
2015-10-03 10:33:17 -04:00
Derrick Zhang
a3337fe6a1 Fix a command in README 2015-10-03 22:18:14 +08:00
Geoff Harcourt
15de0bcfee Add instructions to fix path on OS X El Capitan
OS X 10.11 changes the file where `path_helper` is invoked from
`/etc/zshenv` to `/etc/zprofile`. The change results in `path_helper`
rearranging the path in such a way that interferes with path changes
made in `.zshenv`.

This README update instructs users to rename `/etc/zprofile` to
`/etc/zshenv` so that `.zshenv` (and `.zshenv.local`) will be loaded
*after* `path_helper` is called, maintaining the desired precedence of
paths.

Thanks to @reshleman and @ventsislaf for investigating and offering
solutions.
2015-10-02 14:55:18 -04:00
Dan Croak
9262c9aa48 Add screenshot of prompt to README 2015-10-02 09:02:05 -07:00
Geoff Harcourt
f69c0e1986 Update README to advise running rcup after update
In #408 a user reported errors after pulling down master and opening
Vim without having run `rcup`. This documentation change updates the
section on `rcup` to advise running the command after pulling from the
origin.

Other changes:
* Removed outdated references to `m` and `rk` aliases, which have been
  removed from the repository.
* Added reference to `migrate` alias, which remains in the repository.
2015-08-25 16:21:37 -04:00
Timothy Fenney
74fd8a362e Add quotes for variables in replace 2015-07-28 21:20:01 -04:00
Blaine Schmeisser
f908cc9b8f Update amend to set the current date on the commit. 2015-07-12 13:16:26 -07:00
Seva Rybakov
9d75c20787 Update README.md 2015-07-04 18:40:22 +03:00
Derek Prior
6a034a7d65
Ignore "useless use of variable in void context"
The following ERB generates a "Possibly useless use of variable in void
context" warning from Syntastic:

```erb
<%= comment %>
```

The warning can be eliminated by making it:

```erb
<%= comment.to_s %>
```

However, this behavior is the default and is redundant. There are other
cases where this warning pops up and in each case I've found it to be of
no use.
2015-06-15 10:43:10 -04:00
Greg Lazarev
4713baaeec Add third-party site-functions to $fpath
Third-party completions get added to
`/usr/local/share/zsh/site-functions`.

Standard `$fpath` contains `/usr/share/zsh/site-functions`
(not the missing `local`).

By adding this to the `$fpath` git subcommands get completed correctly.
Related to https://github.com/thoughtbot/dotfiles/pull/373.
2015-05-26 14:09:24 -07:00
Greg Lazarev
f6ce831b9d Remove uncommon aliases 2015-05-26 14:08:04 -07:00
Tute Costa
87e72a9098 Use C-s as tmux prefix
C-a allow use to trigger tmux prefix more easily than C-b, at the cost
of overriding the readline beginning of line. This change remaps it to
C-s, which has the same effect without that drawback.

Remove last-pane bindings.
Map prefixes to underlying behavior

Quoting Chris Toomey:

> I'm wondering if we might want to take a different approach with these
> keys. last-pane is already bound to ; by default which is comfortably
> on the home row, and if using vim-tmux-navigator also bound to
> (unprefixed) C-\.
2015-05-22 14:53:40 -04:00
Dean Tambling
66491639e4 Added git_template/info/exclude for Xcode
Xcode >=6.0.1 throws an error when creating a new git-tracked project
without an 'exclude' file. Created the exclude file to correspond to
the existing gitignore file.

More info about this file:
http://seejohncode.com/2012/02/29/git-info-exclude
2015-05-22 11:36:42 -07:00
Jacopo Notarstefano
13b182f973 Add "^K" keybind
Bind "^K" to the kill-line command.
2015-05-22 11:22:50 -07:00
Daniel Nolan
b0ab8136b6 Source matchit.vim from vim/macros directory
* After removing the matchit.vim plugin from the vimrc.bundles file in
  this pull request https://github.com/thoughtbot/dotfiles/pull/379. It
  was brought to my attention that plugins in the macros directory are
  not automatically loaded due to backwards compatibility issues.
* Add entry to vimrc to source the matchit.vim plugin from the macros
  directory, if the user does not have it installed already. This is how
  Tim Pope adds the matchit.vim plugin to vimrc in his vim-sensible plugin.
  https://github.com/tpope/vim-sensible/blob/master/plugin/sensible.vim#L88
2015-05-22 11:21:22 -07:00
Grayson Wright
d68ba14669 Update tat script to accept optional session name
If no session name is provided,
it will generate one from the current directory.
2015-05-15 17:37:25 -07:00
Jefferson Queiroz Venerando
0ee272928f Update README to use vim-plug syntax
The examples were using the vundle syntax instead.
2015-05-12 11:19:11 -03:00
Josh Leichtung
ae4fa0a19a Update shim that helps migrate to vim-plug
Improve the shim to catch both `Plugin` and `Bundle` commands
for users that are still using Vundle's older syntax.
2015-05-08 14:50:49 -07:00
Greg Lazarev
7aba66a9d6 Remove ctags.vim plugin
The plugin seems abandoned and doesn't work with our setup as it is.
2015-05-08 14:45:32 -07:00
Derek Prior
734c130822 Add "bundle search" subcommand
Bundler 1.8+ added support for git-style subcommands. Any scripts
starting with `bundler-` in your path are executable as bundler
subcommands.

This adds `search` as a subcommand that uses `ag` to search for a string
among all gems in your bundle (default) or optionally a specific gem.
I've found this useful for finding the source of puzzling deprecations,
finding what gem provides a method, and other various things.
2015-05-08 14:44:00 -07:00
Daniel Nolan
58bb228f75 Remove matchit.zip plugin
* This plugin is no longer maintained and is included in vim by default.
* Per the docs at https://github.com/vim-scripts/matchit.zip
  Since vim 6.0, matchit.vim has been included in the standard vim distribution,
  under the macros/ directory; the version here may be more recent.
* The version included in the vim macros directory is the same version
  being added in the vimrc.bundles file from github version 1.13.2
2015-05-08 14:36:22 -07:00
Sean Doyle
1fcbe111c6
Exclude node_modules and bower_components
This is equivalent to excluding `vendor/assets` in a Rails project.

JS Dependency trees (especially npm packages) can be extremely noisy.
2015-05-08 12:00:07 -04:00
George Brocklehurst
ed6f00931a
Enable Git's autosquash feature by default.
Autosquash makes it quicker and easier to squash or fixup commits during an
interactive rebase. It can be enabled for each rebase using `git rebase -i
--autosquash`, but it's easier to turn it on by default.

Say I have this history:

    $ git log --oneline
    aaa1111 A first commit
    bbb2222 A second commit
    ccc3333 A third commit

I make another change that I already know should be squashed into "A
second commit". I can do this:

    $ git add .
    $ git commit --squash bbb2222
    [my-branch ddd4444] squash! A second commit

Then when I rebase:

    $ git rebase -i origin/my-branch

The interactive rebase list will be set up ready to squash:

    pick aaa1111 A first commit
    pick bbb2222 A second commit
    squash ddd4444 squash! A second commit
    pick ccc3333 A third commit

Since it's unlikely that anyone will be writing a commit message that begins
`squash!` or `fixup!` when they don't want this behaviour, and the user
still has a chance to review what's going to happen with the rebase, it's
safe to have it always turned on.
2015-05-02 22:37:41 -04:00
Geoff Harcourt
5724d124a5 Use vim-plug over vundle
[vim-plug](https://github.com/junegunn/vim-plug) has a number of
advantages over Vundle:

* Installs and updates plugins very quickly in parallel
* Can lock plugins at versions/tags
* Can rollbacks updates (useful if a plugin breaks) and take/reload
  snapshots of current state
* Optionally lazily-load plugins when their relevant command is invoked
* Execute post-update hooks for plugins with compiled extensions, etc.

vim-plug uses a DSL very close to Vundle (simplest form is `Plug` vs.
`Plugin`), and here it is set to continue to use the same plugin
location that Vundle was using before.

After updating, users will need to
1. Rename `Plugin` lines in `.vimrc.bundles.local` to use `Plug`
2. Run `:PlugInstall` (the post-up hook does this)
2015-04-27 19:14:22 -04:00
Dan Croak
24b34d1bec Move Git aliases to subcommand scripts
Any executable script on you PATH
that is named `git-some-name`
will be available as a git subcommand,
which means you could do `git some-name` to run the script.

Git adds them to `git help -a` under the title
"git commands available from elsewhere on your $PATH",
which will then power the auto completion,
so that will also work for any command you add.

http://blog.zamith.pt/blog/2014/11/05/supercharging-your-git/

Examples of other projects that structure their dotfiles like this:

https://github.com/robbyrussell/oh-my-zsh
https://github.com/tj/git-extras
https://github.com/holman/dotfiles
2015-04-27 13:47:52 -07:00
Greg Lazarev
266984354b Ignore vendor/ during ag searches 2015-04-09 14:46:10 -07:00
Andy Waite
fc4f011862 Enable autocomplete with dictionary words
Enable autocomplete with dictionary words when
spell check is on.
2015-04-09 10:30:07 -07:00
Jessie A. Young
b3cb23830d Remove GitHub colorscheme
* Every time I pull updates from this repo into my own dotfiles, I have to
  reconfigure my preferred theme (solarized)
* Seems like there is not a majority or plurality of thoughbotters using a
  single colorscheme
* Easiest to just not specify a colorscheme
* See https://forum.upcase.com/t/why-is-the-default-vim-theme-on-dotfiles-is-github/4232
2015-03-18 10:16:39 -07:00
Derek Prior
cf624303b5
Let ctrl-p find files with a leading dot
I am constantly forgetting that I can't use `ctrl-p` to open
`.travis.yml` or any other file with a leading `.`. This change comes
about after some discussion in general on how to handle this. Passing
`--hidden` to the `ag` command allows it to find files with a leading
`.`.

Unfortunately, this also includes the content of your `.git`
directory. To overcome this, we add `/.git/` to `agignore`.
2015-03-13 14:17:51 -04:00