From e59305162532284b94816a85c9fcac1ed0a0402e Mon Sep 17 00:00:00 2001 From: Alin Panaitiu Date: Sun, 8 Mar 2020 14:29:43 +0200 Subject: [PATCH] Add fish integration --- README.md | 13 +++++++++++++ functions/z.fish | 12 ++++++++++++ init.fish | 14 ++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 functions/z.fish create mode 100644 init.fish diff --git a/README.md b/README.md index 916d00a..e2c0ab8 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,13 @@ 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. @@ -78,6 +85,12 @@ alias zq="zoxide query" alias zr="zoxide remove" ``` +#### fish +Using [fisher](https://github.com/jorgebucaran/fisher): +```sh +fisher add ajeetdsouza/zoxide +``` + ## Configuration ### Environment variables diff --git a/functions/z.fish b/functions/z.fish new file mode 100644 index 0000000..542b5d1 --- /dev/null +++ b/functions/z.fish @@ -0,0 +1,12 @@ +function z + if test (count $argv) -gt 0 + set _Z_RESULT (zoxide query $argv) + switch "$_Z_RESULT" + case 'query: *' + cd (string sub -s 8 -- "$_Z_RESULT") + case '*' + echo "$_Z_RESULT" + end + commandline -f repaint + end +end diff --git a/init.fish b/init.fish new file mode 100644 index 0000000..1350a64 --- /dev/null +++ b/init.fish @@ -0,0 +1,14 @@ +function zoxide-add --on-event fish_prompt + if command -q zoxide + zoxide add + 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