LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxQuestions.org Member Success Stories (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/)
-   -   Directory Bookmarker (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/directory-bookmarker-4175726981/)

dugan 07-15-2023 02:06 PM

Directory Bookmarker
 
After over a decade of looking at directory changers and bookmarkers (zoxide, fasd, autojump, etc), I decided to just write one.

It's for FISH, because that's what I use, and it uses FZF.

You just write out your list of directory "bookmarks" in ~/.sdirs. For example:

Code:

~/Videos
~/Downloads

The following then goes in ~/.config/fish/functions/j.fish:

Code:

function j
    if count $argv > /dev/null
        if set --local result (command cat ~/.sdirs | command fzf --select-1 --exit-0 --query $argv)
            cd (echo "echo $result" | sh)
        end
    else
        if set --local result (command cat ~/.sdirs | command fzf --select-1 --exit-0)
            cd (echo "echo $result" | sh)
        end
    end
end


Then you just enter "j" for a menu, or, "j D" to jump to ~/Downloads.

These are what I looked at to get it done:

https://github.com/mgunyho/tere
https://stackoverflow.com/questions/...-tilde-in-bash
https://www.reddit.com/r/commandline..._exactly_what/
https://github.com/huyng/bashmarks
https://stackoverflow.com/a/29643375

If you'd rather have it for BASH or Zsh, well, that's left as an exercise for the reader.

My previous attempt:

https://gist.github.com/duganchen/40...f2957aa1764dca


All times are GMT -5. The time now is 01:31 AM.