CLI tools to quickly find recently opened files by fuzzy search?
Are there any CLI tools like zoxide that allow to quickly find recently opened files by fuzzy search instead of directories?
Are there any CLI tools like zoxide that allow to quickly find recently opened files by fuzzy search instead of directories?
eager_eagle,
fzf
+Ctrl+R
then I type part of the path, basename, or just my CLI editor and browse the recent commands.
Ordoviz, <span style="font-style:italic;color:#969896;">#!/bin/sh </span><span style="font-style:italic;color:#969896;"># Select a file with fzf from a database sorted by frecency and open it using </span><span style="font-style:italic;color:#969896;"># xdg-open. frece can be found at https://github.com/YodaEmbedding/frece </span><span style="color:#323232;"> </span><span style="color:#323232;">DB_FILE</span><span style="font-weight:bold;color:#a71d5d;">=</span><span style="color:#183691;">${</span><span style="color:#323232;">FRECE_FILES_DB</span><span style="font-weight:bold;color:#a71d5d;">:-</span><span style="color:#183691;">$</span><span style="color:#323232;">HOME</span><span style="color:#183691;">/.cache/frecent-files.csv} </span><span style="color:#323232;">item</span><span style="font-weight:bold;color:#a71d5d;">=</span><span style="color:#183691;">$(</span><span style="color:#323232;">frece</span><span style="color:#183691;"> print "$</span><span style="color:#323232;">DB_FILE</span><span style="color:#183691;">" </span><span style="font-weight:bold;color:#a71d5d;">| </span><span style="color:#323232;">fzf --tiebreak</span><span style="font-weight:bold;color:#a71d5d;">=</span><span style="color:#183691;">index</span><span style="color:#323232;"> --scheme</span><span style="font-weight:bold;color:#a71d5d;">=</span><span style="color:#183691;">path) </span><span style="color:#323232;"> </span><span style="color:#62a35c;">[ </span><span style="color:#323232;">-z </span><span style="color:#183691;">"$</span><span style="color:#323232;">item</span><span style="color:#183691;">" </span><span style="color:#62a35c;">] </span><span style="font-weight:bold;color:#a71d5d;">&</span><span style="color:#323232;">amp;</span><span style="font-weight:bold;color:#a71d5d;">&</span><span style="color:#323232;">amp</span><span style="font-weight:bold;color:#a71d5d;">; </span><span style="color:#62a35c;">exit</span><span style="color:#323232;"> 1 </span><span style="color:#323232;">frece increment </span><span style="color:#183691;">"$</span><span style="color:#323232;">DB_FILE</span><span style="color:#183691;">" "$</span><span style="color:#323232;">item</span><span style="color:#183691;">" </span><span style="color:#323232;"> </span><span style="color:#323232;">xdg-open </span><span style="color:#183691;">"$</span><span style="color:#323232;">item</span><span style="color:#183691;">" </span><span style="color:#323232;"> </span><span style="font-style:italic;color:#969896;">#!/bin/sh </span><span style="font-style:italic;color:#969896;"># Update frece database </span><span style="color:#323232;"> </span><span style="color:#323232;">DB_FILE</span><span style="font-weight:bold;color:#a71d5d;">=</span><span style="color:#183691;">${</span><span style="color:#323232;">FRECE_FILES_DB</span><span style="font-weight:bold;color:#a71d5d;">:-</span><span style="color:#183691;">$</span><span style="color:#323232;">HOME</span><span style="color:#183691;">/.cache/frecent-files.csv} </span><span style="color:#323232;">tmp_file</span><span style="font-weight:bold;color:#a71d5d;">=</span><span style="color:#183691;">$(</span><span style="color:#323232;">mktemp</span><span style="color:#183691;">) </span><span style="color:#323232;">fd -H . ~ </span><span style="font-weight:bold;color:#a71d5d;">> </span><span style="color:#183691;">"$</span><span style="color:#323232;">tmp_file</span><span style="color:#183691;">" </span><span style="font-style:italic;color:#969896;"># use ~/.fdignore file to exclude certain dirs </span><span style="color:#323232;">frece update </span><span style="color:#183691;">"$</span><span style="color:#323232;">DB_FILE</span><span style="color:#183691;">" "$</span><span style="color:#323232;">tmp_file</span><span style="color:#183691;">"</span><span style="color:#323232;"> --purge-old </span><span style="color:#323232;">rm </span><span style="color:#183691;">"$</span><span style="color:#323232;">tmp_file</span><span style="color:#183691;">" </span><span style="color:#323232;"> </span>
corytheboyd, (edited ) fzf? https://github.com/junegunn/fzf
Out of the box, would only help searching shell commands that have been run, so for files, things like “vim file.txt”, which is obviously not usually how files are edited (you’d use the file browser in a text editor or IDE)
However if you find a way to list all files on your system by modified time, you can pipe it to fzf for a slick fuzzy find search.
Maybe ag would work here too: https://github.com/ggreer/the_silver_searcher
astraeus, (edited ) I can’t tell you the number of times I have in fact edited files using vim even with a WM and DE. I just treat my laptop like it’s a server I connect directly to now
Oh, or even better how many times I used the terminal in VSC to vim edit something 😂
this_is_router, things like “vim file.txt”, which is obviously not usually how files are edited
You what mate? Don’t assume my workflow. “vi file.txt” is obviously superior to clicking inside some texteditor or file browser
PumpkinDrama, (edited ) Related idea:
To manage temporary files in Linux, a Bash script can move files untouched for 10 days to a timestamped subfolder, return modified files to the root, and delete files not modified for 90 days. Alternatively, a folder with symlinks to recently accessed files can be created using
mkdir
,find
with-atime -7
to locate recently accessed files, and awhile
loop withln -s
to symlink each file into the folder. Both approaches help organize files based on access time to avoid clutter and remove stale temporary files. The Bash script offers more automation while the symlink folder provides a manual way to access recent files.
Add comment