descriptionMy ~/bin/ directory, with useful scripts I use all the time.
ownersunny@sunbase.org
last changeSun, 17 Nov 2024 01:52:51 +0000 (17 02:52 +0100)
content tags
add:
README.md

README for utils.git

Pipeline status

This is a collection of scripts I've had in my ~/bin/ directory since the previous century. Some of them are quite specific for my own use, but many of them have evolved into a mature state and could probably have their own repository as their own project. That will probably not happen, as most of the scripts consists of only one file.

The master branch is considered stable and will never be rebased. Every new functionality or bug fix is created on topic branches which may be rebased now and then. All tests on master (executed with "make test") should succeed. If any test fails, it’s considered a bug. Please report any failing tests in the issue tracker.

License

Everything here created by Øyvind A. Holm (<sunny@sunbase.org>) is licensed under the GNU General Public License version 2 or later.

Download

This repository can be cloned from

The repositories are synced with Gitspread.

Stable utilities

These scripts are stable and ready for public use.

Git extensions, check out first

git-dangling

Scan the current repository for dangling heads (dead branches where the branch names have been deleted) or tags and create branches with the format commit-SHA1 and tag-SHA1. This makes it easy to locate branches and tags that shouldn't have been deleted. No need to dig around in the reflog anymore. Needs git-delete-banned.

git-dbr

Delete remote and local branches specified on the command line, but can be used with the output from git log --format=%d or %D. A quick and easy way to clean up the branch tree with copy+paste.

git-rcmd

Execute commands in remote ssh repositories. For example, to make all connected ssh repos (if they have a local shell, of course) fetch all new commits from all remotes:

git-rcmd -c "git fetch --all --prune"

git-testadd

Execute a command with only the staged changes in Git applied.

If you have lots of unrelated uncommitted changes in the current repository and want to split up the commit, how can you easily check if the changes passes the test suite? With all the other unrelated changes it can be hard to make sure that only relevant changes becomes part of the commit, and that they don't result in regressions. This script clones the repository to the directory .testadd.tmp in the current directory and applies the staged chenges there (unless -u/--unmodified is specified), chdirs to the same relative directory in the clone and executes the command specified on the command line there.

If the command contains any options starting with -, add -- in front of the command so they won't be parsed by git-testadd, or surround it with quotes.

Examples
user@host:~/src/myproject/src/t $ git-testadd make test

The command will be executed in ~/src/myproject/src/t/.testadd.tmp/ with only the staged changes applied.

user@host:~/src/myproject/src/t $ git-testadd -- ./run-tests -v

This command contains a -v option. Disable option parsing of the command by prefixing it with --.

$ git-testadd "make && cd t && make 2>&1 | less || echo fail"

With quotes, even control operators and pipes can be used.

git-wip

Useful for working with topic branches. Create subbranches separated with a full stop in the branch name. It can create new subbranches, merge to parent branches or master with or without fast-forward and squash the whole branch to the parent branch or master.

Other stable Git extensions

git-allbr

Scan remotes for branches and recreate them in the local repository.

git-bare

Change the state of the current repository to/from a bare repository to/from a regular repository.

git-bs

Alias for git bisect, but allows execution from a subdirectory.

git-delete-banned

Delete unwanted commit-SHA1 branches and tag-SHA1 tags created by git-dangling. Some people like to keep old branches around after they've been squashed or rebased, but there are always some worthless branches around that only clutter the history. Those commits can be specified in ~/.git-dangling-banned, and this command will delete them.

git-delete-old-branches

Delete obsolete Git branches locally and from all remotes. For each branch, display a git diff --stat against all local and remote branches with this name, a simplified git log --graph, and finally a git log with patch against all branches. Display this in less(1), and ask if all branches with this name should be deleted.

The following responses are valid:

The answers can also be stored in an SQLite database to automate subsequent runs.

git-delrembr

Delete all remote and local branches specified on the command line.

git-ignore

Ignore files in Git. Automatically update .gitignore in the local directory (default) or add the file, directory or symlink to the .gitignore at the top of the repository. Directories will have a slash automatically added, and if the file/directory/symlink already exists in Git, it will be removed from the repository without touching the actual file.

git-logdiff

Show log differences between branches with optional patch.

git-mnff

Merge a topic branch without using fast-forward, always create a merge commit. This is used for collecting related changes together and makes things like git log --oneline --graph more readable. IMHO. After the branch is merged, it's deleted.

