Installing asdf via Homebrew now requires souring from a different path.
This same issue was recently fixed in thoughbot/laptop by @cpytel, and so I've copied the changes from this commit:
aa3a84e15e
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.
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
`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.
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
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.
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.
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.
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.
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.
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`
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
**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
* 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.
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
* 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
...
```
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
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!
* 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