Commit graph

40 commits

Author SHA1 Message Date
komeil Parseh
b11f233fec
Customize dotfiles for Parch 2023-02-16 12:27:43 +03:30
Benjamin Eskola
46af61168b Make _load_settings() more concise
- Use the `~` glob operator to exclude *.zwc insead of a separate test
  (requires `setopt extendedglob`).
- Exclude both `pre` and `post` in one case alternative.
2019-01-21 20:25:14 -05:00
Derrick Carr
b860504752
Revert accidental merge from fork (#571)
This reverts two commits that were accidentally merged from a fork.
- commit c3180360ac
- commit ccb51c97c6
2017-11-17 16:36:59 -08:00
Derrick Carr
c3180360ac Use ASDF for version management
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.
2017-11-17 14:44:00 -08:00
John Eckhart
f4d509ffd0 Skip compiled wordcode files (ie. zwc extensions) 2017-08-25 15:35:02 -04:00
Geoff Harcourt
0078865a67 Revert "Skip compiled wordcode files (ie. zwc extensions)"
This reverts commit 5178a8a1a8.
2017-05-25 13:10:02 -04:00
Geoff Harcourt
88618e5858 Revert "Combine conditional statements"
This reverts commit cae0bd04ea.

This implementation appears to break sourced configurations. Reverting
until we figure out a resolution.
2017-05-25 13:04:30 -04:00
John Eckhart
cae0bd04ea Combine conditional statements 2017-05-23 16:29:16 -04:00
John Eckhart
5178a8a1a8 Skip compiled wordcode files (ie. zwc extensions) 2017-05-22 02:19:20 -04:00
David Thompson
5eff1d7afb Move aliases below local config
Enables overriding of aliases that environment variables
2017-01-19 18:03:30 -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
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ć
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
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
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
Jacopo Notarstefano
13b182f973 Add "^K" keybind
Bind "^K" to the kill-line command.
2015-05-22 11:22:50 -07:00
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