file-opener
file-opener
Searches specific directories for a file with a matching filename and opens it with the default application for the selected file type
How to use it
To use this you need to have the xdg-open
command installed.
The easiest method would be to set up an alias inside your .bashrc
file like so
alias opener='crystal run --release "DIRECTORY/WITH/YOUR/FILE/find.cr" --'
and then search by writing opener \find.cr
or opener -l \find.cr
the slash is necessary because otherwise linux might not pass this argument as a raw string.
The optional -l
argument specifies if the script should search in the current working directory (this would be with -l
) or in the directories hardcoded inside find.cr
.
Other Details
- The directories need to be seperated with
/
while the escaping char needs to be\
. - The directories inside
find.cr
are in a hierarchical order so the script will not search other directories if it finds a matching file inside the first one. - If multiple matching files are found inside one directory it will print all of them.
- If you notice a bug after searching with an argument such as
opener \src/main.rs
change it toopener \*src/main.rs
and it should work. This is caused by the weird implementation of glob inside crystal std.
file-opener
- 1
- 0
- 0
- 0
- 0
- over 3 years ago
- August 6, 2021
Thu, 07 Nov 2024 15:44:47 GMT