git-nocom

Filter output from git branch through this to remove commit-SHA1 branches.

git-pa

Push to all predefined remotes with a single command.

git-restore-dirs

Restore empty directories from the .emptydirs file created by git-store-dirs.

git-rpull

Shortcut for git rcmd -c "git pull --ff-only".

git-store-dirs

Store the names of all empty directories in a file called .emptydirs at the top of the repository. The names are zerobyte-separated to work with all kinds of weird characters in the directory names. Use git-restore-dirs to recreate the directories.

git-wait-until-clean

If there are any modifications or unknown files in the current repository, wait until it's been cleaned up. Useful in scripts where the following commands need a clean repository. Can also ignore unknown files or check for the existence of ignored files.

Various

ampm

Read text from stdin or files and convert from am/pm to 24-hour clock.

datefn

Insert, replace or delete UTC timestamp from filenames.

dostime

Cripple the file modtime by truncating odd seconds to even. To make life easier for rsync and friends if one has to interact with those kinds of "file systems".

edit-sqlite3

Edit an SQLite 3.x database file in your favourite text editor. The original version is backuped with the file modification time in the file name as seconds since 1970-01-01 00:00:00 UTC.

find_8bit

Read text from stdin and output all lines with bytes > U+007F.

find_inv_utf8

Read text from stdin and print all lines containing invalid UTF-8.

goal

Print timestamp when a specific goal will be reached. Specify start date with value, goal value and current value, and it will print the date and time of when the goal will be reached.

md-header

Create commented-out Vim fold markers (<!-- {{{num -->) with header level in Commonmark/Markdown files at the end of every header line where hash signs are used. Useful for big documents.

zeropad

Pad decimal or hecadecimal numbers with zeroes to get equal length.

zerosplit

Split contents into files based on separation bytes.

Stable, but has some limitations

sort-sqlite

Sort the rows in an SQLite database. A backup of the previous version is copied to a *.bck file containing the date of the file modification time in the file name.

Not described yet

Create a graph in Gnuplot of the commit activity. Needs ep, inc\_epstat and stpl. And Gnuplot, of course.

FIXME: ep is in Nårwidsjn.

"git What's New". Create an ASCII representation of all commits that contain the current commit. Useful after a git fetch to list all new commits. Needs git-lc.

FIXME: Uses "git lg". Change that to a proper git log command or put the alias somewhere.

git diff drivers

git-annex

Apache logs

Other


File ID: a8487d1c-1c4f-11e5-b5a1-398b4cddfd2b
vim: set ts=2 sw=2 sts=2 tw=72 et fo=tcqw fenc=utf8 :
vim: set com=b\:#,fb\:-,fb\:*,n\:> ft=markdown :
shortlog
4 days ago Øyvind A. HolmLib/std/c/, create_cproject: Create man page templatemastersynced/master
4 days ago Øyvind A. Holm`make tlok` outputs "FAIL\n" if the executable wasn...
4 days ago Øyvind A. Holmc/src/Makefile: Create and use `INSTALL_TARGETS`
4 days ago Øyvind A. Holmstd/c/README.md: Add section skeletons and don't indent...
4 days ago Øyvind A. Holmstd/c/README.md: Move "About this document" to the...
4 days ago Øyvind A. Holmstd/c/: Create `make html` and `make pdf`
4 days ago Øyvind A. HolmAdd `install` and `uninstall` to the top Makefile
4 days ago Øyvind A. HolmMakefile: `%.pdf`: Don't create the new file directly...
4 days ago Øyvind A. HolmMakefiles in std/c/: Use `$@` instead of hardcoded...
4 days ago Øyvind A. Holmc/src/Makefile: Collect all variables into 2 sorted...
2024-10-30 Øyvind A. Holmtests/datefn-files/.gitignore: Ignore `datefn-tmp/`
2024-10-30 Øyvind A. Holmstd.c: usage(): Use `myerror()` instead of `fprintf()`
2024-10-29 Øyvind A. Holmstd.c: Create `std_strerror()`, a predictable version...
2024-10-29 Øyvind A. Holmc/src/: Create a more sensible system for verbose level...
2024-10-29 Øyvind A. Holmstd.c: Improve some comments
2024-10-29 Øyvind A. Holmstd/c/src/: Delete `stddebug`, use plain old `stderr`
...
heads
4 days ago synced/master
4 days ago master
5 weeks ago synced/git-annex
5 weeks ago git-annex