With fasd, you can not only jump to any folders once arrived (like what autojump do), but also open any files once opened.
Like what "Recent files" and "Recent folders" in Desktop Environment do, but in terminal.
Install and setup:
- Install fasd with
sudo apt install fasd
- Add
fasd
inplugins=(...)
in ~/zshrc - Add
alias o='fasd -a -e rifle'
~/.bash_aliases
The default definition of o
is alias o='fasd -a -e xdg-open'
.
By changing it to rifle
, you can define associated applications of
different file types in ranger's configuration (~/.config/ranger/rifle.conf),
which is more portable than customizing associations defined in xdg-open.
Now fasd will remember every file you open (with rifle
or other command line application)
and every directory, which can be listed with a
(alas of fasd -a
).
Open a PDF file in any folder with o stat
after running
rf 'An Introduction to Statistical Learning-Trevor Hastie Robert Tibshirani(2015).pdf'
in folder ~/Documents/Books.
Here stat
is a pattern in the opened file name,
therefore remembered and matched by fasd, like fuzzy search with fzf.
Note: the aliases is defined in ~/.oh-my-zsh/plugins/fasd/fasd.plugin.zsh. You can update it directly.