Skip to content

Commit

Permalink
zoxide-{add,remove} should accept multiple arguments (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajeetdsouza committed Jul 29, 2021
1 parent 712d340 commit 238fa57
Show file tree
Hide file tree
Showing 16 changed files with 135 additions and 108 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- markdownlint-disable MD024 -->

# Changelog

All notable changes to this project will be documented in this file.
Expand All @@ -7,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

- `zoxide add` and `zoxide remove` now accept multiple arguments.

### Fixed

- Nushell: errors on 0.33.0.
Expand Down
70 changes: 44 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ categories = ["command-line-utilities", "filesystem"]

[dependencies]
anyhow = "1.0.32"
askama = { version="0.10.3", default-features=false }
askama = { version = "0.10.3", default-features = false }
bincode = "1.3.1"
clap = "3.0.0-beta.2"
dirs-next = "2.0.0"
dunce = "1.0.1"
glob = "0.3.0"
ordered-float = "2.0.0"
serde = { version="1.0.116", features=["derive"] }
serde = { version = "1.0.116", features = ["derive"] }
tempfile = "3.1.0"

[target.'cfg(windows)'.dependencies]
rand = { version="0.8.4", features=["getrandom", "small_rng"], default-features=false }
rand = { version = "0.8.4", features = [
"getrandom",
"small_rng",
], default-features = false }

[dev-dependencies]
assert_cmd = "1.0.1"
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ Read more about the matching algorithm [here][algorithm-matching].

## Getting started

### Step 1: Install `zoxide`
### *Step 1: Install `zoxide`*

`zoxide` supports most major platforms. If your platform isn't listed below,
`zoxide` runs on most major platforms. If your platform isn't listed below,
please [open an issue][issues].

<details>
Expand Down Expand Up @@ -131,12 +131,12 @@ To install `zoxide`, use a package manager:

</details>

### Step 2: Install `fzf` (optional)
### *Step 2: Install `fzf` (optional)*

[`fzf`][fzf] is a command-line fuzzy finder, used by `zoxide` for interactive
selection ([installation instructions][fzf-installation]).
selection. It can be installed from [here][fzf-installation].

### Step 3: Add `zoxide` to your shell
### *Step 3: Import your data (optional)*

If you currently use any of the following utilities, you may want to import
your data into `zoxide`:
Expand All @@ -159,7 +159,9 @@ zoxide import --from z path/to/db

</details>

Now, initialize `zoxide` on your shell:
### *Step 4: Add `zoxide` to your shell*

To start using `zoxide`, add it to your shell.

<details>
<summary><code>bash</code></summary>
Expand Down Expand Up @@ -195,7 +197,7 @@ zoxide init fish | source
</details>

<details>
<summary><code>nushell 0.32+</code></summary>
<summary><code>nushell v0.32+</code></summary>

Initialize the `zoxide` script:

Expand All @@ -217,7 +219,7 @@ You can replace `__zoxide_prompt` with a custom prompt.
<details>
<summary><code>powershell</code></summary>

Add this to your configuration (the location is stored in `$profile`):
Add this to your configuration (find it with `echo $profile`):

```powershell
Invoke-Expression (& {
Expand Down Expand Up @@ -251,7 +253,7 @@ eval "$(zoxide init zsh)"
</details>

<details>
<summary>Any POSIX shell</summary>
<summary>any POSIX shell</summary>

Add this to your configuration:

Expand Down
4 changes: 2 additions & 2 deletions contrib/completions/_zoxide
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ _zoxide() {
_arguments "${_arguments_options[@]}" \
'-h[Prints help information]' \
'--help[Prints help information]' \
':path:_files -/' \
'*::paths:_files -/' \
&& ret=0
;;
(import)
Expand Down Expand Up @@ -75,7 +75,7 @@ _arguments "${_arguments_options[@]}" \
'()*--interactive=[]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'::path:_files -/' \
'*::paths:_files -/' \
&& ret=0
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions contrib/completions/zoxide.bash
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ _zoxide() {
;;

zoxide__add)
opts=" -h --help <path> "
opts=" -h --help <paths>... "
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down Expand Up @@ -127,7 +127,7 @@ _zoxide() {
return 0
;;
zoxide__remove)
opts=" -i -h --interactive --help <path> "
opts=" -i -h --interactive --help <paths>... "
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down
2 changes: 1 addition & 1 deletion man/zoxide-add.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.SH NAME
zoxide-add - add a new directory or increment its rank
.SH SYNOPSIS
.B zoxide add \fIPATH\fR
.B zoxide add \fI[PATHS]\fR
.SH DESCRIPTION
If the directory is not already in the database, this command creates a new
entry for it with a default score of \fI1\fR, otherwise, it increments the
Expand Down
4 changes: 2 additions & 2 deletions man/zoxide-init.1
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Add this to your configuration (usually \fI~/.config/nu/config.toml\fR):
You can replace \fB__zoxide_prompt\fR with a custom prompt.
.TP
.B powershell
Add this to your configuration (the location is stored in \fI$profile\fR):
Add this to your configuration (find it with \fIecho $profile\fR):
.sp
.nf
\fBInvoke-Expression (& {
Expand All @@ -67,7 +67,7 @@ Add this to your configuration (usually \fI~/.zshrc\fR):
\fBeval "$(zoxide init zsh)"\fR
.fi
.TP
.B Any POSIX shell
.B any POSIX shell
.sp
Add this to your configuration:
.sp
Expand Down
2 changes: 1 addition & 1 deletion man/zoxide-remove.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.SH NAME
zoxide-remove - remove a directory from the database
.SH SYNOPSIS
.B zoxide remove \fIPATH [OPTIONS]\fR
.B zoxide remove \fI[PATHS] [OPTIONS]\fR
.SH DESCRIPTION
If you'd like to permanently exclude a directory from the database, see the
\fB_ZO_EXCLUDE_DIRS\fR environment variable in \fBzoxide\fR(1).
Expand Down
8 changes: 4 additions & 4 deletions src/app/_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ pub enum App {
/// Add a new directory or increment its rank
#[derive(Clap, Debug)]
pub struct Add {
#[clap(value_hint = ValueHint::DirPath)]
pub path: PathBuf,
#[clap(min_values = 1, required = true, value_hint = ValueHint::DirPath)]
pub paths: Vec<PathBuf>,
}

/// Import entries from another application
Expand Down Expand Up @@ -126,12 +126,12 @@ pub struct Query {
#[derive(Clap, Debug)]
pub struct Remove {
// Use interactive selection
#[clap(conflicts_with = "path", long, short, value_name = "keywords")]
#[clap(conflicts_with = "paths", long, short, value_name = "keywords")]
pub interactive: Option<Vec<String>>,
#[clap(
conflicts_with = "interactive",
required_unless_present = "interactive",
value_hint = ValueHint::DirPath
)]
pub path: Option<String>,
pub paths: Vec<String>,
}
Loading

0 comments on commit 238fa57

Please sign in to comment.