Last active
August 23, 2023 11:52
-
-
Save sebastiancarlos/df1e2fcfbed1c467a4984badbc6b67af to your computer and use it in GitHub Desktop.
locate is great, but you can make it faster with a custom updatedb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All my gist code is licensed under the terms of the MIT license. | |
# Video demo: https://www.youtube.com/watch?v=KFtZbsSG_fA | |
# add this to your ~/.bashrc or something like that | |
# alias for every locate database | |
alias locate="glocate --regextype=posix-extended --database=${HOME}/tmp/locatedb-min" | |
alias locatehome="glocate --regextype=posix-extended --database=${HOME}/tmp/locatedb-home" | |
alias locateall="glocate --regextype=posix-extended --database=${HOME}/tmp/locatedb" | |
alias loc="locate" | |
alias loch="locatehome" | |
alias loca="locateall" | |
# custom updatedb | |
# - create: | |
# - locatedb (all files) | |
# - locatedb-home (home directory) | |
# - locatedb-min (home directory, but excluding hidden files and notoriously | |
# huge and useless folders) | |
# - TODO: Move this to a cron job | |
# - Note: For the regex in --prunepaths to work, manually change the source for | |
# GNU updatedb as described here: | |
# https://savannah.gnu.org/bugs/?19374#comment5 | |
function updatedb () { | |
echo "generating locatedb..." | |
sudo updatedb --output=${HOME}/tmp/locatedb --prunepaths='/Volumes /System' | |
echo "generating locatedb-home..." | |
sudo updatedb --output=${HOME}/tmp/locatedb-home --localpaths="${HOME}" | |
echo "generating locatedb-min..." | |
sudo updatedb --output=${HOME}/tmp/locatedb-min --localpaths="${HOME}" --prunepaths="${HOME}/Library .*/\..*" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment