Fix cd - on fish (#179)

This commit is contained in:
Ajeet D'Souza 2021-04-13 01:57:36 +05:30 committed by GitHub
parent 5882bc6c4d
commit acc9059177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 16 deletions

View File

@ -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/), 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). 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 ## [0.6.0] - 2021-04-09
### Added ### Added

View File

@ -13,15 +13,15 @@ frequently, and uses a ranking algorithm to navigate to the best match.
## Examples ## Examples
```sh ```sh
z foo # cd into highest ranked directory matching foo z foo # cd into highest ranked directory matching foo
z foo bar # cd into highest ranked directory matching foo and bar z foo bar # cd into highest ranked directory matching foo and bar
z ~/foo # z also works like a regular cd command z ~/foo # z also works like a regular cd command
z foo/ # cd into relative path z foo/ # cd into relative path
z .. # cd one level up z .. # cd one level up
z - # cd into previous directory 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]. Read more about the matching algorithm [here][algorithm-matching].
@ -174,7 +174,8 @@ eval "$(zoxide init zsh)"
#### Any POSIX shell #### 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 ```sh
eval "$(zoxide init posix --hook prompt)" eval "$(zoxide init posix --hook prompt)"

View File

@ -10,7 +10,7 @@ use once_cell::sync::OnceCell;
use std::io::{self, Write}; use std::io::{self, Write};
/// Generates shell configuration /// Generate shell configuration
#[derive(Clap, Debug)] #[derive(Clap, Debug)]
#[clap(after_help(env_help()))] #[clap(after_help(env_help()))]
pub struct Init { pub struct Init {

View File

@ -18,7 +18,13 @@ pub trait Cmd {
} }
#[derive(Debug, Clap)] #[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 { pub enum App {
Add(Add), Add(Add),
Import(Import), Import(Import),

View File

@ -10,7 +10,7 @@ use clap::Clap;
use std::io::{self, Write}; use std::io::{self, Write};
/// Searches for a directory /// Search for a directory in the database
#[derive(Clap, Debug)] #[derive(Clap, Debug)]
pub struct Query { pub struct Query {
keywords: Vec<String>, keywords: Vec<String>,

View File

@ -10,7 +10,7 @@ use clap::Clap;
use std::io::Write; use std::io::Write;
/// Removes a directory /// Remove a directory from the database
#[derive(Clap, Debug)] #[derive(Clap, Debug)]
pub struct Remove { pub struct Remove {
#[clap(conflicts_with = "path", long, short, value_name = "keywords")] #[clap(conflicts_with = "path", long, short, value_name = "keywords")]

View File

@ -16,7 +16,10 @@ end
# cd + custom logic based on the value of _ZO_ECHO. # cd + custom logic based on the value of _ZO_ECHO.
function __zoxide_cd 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 %} {%- if echo %}
and __zoxide_pwd and __zoxide_pwd
{%- endif %} {%- endif %}
@ -52,9 +55,7 @@ function __zoxide_z
set argc (count $argv) set argc (count $argv)
if test $argc -eq 0 if test $argc -eq 0
__zoxide_cd $HOME __zoxide_cd $HOME
else if begin else if test "$argv" = -
test $argc -eq 1; and test $argv[1] = -
end
__zoxide_cd - __zoxide_cd -
else if begin else if begin
test $argc -eq 1; and test -d $argv[1] test $argc -eq 1; and test -d $argv[1]