description | My ~/bin/ directory, with useful scripts I use all the time. |
owner | sunny@sunbase.org |
last change | Sun, 17 Nov 2024 01:52:51 +0000 (17 02:52 +0100) |
URL | git://repo.or.cz/sunny256-utils.git |
https://repo.or.cz/sunny256-utils.git | |
push URL | ssh://repo.or.cz/sunny256-utils.git |
https://repo.or.cz/sunny256-utils.git (learn more) | |
bundle info | sunny256-utils.git downloadable bundles |
content tags |
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.
Everything here created by Øyvind A. Holm (<sunny@sunbase.org>) is licensed under the GNU General Public License version 2 or later.
This repository can be cloned from
git@gitlab.com:oyvholm/utils.git
/
<https://gitlab.com/oyvholm/utils.git> (Main repo)git@bitbucket.org:sunny256/utils.git
ssh://sunny256@repo.or.cz/srv/git/sunny256-utils.git
The repositories are synced with Gitspread.
These scripts are stable and ready for public use.
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
.
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.
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"
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.
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.
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
.
Scan remotes for branches and recreate them in the local repository.
Change the state of the current repository to/from a bare repository to/from a regular repository.
Alias for git bisect
, but allows execution from a subdirectory.
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.
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:
-o
/--once
is used later, files
marked with n
will not be checked.The answers can also be stored in an SQLite database to automate subsequent runs.
Delete all remote and local branches specified on the command line.
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.
Show log differences between branches with optional patch.
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.
Filter output from git branch
through this to remove commit-SHA1
branches.
Push to all predefined remotes with a single command.
Restore empty directories from the .emptydirs
file created by
git-store-dirs
.
Shortcut for git rcmd -c "git pull --ff-only"
.
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.
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.
Read text from stdin or files and convert from am/pm to 24-hour clock.
Insert, replace or delete UTC timestamp from filenames.
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 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.
Read text from stdin and output all lines with bytes > U+007F.
Read text from stdin and print all lines containing invalid UTF-8.
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.
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.
Pad decimal or hecadecimal numbers with zeroes to get equal length.
Split contents into files based on separation bytes.
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.
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.
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 :
4 days ago | synced/master | logtree |
4 days ago | master | logtree |
5 weeks ago | synced/git-annex | logtree |
5 weeks ago | git-annex | logtree |