ASDF manages languages versions for many languages instead of just one.
This commit adds ASDF to path and completions for zsh, so that it's
easier to use.
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`
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.
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`.
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.
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.
When within a git repository, doing a tab-autocomplete on a command results with the command becoming unreadable. The command still works but this is pretty annoying visually.
Basically I
1. Navigate to a directory with a git repository in it. The prompt indicates the current branch properly
2. Next, type `git -` and hit tab
The prompt now shows only part of branch's name with the first suggestion appended.
After googling a bit I stumbled upon several pages describing a similar problem (most useful to me was http://stackoverflow.com/questions/23740862/issues-with-zsh-prompt).
The culprit seems to be the git_prompt_info function escaping the `$current_branch` variable as if it is a color. As a result zsh is confused where the cursor is. After "unescaping" the variable everything seems to work fine.
Using zsh 5.0.7 (x86_64-apple-darwin13.4.0).
The glob used a modifier, but it was modifying a directory instead of a
glob that matched all the files in the directory. Add the missing `*` to
fix this.
From the [Zsh manual](http://zsh.sourceforge.net/Intro/intro_3.html):
> '.zshenv' is sourced on all invocations of the shell, unless the -f option is
> set. It should contain commands to set the command search path, plus other
> important environment variables. `.zshenv' should not contain commands that
> produce output or assume the shell is attached to a tty.
Why is this important? [Alfred](http://www.alfredapp.com/) workflows run in
non-interactive shells. When the `$PATH` is set, or `rbenv` is initialized, in
`zshrc` instead of `zshenv`, those workflows will not use the correct Ruby
version and might not have access to certain bin files, such as those from
`$HOME/.bin/` or Homebrew.
Just before loading `~/.zshrc.local`, load:
1. `~/.zsh/configs/pre/**/*`
2. `~/.zsh/configs/**/*` # excluding pre and post
3. `~/.zsh/configs/post/**/*`
About the zsh glob:
- `.`: only produce normal files.
- `-`: follow symlinks to their final file; skip any broken links.
- `N`: do not complain about zero matches.
Big ups to Pat Brisbin for finding `N`.
This is for homebrew binaries to work.
Load `rbenv` after adding `$HOME/.bin` and `/usr/local/bin` to `PATH`, but
before adding project-specific binstubs.
* Switch order from "[git branch][pathname]" to "basename git branch %".
* Remove noisy brackets.
Example old:
[master][~/dev/thoughtbot/dotfiles]
Example new:
dotfiles dc-prompt %
* "to the $HISTFILE incrementally (as soon as they are entered), rather than
waiting until the shell exits"
* replace any duplicate in the history, not just the previous duplicate: allows
for a cleaner history
* `.zhistory` is more idiomatic than `.zsh_history`
This frequently catches false positives for aliases, particularly for
subcommands. It also takes just as long to look at the autocorrect
prompt and select "y" as it does to just retype the command yourself.
* easier when everything is just one file
* most (if not all) interactive shells are login shells and we likely want those
settings for interactive shells
* remove duplicates with zlogin
* order by functions first, then bindings, then exports
* lowercase `setopt` arguments for consistency with `setopt` output
Follows the pattern of:
* ~/.aliases.local in ce7ad49
* ~/.gitconfig.local in 8e141fe
* ~/.vimrc.local in a666267
Use consistent:
* `source`ing style.
* commenting style.
I am using ~/.zshrc.local as a home for `eval "$(rbenv init -)"`.
With arguments, g acts like git.
Without arguments, it runs `git status`.
* Source functions/* after loading ZSH completion so `compdef` is available to g
alias
Most tools look for $VISUAL before $EDITOR, and we tend to want that
anyway. This allows people to customize the two, for example using GUI
vim for $VISUAL and normal vim for $EDITOR, or more extreme: `ex -v` for
$VISUAL and `ex` for $EDITOR.
* Use a regular alias to make `s` short for `rspec`
* Use an `rspec` shell function to route to zeus when appropriate
* Removes confusion from `s` working differently than `rspec`
* Removes need to use a special alias to get zeus working