Commit graph

38 commits

Author SHA1 Message Date
Daniel Barber
57e23e0e67 Dirname is clearer here 2019-07-17 17:53:22 -04:00
Daniel Barber
52ee922459 Use the location of brew to determine where asdf is 2019-07-17 17:40:42 -04:00
Daniel Barber
dbbae5752b brew --prefix will return something whether ASDF is installed or not
So we should check that the file exists before we try calling it.
2019-07-17 10:09:26 -04:00
Daniel Barber
cdd0d2ced8 Assume people don't change their Homebrew dir
It checks the home directory location and the default Homebrew location
before falling back to `brew --prefix` (Sloooow!)

This also accounts for non macOS systems that don't have Homebrew.
2019-07-17 10:09:26 -04:00
Daniel Barber
2af1b50124 Account for asdf being installed by Homebrew
If `asdf` has been installed via Homebrew the completions file is in a
different place. This PR takes that possibility into account.
2019-07-17 10:09:26 -04:00
Mike Burns
6c8205bad4
Make Homebrew analytics opt-in
Currently [Homebrew implements analytics] as opt-out, forcing it on its
users without their enthusiastic consent or a full understanding of the
implications.

This changes it to opt-in: we opt-out by default, and to opt in to
Homebrew analytics we can override it in `~/.zshrc.local`:

```sh
unset HOMEBREW_NO_ANALYTICS
```

[Homebrew implements analytics]: https://docs.brew.sh/Analytics
2019-05-03 10:45:53 -04:00
Brett MacDonald
d69b67004e Improve successive startup time; fix conflict.
- Don't update completion dump if it has been updated within 24hrs.
- Unload Completion for zsh bundled function mcd to prevent conflict. #594
2018-07-15 15:49:04 -04:00
Geoff Harcourt
aa2f5b3d13 Remove deprecation warning for rbenv -> asdf
This change removes the deprecation warning and shim we added during the
transition from rbenv to asdf.
2018-01-05 14:07:20 -05:00
Bernerd Schaefer
06b4bf8c9c zsh: Allow prompt to be overridden
`zsh/configs/prompt.zsh` sets up the dotfile's custom prompt. It
currently does so in a way which prevents overriding the prompt for
specific invocations of zsh.

I noticed this because I've got a helper script for getting a shell
fully configured to work with the AWS CLI that ends with
`PS1='[aws] ' exec "$SHELL"` to distinguish the shell from other
sessions. With a vanilla zsh (and bash) setup, this correctly sets the
prompt on the new shell.

Here's a minimal demonstration with vanilla zsh:

```
bernerdscha-ltm% echo $PS1
%m%#
bernerdscha-ltm% PS1="hi> " exec zsh
hi>
```

And with dotfiles:

```
dotfiles bs-override-ps1 % echo $PS1
${SSH_CONNECTION+"%{$fg_bold[green]%}%n@%m"}%{$fg_bold[blue]%}%c%{$reset_color%}$(git_prompt_info) %#
dotfiles bs-override-ps1 % PS1="hi> " exec zsh
dotfiles bs-override-ps1 %
```

This PR updates prompt.zsh to only update the prompt if there's not an
existing exported PS1 variable. The export check is relevant because in
the default case where PS1 is not explicitly set  by the user it will
have already been set (but not exported) by the default zsh configs.
2017-12-06 10:24:13 -05:00
Brad Urani
4fa7cd6f4b Filter commented lines out of .env in envup
Makes envup filter out comments in the .env file even if the line starts
with whitespace
2017-09-26 17:14:04 -04:00
Derek Prior
346268b6e7 Add deprecation 2017-09-15 14:36:21 -04:00
Derek Prior
3d11861f82 Use ASDF for version managment
ASDF has plugins for Ruby, Node, Elixir, Haskell, Scala, Go, etc.
Instead of finding and installing a new tool each time we have need for
a version manager in a new tools, we can use the same tool we already
know, adding a new plugin.

This change is the result of a successful [research card][1] and has a
corresponding change to [laptop][2].

