Merge branch 'main' into ajeet/multi
This commit is contained in:
commit
a545e81555
16
CHANGELOG.md
16
CHANGELOG.md
|
|
@ -9,17 +9,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Manpages for each subcommand.
|
- Manpages for all subcommands.
|
||||||
- Default prompt for Nushell.
|
- Default prompt for Nushell.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- `zoxide remove -i` now accepts multiple selections.
|
- `zoxide remove -i` now accepts multiple selections.
|
||||||
- `zoxide add` no longer accepts zero parameters.
|
- `zoxide add` no longer accepts zero parameters.
|
||||||
|
- `$_ZO_EXCLUDE_DIRS` now defaults to `"$HOME"`.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- `cd -` on fish shells.
|
- `cd -` on fish shells.
|
||||||
|
- `__zoxide_hook` no longer changes value of `$?` within `$PROMPT_COMMAND` on bash.
|
||||||
|
|
||||||
## [0.6.0] - 2021-04-09
|
## [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
|
### 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
|
## [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
|
### Fixed
|
||||||
|
|
||||||
- Incorrect exit codes in `z` command on `fish`.
|
- Incorrect exit codes in `z` command on fish.
|
||||||
|
|
||||||
### Removed
|
### 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.
|
- `$_ZO_ECHO` to echo match before `cd`ing.
|
||||||
- Minimal `ranger` plugin.
|
- Minimal `ranger` plugin.
|
||||||
- PWD hook to only update the database when the current directory is changed.
|
- 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`.
|
- `migrate` subcommand to allow users to migrate from `z`.
|
||||||
|
|
||||||
### Fixed
|
### 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.
|
- `init` subcommand to remove dependency on shell plugin managers.
|
||||||
- Support for `z -` command to go to previous directory.
|
- Support for `z -` command to go to previous directory.
|
||||||
- `Cargo.lock` for more reproducible builds.
|
- `Cargo.lock` for more reproducible builds.
|
||||||
- Support for the `fish` shell.
|
- Support for the fish shell.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- `_zoxide_precmd` overriding other precmd hooks on `zsh`.
|
- `_zoxide_precmd` overriding other precmd hooks on zsh.
|
||||||
|
|
||||||
## [0.1.1] - 2020-03-08
|
## [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
|
### Added
|
||||||
|
|
||||||
- GitHub Actions pipeline to build and upload releases.
|
- 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.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
|
[0.5.0]: https://github.com/ajeetdsouza/zoxide/compare/v0.4.3...v0.5.0
|
||||||
|
|
|
||||||
13
README.md
13
README.md
|
|
@ -43,16 +43,18 @@ If you would rather not run a script, you can download the binary from the
|
||||||
#### On Linux
|
#### On Linux
|
||||||
|
|
||||||
| Distribution | Repository | Instructions |
|
| Distribution | Repository | Instructions |
|
||||||
| -------------- | ----------------------- | --------------------------------------------------------- |
|
| ------------------ | ----------------------- | --------------------------------------------------------- |
|
||||||
| **Any** | [crates.io] | `cargo install zoxide` |
|
| **Any** | [crates.io] | `cargo install zoxide` |
|
||||||
| **Any** | [Linuxbrew] | `brew install zoxide` |
|
| **Any** | [Linuxbrew] | `brew install zoxide` |
|
||||||
| Alpine Linux | [Alpine Linux Packages] | `apk add zoxide` |
|
| Alpine Linux 3.13+ | [Alpine Linux Packages] | `apk add zoxide` |
|
||||||
| Arch Linux | [AUR] | `yay -Sy zoxide-bin` |
|
| Arch Linux | [AUR] | `yay -Sy zoxide-bin` |
|
||||||
| CentOS | [Copr] | `dnf copr enable atim/zoxide` <br /> `dnf install zoxide` |
|
| CentOS 7+ | [Copr] | `dnf copr enable atim/zoxide` <br /> `dnf install zoxide` |
|
||||||
| Debian Testing | [Debian Packages] | `apt install zoxide` |
|
| Debian Testing | [Debian Packages] | `apt install zoxide` |
|
||||||
| Fedora | [Fedora Packages] | `dnf install zoxide` |
|
| Devuan 4.0+ | [Devuan Packages] | `apt install zoxide` |
|
||||||
|
| Fedora 32+ | [Fedora Packages] | `dnf install zoxide` |
|
||||||
| NixOS | [nixpkgs] | `nix-env -iA nixpkgs.zoxide` |
|
| NixOS | [nixpkgs] | `nix-env -iA nixpkgs.zoxide` |
|
||||||
| Parrot OS | | `apt install zoxide` |
|
| Parrot OS | | `apt install zoxide` |
|
||||||
|
| Ubuntu 21.04+ | [Ubuntu Packages] | `apt install zoxide` |
|
||||||
| Void Linux | [Void Linux Packages] | `xbps-install -S zoxide` |
|
| Void Linux | [Void Linux Packages] | `xbps-install -S zoxide` |
|
||||||
|
|
||||||
#### On macOS
|
#### On macOS
|
||||||
|
|
@ -219,6 +221,7 @@ Be sure to set these before calling `zoxide init`.
|
||||||
| ------------------- | --------- | ----------------------- |
|
| ------------------- | --------- | ----------------------- |
|
||||||
| Linux / macOS / BSD | `:` | `$HOME:$HOME/private/*` |
|
| Linux / macOS / BSD | `:` | `$HOME:$HOME/private/*` |
|
||||||
| Windows | `;` | `$HOME;$HOME/private/*` |
|
| Windows | `;` | `$HOME;$HOME/private/*` |
|
||||||
|
- By default, this is set to `"$HOME"`.
|
||||||
- `_ZO_FZF_OPTS`
|
- `_ZO_FZF_OPTS`
|
||||||
- Custom options to pass to [`fzf`][fzf]. See `man fzf` for the list of
|
- Custom options to pass to [`fzf`][fzf]. See `man fzf` for the list of
|
||||||
options.
|
options.
|
||||||
|
|
@ -244,6 +247,7 @@ Be sure to set these before calling `zoxide init`.
|
||||||
[crates.io]: https://crates.io/crates/zoxide
|
[crates.io]: https://crates.io/crates/zoxide
|
||||||
[debian packages]: https://packages.debian.org/testing/admin/zoxide
|
[debian packages]: https://packages.debian.org/testing/admin/zoxide
|
||||||
[demo.gif]: demo.gif
|
[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
|
[dports]: https://github.com/DragonFlyBSD/DPorts/tree/master/sysutils/zoxide
|
||||||
[fedora packages]: https://src.fedoraproject.org/rpms/rust-zoxide
|
[fedora packages]: https://src.fedoraproject.org/rpms/rust-zoxide
|
||||||
[freshports]: https://www.freshports.org/sysutils/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
|
[releases]: https://github.com/ajeetdsouza/zoxide/releases
|
||||||
[scoop]: https://github.com/ScoopInstaller/Main/tree/master/bucket/zoxide.json
|
[scoop]: https://github.com/ScoopInstaller/Main/tree/master/bucket/zoxide.json
|
||||||
[termux]: https://github.com/termux/termux-packages/tree/master/packages/zoxide
|
[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
|
[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-plugin-prerun-zoxide]: https://github.com/xxh/xxh-plugin-prerun-zoxide
|
||||||
[xxh]: https://github.com/xxh/xxh
|
[xxh]: https://github.com/xxh/xxh
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,8 @@ T}
|
||||||
Windows|\fI;\fR eg. $HOME;$HOME/private/*
|
Windows|\fI;\fR eg. $HOME;$HOME/private/*
|
||||||
.TE
|
.TE
|
||||||
.sp
|
.sp
|
||||||
After setting this up, you might need to use \fBzoxide-remove\fR(1) to remove
|
By default, this is set to \fI"$HOME"\fR. After setting this up, you might need
|
||||||
any existing entries from the database.
|
to use \fBzoxide-remove\fR(1) to remove any existing entries from the database.
|
||||||
.TP
|
.TP
|
||||||
.B _ZO_FZF_OPTS
|
.B _ZO_FZF_OPTS
|
||||||
Custom options to pass to fzf. See \fBman fzf\fR for the list of options.
|
Custom options to pass to fzf. See \fBman fzf\fR for the list of options.
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ use crate::db::Rank;
|
||||||
|
|
||||||
use anyhow::{bail, Context, Result};
|
use anyhow::{bail, Context, Result};
|
||||||
use dirs_next as dirs;
|
use dirs_next as dirs;
|
||||||
|
use glob::Pattern;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::ffi::OsString;
|
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") {
|
match env::var_os("_ZO_EXCLUDE_DIRS") {
|
||||||
Some(dirs_osstr) => env::split_paths(&dirs_osstr)
|
Some(dirs_osstr) => env::split_paths(&dirs_osstr)
|
||||||
.map(|path| {
|
.map(|path| {
|
||||||
let pattern = path
|
let pattern = path
|
||||||
.to_str()
|
.to_str()
|
||||||
.context("invalid unicode in _ZO_EXCLUDE_DIRS")?;
|
.context("invalid unicode in _ZO_EXCLUDE_DIRS")?;
|
||||||
glob::Pattern::new(&pattern)
|
Pattern::new(&pattern)
|
||||||
.with_context(|| format!("invalid glob in _ZO_EXCLUDE_DIRS: {}", pattern))
|
.with_context(|| format!("invalid glob in _ZO_EXCLUDE_DIRS: {}", pattern))
|
||||||
})
|
})
|
||||||
.collect(),
|
.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())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ impl Query {
|
||||||
I: IntoIterator<Item = S>,
|
I: IntoIterator<Item = S>,
|
||||||
S: AsRef<str>,
|
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 {
|
pub fn matches<S: AsRef<str>>(&self, path: S) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,10 @@ function __zoxide_cd() {
|
||||||
# Hook configuration for zoxide.
|
# 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.
|
# Hook to add new entries to the database.
|
||||||
{%- match hook %}
|
{%- match hook %}
|
||||||
{%- when Hook::None %}
|
{%- when Hook::None %}
|
||||||
|
|
@ -31,11 +35,14 @@ function __zoxide_cd() {
|
||||||
|
|
||||||
{%- when Hook::Prompt %}
|
{%- when Hook::Prompt %}
|
||||||
function __zoxide_hook() {
|
function __zoxide_hook() {
|
||||||
|
\builtin local -r __zoxide_retval="$?"
|
||||||
zoxide add -- "$(__zoxide_pwd)"
|
zoxide add -- "$(__zoxide_pwd)"
|
||||||
|
return "${__zoxide_retval}"
|
||||||
}
|
}
|
||||||
|
|
||||||
{%- when Hook::Pwd %}
|
{%- when Hook::Pwd %}
|
||||||
function __zoxide_hook() {
|
function __zoxide_hook() {
|
||||||
|
\builtin local -r __zoxide_retval="$?"
|
||||||
\builtin local -r __zoxide_pwd_tmp="$(__zoxide_pwd)"
|
\builtin local -r __zoxide_pwd_tmp="$(__zoxide_pwd)"
|
||||||
if [ -z "${__zoxide_pwd_old}" ]; then
|
if [ -z "${__zoxide_pwd_old}" ]; then
|
||||||
__zoxide_pwd_old="${__zoxide_pwd_tmp}"
|
__zoxide_pwd_old="${__zoxide_pwd_tmp}"
|
||||||
|
|
@ -43,10 +50,15 @@ function __zoxide_hook() {
|
||||||
__zoxide_pwd_old="${__zoxide_pwd_tmp}"
|
__zoxide_pwd_old="${__zoxide_pwd_tmp}"
|
||||||
zoxide add -- "${__zoxide_pwd_old}"
|
zoxide add -- "${__zoxide_pwd_old}"
|
||||||
fi
|
fi
|
||||||
|
return "${__zoxide_retval}"
|
||||||
}
|
}
|
||||||
|
|
||||||
{%- endmatch %}
|
{%- 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.
|
# Initialize hook.
|
||||||
if [ "${__zoxide_hooked}" != '1' ]; then
|
if [ "${__zoxide_hooked}" != '1' ]; then
|
||||||
__zoxide_hooked='1'
|
__zoxide_hooked='1'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue