Merge branch 'main' into ajeet/multi

This commit is contained in:
Ajeet D'Souza 2021-04-29 01:30:24 +05:30 committed by GitHub
commit a545e81555
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 25 deletions

View File

@ -9,17 +9,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Manpages for each subcommand.
- Manpages for all subcommands.
- Default prompt for Nushell.
### Changed
- `zoxide remove -i` now accepts multiple selections.
- `zoxide add` no longer accepts zero parameters.
- `$_ZO_EXCLUDE_DIRS` now defaults to `"$HOME"`.
### Fixed
- `cd -` on fish shells.
- `__zoxide_hook` no longer changes value of `$?` within `$PROMPT_COMMAND` on bash.
## [0.6.0] - 2021-04-09
@ -123,7 +125,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- `fish` no longer `cd`s to the user's home when no match is found.
- fish no longer `cd`s to the user's home when no match is found.
## [0.3.1] - 2020-04-03
@ -163,7 +165,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Incorrect exit codes in `z` command on `fish`.
- Incorrect exit codes in `z` command on fish.
### Removed
@ -176,7 +178,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `$_ZO_ECHO` to echo match before `cd`ing.
- Minimal `ranger` plugin.
- PWD hook to only update the database when the current directory is changed.
- Support for the `bash` shell.
- Support for bash.
- `migrate` subcommand to allow users to migrate from `z`.
### Fixed
@ -190,11 +192,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `init` subcommand to remove dependency on shell plugin managers.
- Support for `z -` command to go to previous directory.
- `Cargo.lock` for more reproducible builds.
- Support for the `fish` shell.
- Support for the fish shell.
### Fixed
- `_zoxide_precmd` overriding other precmd hooks on `zsh`.
- `_zoxide_precmd` overriding other precmd hooks on zsh.
## [0.1.1] - 2020-03-08
@ -216,7 +218,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- GitHub Actions pipeline to build and upload releases.
- Support for the `zsh` shell.
- Support for zsh.
[0.6.0]: https://github.com/ajeetdsouza/zoxide/compare/v0.5.0...v0.6.0
[0.5.0]: https://github.com/ajeetdsouza/zoxide/compare/v0.4.3...v0.5.0

View File

@ -42,18 +42,20 @@ If you would rather not run a script, you can download the binary from the
#### On Linux
| Distribution | Repository | Instructions |
| -------------- | ----------------------- | --------------------------------------------------------- |
| **Any** | [crates.io] | `cargo install zoxide` |
| **Any** | [Linuxbrew] | `brew install zoxide` |
| Alpine Linux | [Alpine Linux Packages] | `apk add zoxide` |
| Arch Linux | [AUR] | `yay -Sy zoxide-bin` |
| CentOS | [Copr] | `dnf copr enable atim/zoxide` <br /> `dnf install zoxide` |
| Debian Testing | [Debian Packages] | `apt install zoxide` |
| Fedora | [Fedora Packages] | `dnf install zoxide` |
| NixOS | [nixpkgs] | `nix-env -iA nixpkgs.zoxide` |
| Parrot OS | | `apt install zoxide` |
| Void Linux | [Void Linux Packages] | `xbps-install -S zoxide` |
| Distribution | Repository | Instructions |
| ------------------ | ----------------------- | --------------------------------------------------------- |
| **Any** | [crates.io] | `cargo install zoxide` |
| **Any** | [Linuxbrew] | `brew install zoxide` |
| Alpine Linux 3.13+ | [Alpine Linux Packages] | `apk add zoxide` |
| Arch Linux | [AUR] | `yay -Sy zoxide-bin` |
| CentOS 7+ | [Copr] | `dnf copr enable atim/zoxide` <br /> `dnf install zoxide` |
| Debian Testing | [Debian Packages] | `apt install zoxide` |
| Devuan 4.0+ | [Devuan Packages] | `apt install zoxide` |
| Fedora 32+ | [Fedora Packages] | `dnf install zoxide` |
| NixOS | [nixpkgs] | `nix-env -iA nixpkgs.zoxide` |
| Parrot OS | | `apt install zoxide` |
| Ubuntu 21.04+ | [Ubuntu Packages] | `apt install zoxide` |
| Void Linux | [Void Linux Packages] | `xbps-install -S zoxide` |
#### On macOS
@ -219,6 +221,7 @@ Be sure to set these before calling `zoxide init`.
| ------------------- | --------- | ----------------------- |
| Linux / macOS / BSD | `:` | `$HOME:$HOME/private/*` |
| Windows | `;` | `$HOME;$HOME/private/*` |
- By default, this is set to `"$HOME"`.
- `_ZO_FZF_OPTS`
- Custom options to pass to [`fzf`][fzf]. See `man fzf` for the list of
options.
@ -244,6 +247,7 @@ Be sure to set these before calling `zoxide init`.
[crates.io]: https://crates.io/crates/zoxide
[debian packages]: https://packages.debian.org/testing/admin/zoxide
[demo.gif]: demo.gif
[devuan packages]: https://pkginfo.devuan.org/cgi-bin/package-query.html?c=package&q=zoxide
[dports]: https://github.com/DragonFlyBSD/DPorts/tree/master/sysutils/zoxide
[fedora packages]: https://src.fedoraproject.org/rpms/rust-zoxide
[freshports]: https://www.freshports.org/sysutils/zoxide/
@ -260,6 +264,7 @@ Be sure to set these before calling `zoxide init`.
[releases]: https://github.com/ajeetdsouza/zoxide/releases
[scoop]: https://github.com/ScoopInstaller/Main/tree/master/bucket/zoxide.json
[termux]: https://github.com/termux/termux-packages/tree/master/packages/zoxide
[ubuntu packages]: https://packages.ubuntu.com/hirsute/zoxide
[void linux packages]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/zoxide
[xxh-plugin-prerun-zoxide]: https://github.com/xxh/xxh-plugin-prerun-zoxide
[xxh]: https://github.com/xxh/xxh

