.Dd October 28, 2023 .Dt CMD_CACHIER 1 .Os .Sh NAME .Nm cmd_cachier .Nd A caching service for your cli commands using redis. .Sh SYNOPSIS .Nm cmd_cachier .Ar SUBCOMMAND .Op YOUR_COMMAND .Nm cmd_cachier .Ar YOUR_COMMAND... .Sh PREREQUESITES A redis server must be runnigng on the local machine. On MacOS with homebrew. .Pp Start the daemon and enable on boot on ... .Pp .Nm MacOS(homebrew) .Pp When redis is installed (via homebrew) run: .Dl $ brew service start redis .Pp .Nm Linux(systemd) .Pp When redis is installed run: .Dl $ systemctl enable redis .Dl $ systemctl start redis .Pp .Pp For security reasons if you are only going to use redis for local purposes. Like: Development, cmd_cachier etc.. Then you should edit your .Nm redis.conf And uncomment the following line (MacOS: /opt/homebrew/etc/redis.conf, Linux: /etc/redis/redis.conf) : .Pp From: .Dl # bind 127.0.0.1 ::1 # listens on loopback IPv4 and IPv6 To: .Dl bind 127.0.0.1 ::1 # listens on loopback IPv4 and IPv6 .Pp .Sh DESCRIPTION .Ar TODO: Add description .Pp The db state is preserved throughout a desktop session as redis is a in memory database. To keep commands refreshed you can manually execute your command with the .Nm save subcommand. Or you could refresh it programatically via systemd timers or crontab (man crontab). .Nm crontab .Pp Run: .Dl $ crontab -e .Pp Add the line for an update every minute: .Pp .Dl * * * * * cmd_cache save YOUR_COMMAND .Pp Or every 5 minutes: .Pp .Dl */5 * * * * cmd_cache save YOUR_COMMAND .Pp TODO: systemd timer documentation .Pp If no operands are given, ... directory are displayed. If a subcommand is givenn, ... If only your command is given, ... .Sh SUBCOMMANDS The following subcommands are available: .Bl -tag -width indent .It Nm save Ar YOUR_COMMAND... Save command to database in any case. Will overwrite if already in db. .It Nm query Ar YOUR_COMMAND... Try to query database. Returns empty string if not in db. .It Nm memory Display memory usage of saved commands. .It Nm info Info about redis database. .Sh EXAMPLES Cache list of files in $HOME .Pp .Dl $ cmd_cachier ls -1 "$HOME" .Pp Cache list of git projects .Pp .Dl $ cmd_cachier fd --glob .git --hidden --type d --max-depth 6 --prune .Pp Additionally remove the .git folders from the path: .Pp .Dl $ cmd_cachier fd --glob .git --hidden --type d --max-depth 6 --prune | while read -r line;do tmp="${line%/}";echo "${tmp%/*}";done .Pp With fzf: .Pp .Dl $ cmd_cachier fd . --type d --max-depth 5 --hidden "$HOME" | fzf .Pp .Sh TIPS AND TRICKS Alias gp to cd into a selected git project in the example above. In your .bashrc: .Pp .Dl alias gp='cd "$(cmd_cachier YOUR_SEARCH_COMMAND | fzf)"' .Pp Enforce refresh of the search on demand (alias with gpup): .Pp .Dl alias gpup='cd "$(cmd_cachier save YOUR_SEARCH_COMMAND | fzf)"' .Pp .Sh BUGS .Pp Every now and then a dump.rdb is created in the current directory. .Pp \".Sh COMPATIBILITY \".Sh STANDARDS \".Sh ENVIRONMENT