Skip to content

Commit

Permalink
Fix cd - on fish (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajeetdsouza authored Apr 12, 2021
1 parent 5882bc6 commit acc9059
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed

- `cd -` on fish shells.

## [0.6.0] - 2021-04-09

### Added
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ frequently, and uses a ranking algorithm to navigate to the best match.
## Examples

```sh
z foo # cd into highest ranked directory matching foo
z foo bar # cd into highest ranked directory matching foo and bar
z foo # cd into highest ranked directory matching foo
z foo bar # cd into highest ranked directory matching foo and bar

z ~/foo # z also works like a regular cd command
z foo/ # cd into relative path
z .. # cd one level up
z - # cd into previous directory
z ~/foo # z also works like a regular cd command
z foo/ # cd into relative path
z .. # cd one level up
z - # cd into previous directory

zi foo # cd with interactive selection (using fzf)
zi foo # cd with interactive selection (using fzf)
```

Read more about the matching algorithm [here][algorithm-matching].
Expand Down Expand Up @@ -174,7 +174,8 @@ eval "$(zoxide init zsh)"

#### Any POSIX shell

Add the following line to your configuration file:
Add the following line to your configuration file (usually
`~/.config/nu/config.toml`):

```sh
eval "$(zoxide init posix --hook prompt)"
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use once_cell::sync::OnceCell;

use std::io::{self, Write};

/// Generates shell configuration
/// Generate shell configuration
#[derive(Clap, Debug)]
#[clap(after_help(env_help()))]
pub struct Init {
Expand Down
8 changes: 7 additions & 1 deletion src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ pub trait Cmd {
}

#[derive(Debug, Clap)]
#[clap(about, author, global_setting(AppSettings::GlobalVersion), global_setting(AppSettings::VersionlessSubcommands), version = env!("ZOXIDE_VERSION"))]
#[clap(
about,
author,
global_setting(AppSettings::DisableHelpSubcommand),
global_setting(AppSettings::GlobalVersion),
global_setting(AppSettings::VersionlessSubcommands),
version = env!("ZOXIDE_VERSION"))]
pub enum App {
Add(Add),
Import(Import),
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use clap::Clap;

use std::io::{self, Write};

/// Searches for a directory
/// Search for a directory in the database
#[derive(Clap, Debug)]
pub struct Query {
keywords: Vec<String>,
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use clap::Clap;

use std::io::Write;

/// Removes a directory
/// Remove a directory from the database
#[derive(Clap, Debug)]
pub struct Remove {
#[clap(conflicts_with = "path", long, short, value_name = "keywords")]
Expand Down
9 changes: 5 additions & 4 deletions templates/fish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ end

# cd + custom logic based on the value of _ZO_ECHO.
function __zoxide_cd
builtin cd $argv
{#- We can't use `builtin cd` over here, because fish wraps its builtin cd with
a function that adds extra features (such as `cd -`). Using the builtin
would make those features stop working. #}
cd $argv
{%- if echo %}
and __zoxide_pwd
{%- endif %}
Expand Down Expand Up @@ -52,9 +55,7 @@ function __zoxide_z
set argc (count $argv)
if test $argc -eq 0
__zoxide_cd $HOME
else if begin
test $argc -eq 1; and test $argv[1] = -
end
else if test "$argv" = -
__zoxide_cd -
else if begin
test $argc -eq 1; and test -d $argv[1]
Expand Down

0 comments on commit acc9059

Please sign in to comment.