mirror of
https://github.com/Llewellynvdm/zoxide.git
synced 2025-01-29 01:58:33 +00:00
Make fish completions consistent with Bash
This commit is contained in:
parent
2a2848f55c
commit
72fd48ed97
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- fzf: better default options.
|
- fzf: better default options.
|
||||||
|
- fish: interactive completions are only triggered when the last argument is empty.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::io::{self, Read};
|
use std::io::{self, Read};
|
||||||
|
use std::mem;
|
||||||
use std::process::{Child, ChildStdin, Command, Stdio};
|
use std::process::{Child, ChildStdin, Command, Stdio};
|
||||||
|
|
||||||
use anyhow::{bail, Context, Result};
|
use anyhow::{bail, Context, Result};
|
||||||
@ -50,8 +51,11 @@ impl Fzf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn select(mut self) -> Result<String> {
|
pub fn select(mut self) -> Result<String> {
|
||||||
|
// Drop stdin to prevent deadlock.
|
||||||
|
mem::drop(self.child.stdin.take());
|
||||||
|
|
||||||
|
let mut stdout = self.child.stdout.take().unwrap();
|
||||||
let mut output = String::new();
|
let mut output = String::new();
|
||||||
let stdout = self.child.stdout.as_mut().unwrap();
|
|
||||||
stdout.read_to_string(&mut output).context("failed to read from fzf")?;
|
stdout.read_to_string(&mut output).context("failed to read from fzf")?;
|
||||||
|
|
||||||
let status = self.child.wait().context("wait failed on fzf")?;
|
let status = self.child.wait().context("wait failed on fzf")?;
|
||||||
|
@ -78,10 +78,10 @@ function __zoxide_z_complete
|
|||||||
set -l curr_tokens (commandline -cop)
|
set -l curr_tokens (commandline -cop)
|
||||||
|
|
||||||
if test (count $tokens) -le 2 -a (count $curr_tokens) -eq 1
|
if test (count $tokens) -le 2 -a (count $curr_tokens) -eq 1
|
||||||
# If there is only one argument, use `cd` completions.
|
# If there are < 2 arguments, use `cd` completions.
|
||||||
__fish_complete_directories "$tokens[2]" ''
|
__fish_complete_directories "$tokens[2]" ''
|
||||||
else
|
else if test (count $tokens) -eq (count $curr_tokens)
|
||||||
# Otherwise, use interactive selection.
|
# If the last argument is empty, use interactive selection.
|
||||||
set -l query $tokens[2..-1]
|
set -l query $tokens[2..-1]
|
||||||
set -l result (zoxide query -i -- $query)
|
set -l result (zoxide query -i -- $query)
|
||||||
and commandline -p "$tokens[1] "(string escape $result)
|
and commandline -p "$tokens[1] "(string escape $result)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user