[1]: https://trello.com/c/MVbfz8e5/676-asdf-for-tool-management
[2]: https://github.com/thoughtbot/laptop/pull/502
2017-09-15 14:36:21 -04:00
Greg Lazarev
b5c26215a1
Add export to support Elixir/Erlang history
[Sourced from this](https://til.hashrocket.com/posts/is9yfvhdnp-enable-history-in-iex-through-erlang-otp-20-)
2017-08-29 10:04:28 -07:00
Mike Burns
a1a9f6d694
Add a zsh binding for push-line-or-edit: ^Q
The use case for push-line-or-edit:

1. You are in the middle of typing a long command, perhaps something
involving `tar`.
2. You realize that you must first run another command, such as `man
tar`.
3. You invoke `push-line-or-edit`, which gives you a fresh prompt. You
type `man tar` and read as needed.
4. When the command (`man tar`) finishes, the long command you
half-typed is back, exactly as you left off.

Other use cases are realizing that you're in the wrong directory before
you press enter, changing your Ruby version before you press enter on
that `bundle` command, or in general being partway through something and
realizing that you're not quite ready to run it yet.

While here, turn off start/stop output control, which gives us back the
^Q keybinding.
2016-06-10 14:56:43 +02:00
Robert Eshleman
bd3c5daf7f Remove Unused move_to_front_of_path Function
In #440, a `move_to_front_of_path` function was introduced, but
was [ultimately not used][1] when these changes were merged as f7c73f7.
The function itself was not removed, however.

This commit removes the unused function.

[1]: https://github.com/thoughtbot/dotfiles/pull/440#issuecomment-156549420
2015-11-16 15:26:41 -05:00
Geoff Harcourt
6cc0cb9302 Add tab-completion with local branches for git delete-branch
This solution was heavily influenced by @keith's original contribution
in #356, which I think may have worked on some but not all setups due to
personal configuration differences.

The solution in #356 added the `_git_delete_branch` function in the
`zsh/completions` folder, which resulted in the tab-completion working
against `git`, but not against our `g` function. With our new loading
order where functions are loaded first and completions are loaded last,
we can load the `_git_delete_branch` function before any completions are
defined on `git`, `g`, or `hub`, allowing the `_git_delete_branch` shim
to be used by all three of those git-invoking commands/functions.

Close #355.
2015-11-14 10:15:24 -05:00
Geoff Harcourt
b3a3c2e67d Don't export $PS1
The `$PS1` variable does not need to be exported in order for `zsh` to
use its contents to set prompt options. `export`ing it has the negative
side-effect of polluting prompts in shells launched from `zsh`. The
`export`ing of `$PS1` is the cause of #270, where using `sudo su` to
become another user (launching a non-`zsh` shell) resulted in a
corrupted prompt.

Removing the `export` will allow `sh`/`bash`/`dash` and other shells to
be launched from `zsh` without inheriting its prompt settings.

Fix #270.
2015-11-13 18:23:47 -05:00
Geoff Harcourt
f074afeae3 Use export -U to deduplicate $PATH
In f7c73f7c1b we started to deduplicate
`$PATH` using `typeset -U`, but that did not prevent duplicate `$PATH`
entries when processes were launched that inherited the environment from
an existing shell.

Using `export -U` keeps the `$PATH` deduplicated even when tmux launches
a new shell.

Fix #443.
2015-11-13 18:21:20 -05:00
David Alexander
f7c73f7c1b Deduplicate PATH before exporting
Why:

* Remove dupes from PATH

How:

$PATH is a scalar composed of contents of $path, so it uses typeset -U
("U" as in Unique) to ensure there are no dupes. It preserves the first
occurrence in the array, since it would be searched first before others
when matching a command in the directories in the PATH anyway.
2015-11-13 15:25:55 -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
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
Joshua Clayton
c17ff5ad37 Improve ag tab completion
* Remove unnecessary `uniq`
* Look for tags in tmp/tags or .git/tags
* Send errors to /dev/null if the file(s) do not exist

See http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html for an
explanation behind the reasoning for .git/tags.
2014-08-06 15:51:18 -04:00
Jessie A. Young
b9d24c014a Remove Zeus and Cucumber references
* Spring is now built in to Rails:
  http://weblog.rubyonrails.org/2014/4/8/Rails-4-1/
* Haven't used Cucumber on a project in over a year
2014-06-06 16:01:37 -04:00
Derek Prior
00dbd15af6 Remove functions wrapping Zeus
Project should be moving over to spring, as this is the 'blessed'
approach and is part of suspenders. Leaving these functions around adds
yet another layer of indirection to consider when trying to run these
commands:

* function wrapper
* binstub
* rbenv shim
* actual binary
2014-04-18 17:06:22 -04:00
Derek Prior
294f962f95 Complete parity commands like heroku
Adds tab completiong to `production` and `staging` which acts as tab
completion to heroku.
2014-01-23 18:35:34 -05:00
Chris Toomey
655a76a6c1 Add envup script for loading environment variables 2013-09-13 15:29:18 -04:00
Greg Lazarev
59bdc8d237 Don't use suffix flag for zsh compadd command
* Fixes an issue where tab completing specs that start with the same
words(s) makes tab completion freak out and stop working.

* The con is that we'll see "_spec.rb" in the output, like:

```zsh
$ rspec spec/models/
models/calendar_spec.rb
models/event_closer_spec.rb
...
```
2013-04-19 12:12:42 -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
Gabe Berke-Williams
1f4e6d1370 Use ag instead of ack
https://github.com/ggreer/the_silver_searcher

* ag is faster than ack
* ag searches all files by default (but still ignores gitignored files). This
  removes the need for ack's `--type-add=` options.
* The command is 33% shorter than ack!
2013-03-01 23:28:36 -05:00
Dan Croak
aa31dd7ad3 Add change-extension script
Add ability to change file extensions of files recursively in current
directory.
2013-02-14 11:05:26 -08:00
Dan Croak
bc6d3e6202 Make directory and change into it 2013-02-12 10:22:27 -08:00
Dan Croak
64e3c09e51 Pass arguments from rake shell function when not using zeus
Non-zeus path didn't pass arguments, so it just ran `rake`.
2013-02-12 10:10:04 -08:00
Joe Ferris
81d40fe855 Pass arguments from rspec shell function when not using zeus
* Non-zeus path didn't pass arguments, so it just ran `rspec`
2013-01-21 10:49:12 -05:00
Dan Croak
0d43fe5246 Use Zeus via aliases, rake
* Create `rake` function and `rk` alias.
* Add `z` alias for `zeus`.
* Alias `migrate` to `m` given how common a task it is.
2013-01-21 06:43:30 -08: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
Joshua Clayton
d16a4fe36c Tab-complete ack by looking at the tags file 2012-09-27 08:28:13 -04:00
Joe Ferris
a95b1f7242 zsh config 2011-01-13 17:26:04 -05:00