Changes based on PR review

This commit is contained in:
Alin Panaitiu 2020-03-08 18:15:06 +02:00
parent e593051625
commit 5a2cbe0147
No known key found for this signature in database
GPG Key ID: E3629673D6E15976
3 changed files with 34 additions and 20 deletions

View File

@ -4,13 +4,6 @@
A cd command that learns your habits
## Table of contents
- [Installing `zoxide`](#installing-zoxide)
- [Adding `zoxide` to your shell](#adding-zoxide-to-your-shell)
+ [zsh](#zsh)
+ [fish](#fish)
## Introduction
`zoxide` is a new `cd` alternative inspired by [`z`](https://github.com/rupa/z) and [`z.lua`](https://github.com/skywind3000/z.lua). It keeps track of the directories you use most frequently, and uses a ranking algorithm to navigate to the best match.
@ -91,6 +84,20 @@ Using [fisher](https://github.com/jorgebucaran/fisher):
fisher add ajeetdsouza/zoxide
```
Using [omf](https://github.com/oh-my-fish/oh-my-fish):
```sh
omf install https://github.com/ajeetdsouza/zoxide
```
To enable key bindings you have to set the universal variable `ZOXIDE_KEY_BINDINGS` to 1 and restart the shell.
```fish
set -U ZOXIDE_KEY_BINDINGS 1
```
| Keybinding | Action |
| ---------- | -------------------------------------------------------------------------------- |
| <kbd>Alt</kbd>+<kbd>z</kbd> / <kbd></kbd>+<kbd>z</kbd> | Launch Zoxide in interactive mode |
## Configuration
### Environment variables

View File

@ -4,9 +4,12 @@ function z
switch "$_Z_RESULT"
case 'query: *'
cd (string sub -s 8 -- "$_Z_RESULT")
commandline -f repaint
case '*'
echo "$_Z_RESULT"
if test -n "$_Z_RESULT"
echo "$_Z_RESULT"
end
end
commandline -f repaint
end
end

View File

@ -1,14 +1,18 @@
function zoxide-add --on-event fish_prompt
if command -q zoxide
zoxide add
zoxide add
end
set -q ZOXIDE_KEY_BINDINGS
or set -U ZOXIDE_KEY_BINDINGS 0
abbr -a zi "z -i"
abbr -a za "zoxide add"
abbr -a zq "zoxide query"
abbr -a zr "zoxide remove"
if set -q ZOXIDE_KEY_BINDINGS; and test "$ZOXIDE_KEY_BINDINGS" -eq 1
bind \ez 'z -i'
if bind -M insert >/dev/null 2>/dev/null
bind -M insert \ez 'z -i'
end
end
if command -q zoxide
abbr -a zi "z -i"
abbr -a za "zoxide add"
abbr -a zq "zoxide query"
abbr -a zr "zoxide remove"
bind \ez 'z -i'
end