Commit graph

23 commits

Author SHA1 Message Date
lunohodov
38d11d3afb Prevent unreadable prompt within Git repository
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).
2015-02-12 15:20:25 +01:00
Dan Croak
b0fe7c01ff Add git rename-branch alias
* Extract `git current-branch` alias.
* Re-use `git current-branch` in two places.
2015-01-25 16:48:36 -08:00
Mike Burns
c51b1e8c17
Fix the zsh config glob
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.
2014-10-03 10:28:08 -07:00
Robert Speicher
6a1bd18a1f Add zshenv file
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.
2014-09-12 11:45:03 -07:00
Mike Burns
73497a7c54
Introduce ~/.zsh/configs
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`.
2014-08-27 17:47:26 +02:00
Greg Lazarev
f5dc48659f Add /usr/local/bin to PATH before /usr/bin
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.
2014-07-21 09:59:32 -07:00
Dan Croak
7dbc8f44a1 Show only basename and git branch in prompt
* Switch order from "[git branch][pathname]" to "basename git branch %".
* Remove noisy brackets.

Example old:

    [master][~/dev/thoughtbot/dotfiles]

Example new:

    dotfiles dc-prompt %
2014-04-30 14:06:20 -07:00
Greg Lazarev
1ccc110a61 Improve zsh history
* "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`
2014-04-09 10:07:23 -07:00
Joe Ferris
aade91ee6f Don't attempt to autocorrect spelling
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.
2014-04-03 11:51:28 -04:00
Greg Lazarev
7007a86bce Combine zlogin settings into zshrc
* 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
2014-03-27 22:59:07 -07:00
Gabe Berke-Williams
71fbbc21d2 Don't set $EYRC
We don't use Engine Yard anymore.
2014-03-27 17:09:18 -04:00
Nils Petersohn
68689ec58b Add HISTFILE to save zsh history
History file needs to be specified or otherwise the history would not be saved
over multiple terminal sessions.
[Source](http://zsh.sourceforge.net/FAQ/zshfaq03.html#321)
2014-03-21 15:27:14 -07:00
Dan Croak
31b99d9728 Add rbenv shims and trusted binstubs to PATH
Our expected way of managing Rubies is with rbenv:

https://github.com/thoughtbot/laptop/blob/master/common-components/ruby-environment

This commit loads rbenv in `zshrc` as recommended by the rbenv docs:

https://github.com/sstephenson/rbenv#basic-github-checkout

Assuming the binstubs for a project are in the local bin/ directory, we
can even go a step further to add the directory to shell $PATH so that
rspec can be invoked without the bin/ prefix:

    export PATH="./bin:$PATH"

Doing so on a system that other people have write access to (such as a
shared host) is a security risk:

https://github.com/sstephenson/rbenv/issues/309

The `.git/safe` convention addresses the security problem:

https://twitter.com/tpope/status/165631968996900865

This zsh fix may be necessary for OS users in order to fix a bug:

https://github.com/thoughtbot/laptop/blob/master/mac-components/zsh-fix
2014-01-23 14:22:51 -08:00
Greg Lazarev
dd75d58dbf Cleanup zshrc
* remove duplicates with zlogin
* order by functions first, then bindings, then exports
* lowercase `setopt` arguments for consistency with `setopt` output
2013-12-26 12:58:01 -08:00
Mike Burns
fd9d6354cf The user is able to type [ or ]
There are many workarounds[1] to the

    zsh: no matches found: ...

issue, but let's just stop it at its core: turn off that `nomatch`
functionality.

Apologies to all who enjoy seeing the pun around:

    % got a light?
    zsh: no matches found: light?

But all good shell puns[2] must come to an end.

[1] http://robots.thoughtbot.com/post/18129303042/how-to-use-arguments-in-a-rake-task
[2] http://www-users.cs.york.ac.uk/susan/joke/unix.htm
2013-10-08 10:02:26 +02:00
Dan Croak
e69f7b7995 Source ~/.zshrc.local if it exists
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 -)"`.
2013-07-08 21:20:11 -07:00
Gabe Berke-Williams
89b60fcb49 g alias for git
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
2013-03-03 17:14:16 -05:00
Mike Burns
390a383b6b Set $VISUAL
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.
2013-02-15 10:22:41 +01:00
Joe Ferris
6603b694b0 Replace s shell script with rspec shell function and alias
* 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
2013-01-18 13:24:53 -05:00
Nick Quaranto
717cf442b0 add in zshkit fun stuff 2011-04-04 10:27:03 -04:00
Dan Croak
ead8c516ed adding quotes around Ctrl bindkeys to stop warnings when starting a new shell 2011-03-25 09:45:53 -04:00
Mike Burns
ea2569ca19 Some useful Mike Burns-isms 2011-01-14 01:17:25 -05:00
Joe Ferris
a95b1f7242 zsh config 2011-01-13 17:26:04 -05:00