jethrokuan / z

Pure-fish z directory jumping
MIT License
1.26k stars 44 forks source link

Support using fzf to pick a previous directory via keybinding #95

Open xster opened 3 years ago

xster commented 3 years ago

Similar to alt-k in https://github.com/gokulsoumya/f#keybindings

mk12 commented 2 years ago

I implemented this in my own fish config:

function z --description "Jump around"
    set -g prev_z_argv $argv
    __z $argv
end

function zi --description "Like z, but choose with fzf"
    if test (count $argv) -ge 1
        set -g prev_z_argv $argv
    end
    if not set result (__z $prev_z_argv -l 2> /dev/null | fzf)
        return
    end
    cd (echo $result | sed -E 's/^[0-9.]+[ \t]+//')
end