My personal tools
Introduction
This repository contains a collection of personal tools I've developed to address various needs and frustrations I've encountered in my workflow. Many of these tools make some questionable decisions, such as embedding configuration files, as they were initially created for my personal use.
Table of Contents
File Management Tools
cln
Create symbolic links given a custom set of commands
Mainly created out of frustration of windows ""symbolic"" links
This tool creates real symbolic links on any platform following the syntax of:
source,destination,force?
It respects existing files (be them real files or symbolic links)
Unless force is set to t in which case only existing symbolic links are deleted (overwriten)
Real files will never be deleted by this tool
The commands can be given by:
- stdin
- a file
- command line arguments
- a directory
Example:
- stdin
echo "this,that" | cln
- command line arguments
sync this,that foo,bar "path containing spaces",baz
- files
cln -f <file>
- directory
cln -r <directory>
- This mode looks for "sync" files recursively within the given directory and executes commands in those sync files
Given its ability to read files for commands it can be used to manage a "standard" set of symbolic links
fiter
Iterate over files and rename them incrementally Example: Given
video1.mp4
video2.mp4
video3.mp4
image1.png
image2.png
executable.exe
Running fiter *
would result in:
00001.mp4
00002.mp4
00003.mp4
00005.png
00006.png
00007.exe
The order is not guaranteed
Running fiter *.mp4
on the same folder would give:
00001.mp4
00002.mp4
00003.mp4
image1.png
image2.png
executable.exe
The tool will not delete any files by overwriting existing ones
And thanks to that it will fail when running on files that have already been renamed by it
For such scenarios use fiter -f <glob>
-f renames all files to <file>.bak before renaming them back to their new iterative name
This means that it can run on files that already have iterative names because none are being overwriten
It also means that, on failure, files are left as .bak
fmoditer
Iterate over files and rename them to their mod time
Works pretty much the same way as iter with the exception of -f which is not supported by fmoditer
Example: Given
video1.mp4
video2.mp4
video3.mp4
Running fmoditer *.mp4
would result in
2024-12-15T15-31-53.mp4
2022-03-06T12-55-00.mp4
2023-05-22T17-11-06.mp4
Git and Repository Tools
git-vc
Monitors a directory and commits any changes to git on a set interval Meant to run as a service
Configuration is done through environmental variables:
- ROOT
- Defaults to /tmp
- SCAN_INTERVAL
- Defaults to 1m
Runs
git add .
> git commit -m "Update"
every SCAN_INTERVAL on ROOT
It also sets its identity to system system@localhost
The purpose of this tool is to make sure you never lose any data in a volatile directory
For example given a directory where it's possible for files to spontaneously combust
This tool will ensure they're never really lost thanks to git
repo
Creates repositories on gitea and assigns them as "origin" on the git repository in working directory
The configuration of this tool is done through environmental variables:
GITEA_USER=dave
GITEA_PASSWORD=supersecret
GITA_URL=https://git.site.quack-lab.dev/
Fine grained configuration is applied through flags:
Usage of repo.exe:
-f Force assignment of the remote (deletes existing origin)
-n string
Name of the repository (shorthand)
-name string
Name of the repository
-ni
Do not add remote to the new repo (shorthand)
-noinit
Do not add remote to the new repo
-p Make the repository private (shorthand)
-private
Make the repository private
-r string
Name of the remote to create for the new repository (shorthand) (default "origin")
-remote string
Name of the remote to create for the new repository (default "origin")
System Utilities
vsclean
"clean" vscode recent projects by deleting non existing entries and adding new folders
Reads given directories and adds all folders in directories to vscode's recent projects
The idea is that all projects in a "projects" folder should be accessible to vscode
Doing this manually requires opening every folder one by one
It also removes non existent entries from recent projects and recent files
This tool supports no configuration outside of constants applied at compile time
lazygit-cleaner
Practically the same as vsclean but for lazygit
Removes non existing entries from state.yml and adds any existing git repositories in projects
This tool supports no configuration outside of constants applied at compile time
autoruns
Runs programs specified in autoruns.json (at compile time)
This tool is meant to replace windows autoruns and is meant to be magnitudes faster than windows autoruns
note: autoruns is specifically embedded as to not have to drag autoruns.json across multiple directories
It also supports automatically hiding/closing windows and running only programs that are not already running
See sample autoruns.json in repository of the tool
Supported json fields are:
Entry struct {
Name string `json:"name"`
// ^ only used for logging
Path string `json:"path"`
// ^ path to the program being run
Disabled bool `json:"disabled"`
// ^ all entries are enabled by default other than the ones with "disabled": "true"
Procname string `json:"procname"`
// ^ used for detection to determine whether or not the entry has to be run
Procs []string `json:"procs"`
// ^ (optional) used for scanning for additional processes before executing actions, some programs start multiple processes as children of the main process and some start multiple processes independently
ProcsAction string `json:"procsaction"`
// ^ (optional) specifies the action to apply specifically and only to procs
Flags []string `json:"flags"`
// ^ (optional) command line arguments to pass to executable when starting
Workdir string `json:"workdir"`
// ^ (optional) workdir in which to start the program
Action string `json:"action"`
// ^ (optional) what to do with the program on startup (supported are hide/close/click)
ActionParams []string `json:"actionparams"`
// ^ (optional) parameters for actions, currently used only for click, see example in autoruns.json
ActionDelay int `json:"actiondelay"`
// ^ (optional) amount of time (in milliseconds) to wait before running action on program startup
}
This tool supports no configuration outside of constants applied at compile time (one of which is autoruns.json)
Directory Management Tools
directory-cleaner
Archives and deletes "old" files in a given directory Meant to run as a service - preferably in a docker container
Meant to clean up "temporary" directories where the host program does not do a good job of deleting old entries, for example the windows temp
Configuration is given through environmental variables:
- ROOT
- Defaults to /tmp
- The root directory to be watched
- ROOT_ARCHIVE
- Defaults to ROOT/archive
- Directory in which "old" entries are placed before deletion
- IGNORED_DIRECTORIES
- Directories to ignore when scanning
- SCAN_INTERVAL
- Defaults to 1m
- Interval between scans
- ARCHIVE_THRESHOLD
- Defaults to 1d
- Time threshold for a file to be considered "old" and put into archive (ROOT_ARCHIVE)
- DELETE_THRESHOLD
- Defaults to 12h
- Time threshold for a file to be deleted out of the archive
- This threshold should be applied in addition to ARCHIVE_THRESHOLD
- For example to specify a lifetime of 2 days for files you could do 1d 1d between archive and delete
- USE_MODTIME
- Defaults to false
- Use modtime instead of accesstime
The tool uses access time to determine age of files with the thinking that files that should be deleted are ones that are not used
It also supports using mod time instead
This is important because moving files from ROOT to ROOT_ARCHIVE after ARCHIVE_THRESHOLD resets their atime and mtime
...because they're accessed and modified
Therefore file time to live is actually ARCHIVE_THRESHOLD + DELETE_THRESHOLD
directory-deletor
Deletes given directories in a directory on a set interval
Very similar to directory-cleaner except that this tool straight out deletes given directories
It's meant to combat windows unrelenting spam of "3D Projects" in ~
Who even uses that folder? Why is it there? Why can't I delete it? Well, now you can
Part of the configuration is done through command line arguments:
-scan int
scan interval in seconds (default 60)
-wd string
working directory
And part through environmental variables:
- FORBIDDEN
- csv separated list of directories to delete
- Those whose existence is forbidden
- PATH_PREFIX
- A prefix prepended to work directory
- Why? I don't remember