An open API service indexing awesome lists of open source software.

https://github.com/tatsh/baldwin

Simple tracking of your home directory with easy-to-read diffs.
https://github.com/tatsh/baldwin

command-line file-management git version-control

Last synced: 4 months ago
JSON representation

Simple tracking of your home directory with easy-to-read diffs.

Awesome Lists containing this project

README

          

# Baldwin

[![Python versions](https://img.shields.io/pypi/pyversions/baldwin.svg?color=blue&logo=python&logoColor=white)](https://www.python.org/)
[![PyPI - Version](https://img.shields.io/pypi/v/baldwin)](https://pypi.org/project/baldwin/)
[![GitHub tag (with filter)](https://img.shields.io/github/v/tag/Tatsh/baldwin)](https://github.com/Tatsh/baldwin/tags)
[![License](https://img.shields.io/github/license/Tatsh/baldwin)](https://github.com/Tatsh/baldwin/blob/master/LICENSE.txt)
[![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/Tatsh/baldwin/v0.0.10/master)](https://github.com/Tatsh/baldwin/compare/v0.0.10...master)
[![CodeQL](https://github.com/Tatsh/baldwin/actions/workflows/codeql.yml/badge.svg)](https://github.com/Tatsh/baldwin/actions/workflows/codeql.yml)
[![QA](https://github.com/Tatsh/baldwin/actions/workflows/qa.yml/badge.svg)](https://github.com/Tatsh/baldwin/actions/workflows/qa.yml)
[![Tests](https://github.com/Tatsh/baldwin/actions/workflows/tests.yml/badge.svg)](https://github.com/Tatsh/baldwin/actions/workflows/tests.yml)
[![Coverage Status](https://coveralls.io/repos/github/Tatsh/baldwin/badge.svg?branch=master)](https://coveralls.io/github/Tatsh/baldwin?branch=master)
[![Dependabot](https://img.shields.io/badge/Dependabot-enabled-blue?logo=dependabot)](https://github.com/dependabot)
[![Documentation Status](https://readthedocs.org/projects/baldwin/badge/?version=latest)](https://baldwin.readthedocs.org/?badge=latest)
[![mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://pre-commit.com/)
[![Poetry](https://img.shields.io/badge/Poetry-242d3e?logo=poetry)](https://python-poetry.org)
[![pydocstyle](https://img.shields.io/badge/pydocstyle-enabled-AD4CD3?logo=pydocstyle)](https://www.pydocstyle.org/)
[![pytest](https://img.shields.io/badge/pytest-enabled-CFB97D?logo=pytest)](https://docs.pytest.org)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Downloads](https://static.pepy.tech/badge/baldwin/month)](https://pepy.tech/project/baldwin)
[![Stargazers](https://img.shields.io/github/stars/Tatsh/baldwin?logo=github&style=flat)](https://github.com/Tatsh/baldwin/stargazers)
[![Prettier](https://img.shields.io/badge/Prettier-enabled-black?logo=prettier)](https://prettier.io/)

[![@Tatsh](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fpublic.api.bsky.app%2Fxrpc%2Fapp.bsky.actor.getProfile%2F%3Factor=did%3Aplc%3Auq42idtvuccnmtl57nsucz72&query=%24.followersCount&style=social&logo=bluesky&label=Follow+%40Tatsh)](https://bsky.app/profile/Tatsh.bsky.social)
[![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-Tatsh-black?logo=buymeacoffee)](https://buymeacoffee.com/Tatsh)
[![Libera.Chat](https://img.shields.io/badge/Libera.Chat-Tatsh-black?logo=liberadotchat)](irc://irc.libera.chat/Tatsh)
[![Mastodon Follow](https://img.shields.io/mastodon/follow/109370961877277568?domain=hostux.social&style=social)](https://hostux.social/@Tatsh)
[![Patreon](https://img.shields.io/badge/Patreon-Tatsh2-F96854?logo=patreon)](https://www.patreon.com/Tatsh2)

This is a conversion of my simple scripts to version my home directory with very specific excludes
and formatting every file upon commit so that readable diffs can be generated.

## Installation

### Pip

```shell
pip install baldwin
```

## Usage

```plain
$ bw -h
Usage: bw [OPTIONS] COMMAND [ARGS]...

Manage a home directory with Git.

Options:
-d, --debug Enable debug logging.
-h, --help Show this message and exit.

Commands:
auto-commit
format
git
info
init
install-units
```

In addition to the `bw` command, `hgit` is a shortcut for `bw git`.

### Start a new repository

```shell
bw init
```

Find out where the Git directory is by running `bw info`. This can be done even if `init` has not
been run.

### Automation

#### systemd

```shell
bw install-units
```

This will install a timer that will automatically make a new commit every 6 hours. It does not push.

Keep in mind that systemd units require a full path to the executable, so you must keep the unit
up-to-date if you move where you install this package. Simply run `bw install-units` again.

Note that user systemd units only run while logged in.

To disable and remove the units, use the following commands:

```shell
systemctl disable --now home-vcs.timer
rm ~/.config/systemd/user/home-vcs.*
```

### Pushing

To push, use either of the following:

- `bw git push`
- `hgit push`

The above also demonstrates that `bw git`/`hgit` are just frontends to `git` with the correct
environment applied.

## Formatting

If Prettier is installed, it will be used to format files. The configuration used comes with this
package. Having consistent formatting allows for nice diffs to be generated.

If you have initialised a repository without having `prettier` or `jq` in `PATH`, you need to run the
following commands to enable readable diffs:

```shell
hgit config diff.json.textconv 'jq -MS .'
hgit config diff.json.cachetextconv true
hgit config diff.yaml.textconv 'prettier --no-editorconfig --parser yaml'
hgit config diff.yaml.cachetextconv true
```

If you have the XML plugin installed:

```shell
hgit config diff.xml.textconv 'prettier --no-editorconfig --parser xml --xml-whitespace-sensitivity ignore'
hgit config diff.xml.cachetextconv true
```

## Binary files

Any file that is untracked and detected to be binary will not be added. Use `hgit add` to add a
binary file manually.

## Other details

Default `.gitignore` and `.gitattributes` files are installed on initialisation. They are never
modified by this tool. Please customise as necessary.