View File

@ -84,8 +84,8 @@ T}
Windows|\fI;\fR eg. $HOME;$HOME/private/*
.TE
.sp
After setting this up, you might need to use \fBzoxide-remove\fR(1) to remove
any existing entries from the database.
By default, this is set to \fI"$HOME"\fR. After setting this up, you might need
to use \fBzoxide-remove\fR(1) to remove any existing entries from the database.
.TP
.B _ZO_FZF_OPTS
Custom options to pass to fzf. See \fBman fzf\fR for the list of options.

View File

@ -2,6 +2,7 @@ use crate::db::Rank;
use anyhow::{bail, Context, Result};
use dirs_next as dirs;
use glob::Pattern;
use std::env;
use std::ffi::OsString;
@ -29,18 +30,27 @@ pub fn zo_echo() -> bool {
}
}
pub fn zo_exclude_dirs() -> Result<Vec<glob::Pattern>> {
pub fn zo_exclude_dirs() -> Result<Vec<Pattern>> {
match env::var_os("_ZO_EXCLUDE_DIRS") {
Some(dirs_osstr) => env::split_paths(&dirs_osstr)
.map(|path| {
let pattern = path
.to_str()
.context("invalid unicode in _ZO_EXCLUDE_DIRS")?;
glob::Pattern::new(&pattern)
Pattern::new(&pattern)
.with_context(|| format!("invalid glob in _ZO_EXCLUDE_DIRS: {}", pattern))
})
.collect(),
None => Ok(Vec::new()),
None => {
let pattern = (|| {
let home = dirs::home_dir()?;
let home_str = home.to_str()?;
let home_esc = Pattern::escape(home_str);
Pattern::new(&home_esc).ok()
})();
Ok(pattern.into_iter().collect())
}
}
}

View File

@ -8,7 +8,7 @@ impl Query {
I: IntoIterator<Item = S>,
S: AsRef<str>,
{
Query(keywords.into_iter().map(|s: S| to_lowercase(s)).collect())
Query(keywords.into_iter().map(to_lowercase).collect())
}
pub fn matches<S: AsRef<str>>(&self, path: S) -> bool {

View File

@ -24,6 +24,10 @@ function __zoxide_cd() {
# Hook configuration for zoxide.
#
{# Custom prompts often use "$?" to show the exit status of the previous
# command. Adding __zoxide_hook to the front of $PROMPT_COMMAND would change
# the exit status, so we must capture it and return it manually instead. -#}
# Hook to add new entries to the database.
{%- match hook %}
{%- when Hook::None %}
@ -31,11 +35,14 @@ function __zoxide_cd() {
{%- when Hook::Prompt %}
function __zoxide_hook() {
\builtin local -r __zoxide_retval="$?"
zoxide add -- "$(__zoxide_pwd)"
return "${__zoxide_retval}"
}
{%- when Hook::Pwd %}
function __zoxide_hook() {
\builtin local -r __zoxide_retval="$?"
\builtin local -r __zoxide_pwd_tmp="$(__zoxide_pwd)"
if [ -z "${__zoxide_pwd_old}" ]; then
__zoxide_pwd_old="${__zoxide_pwd_tmp}"
@ -43,10 +50,15 @@ function __zoxide_hook() {
__zoxide_pwd_old="${__zoxide_pwd_tmp}"
zoxide add -- "${__zoxide_pwd_old}"
fi
return "${__zoxide_retval}"
}
{%- endmatch %}
{# bash throws an error if $PROMPT_COMMAND contains two semicolons in sequence.
# This is hard to avoid perfectly, but adding __zoxide_hook to the front of
# $PROMPT_COMMAND rather than the back makes this scenario unlikely. -#}
# Initialize hook.
if [ "${__zoxide_hooked}" != '1' ]; then
__zoxide_hooked='1'