# dfm
[](https://gitlab.com/deliberist/dfmpy/-/commits/main)
[](https://ci.appveyor.com/project/rbprogrammer/dfmpy)
[](https://codecov.io/gl/deliberist/dfmpy)
[](https://pypi.org/project/dfmpy)
Sometimes pronounced "_diff-em-py_" and is a small play on words. dfm is yet
another Dot-Files Manager, but with robust features that can essentially
"_diff_" the dotfiles actually installed versus the expected installed files.
Hence the "_diff-em_".
dfm is not just another dotfiles manager, it supports multiple environments
based on hostname, system type, or a combination of the two. It also ignores
files/directories based on user defined globs which can be particularly useful
if dfm has to traverse directories that have large I/O latencies (large
directory inodes, too many files to stat, or even just network mounted
directories, etc.).
## Installation
Since dfm is [registered on Pypi](https://pypi.org/project/dfm), you can install
dfm through standard `pip` methods.
```bash
python3 -m pip install --user --upgrade dfmpy
```
For more installation details, see
[INSTALLATION.md](https://gitlab.com/deliberist/dfmpy/blob/main/INSTALLATION.md).
## Config Files
To use dfm you must first `dfm init` which will create two files config
files:
1. `${XDG_CONFIG_HOME}/dfm/config.ini`
1. `${XDG_CONFIG_HOME}/dfm/ignore.globs`
where `${XDG_CONFIG_HOME}` is usually `~/.config`. dfm uses
[xdgenvpy](https://pypi.org/project/xdgenvpy) to get a handle on the dfm config
directory.
`config.ini` is the main config file that tells it, among other things, where to
find your dotfiles repository, where to install symlinks, and even how to manage
identical filenames for different systems.
`ignore.globs` is a set of commonly ignored files and directories that one might
never want synced with their dotfiles repository. For example, if you manage
your dotfiles repository with Git then you would never want the `.git` directory
symlinked to your destination directory. And vice versa, you should never add
SSH keys (`~/.ssh/id_*`) to your dotfiles repo. The globs in this file tell
dfm to just skip over the files or directories.
## Usage
dfm makes use of Python's
[argparse](https://docs.python.org/3/library/argparse.html) library sub-command
feature. This gives dfm multiple independent commands with their own set of
CLI arguments.
### File suffixes
To maintain dotfiles across multiple systems there needs to be a mechanism that
allows for all the files to have the same name when install but not collide when
they reside in the repository. To get around this dfm makes use of the system's
hostname and system type appended to the file name.
For example, developers may want a `~/.vimrc` in their home directory. But in
the dotfiles repository we may want all vimrc files next to each other, i.e. in
the same directory. dfm searches for a `##` marker in a file to determine if
the file has a system specific variant. Suppose our dotfiles repo looks like
this:
```bash
cd ~/.files
tree
.
|-- .vimrc
|-- .vimrc##host1.Linux
|-- .vimrc##host2.Linux
|-- .vimrc##host2.Windows
|-- .vimrc##host3
`-- .vimrc##Windows
0 directories, 6 files
```
- `.vimrc` is the default vimrc file and will be the symlinked file if no other
system specific file exists.
- `.vimrc##host1.Linux` is a system specific file that will only be symlinked if
the hostname is "host1" and the system type is Linux.
- `.vimrc##host2.Linux` is a system specific file that will only be symlinked if
the hostname is "host2" and the system type is Linux.
- `.vimrc##host2.Windows` is a system specific file that will only be symlinked
if the hostname is "host2" and the system type is Windows.
- `.vimrc##host3` is a system specific file that will only be symlinked if the
hostname is "host3".
- `.vimrc##Windows` is a system specific file that will only be symlinked if the
system type is Windows.
The hostname is determined by the return value from
[socket.gethostname()](https://docs.python.org/3/library/socket.html#socket.gethostname),
and the system type is determined by the return value from
[platform.system()](https://docs.python.org/3/library/platform.html#platform.system).
### Common arguments
```bash
dfm --help
```
`-v` is the verbose flag, which can be used multiple times. This flag controls
which log level gets printed. The default log level is set to ERROR, which is
lowered to WARNING when one `-v` flag is set. Multiple `-v` flags will lower
the log level even further.
`-i` turns on interactive mode. dfm strives to be as filesystem safe as
possible. By default it will not attempt to overwrite files. The interactive
flag tells dfm to ask for permission when it performs a potentially dangerous
operation.
`-f` turns on force mode. Again, dfm strives to be filesystem safe. The
default commands will not overwrite files nor delete files without explicit user
direction. While interactive mode can help with this, sometimes developers want
to just force an operation and live with the consequences. Effectively, force
mode short circuits interactive mode and assumes the developers accepts the
operation that dfm is trying to perform (e.g. overwriting a file).
### Install dfm
```bash
dfm init --help
```
Currently, dfm requires initialization after installation. We merely need to
run the `init` command.
```bash
python3 -m pip install --user --upgrade dfmpy
dfm init
```
Next, if you don't want to have your dotfiles repository under `~/.files/` then
you have one of two options:
1. Create a symlink, something like:
`ln -s /home/user/.local/git/dotfiles/source/ ~/.files`. Or
1. Update `~/.config/dfm/config.ini` and change the `repository_dir` property to
point to your actual dotfiles repo.
### Sync your dotfiles
```bash
dfm sync --help
```
Once installed and initialized, dfm will utilize the
`${XDG_CONFIG_HOME}/dfm/config.ini` config file when it needs to (re)sync your
dotfiles. Per the default `config.ini` file, dfm assumes your dotfiles repo is
initially located at `~/.local/share/dotfiles`. If this is not the case, you
need to modify your `config.ini` accordingly.
```bash
dfm sync -f
```
The sync command will use the `dfm/config.ini` file to determine where the
dotfiles are installed and where the dotfiles repository is. It will then
calculate a set of expected symlinks to files. dfm uses this set to traverse
the installed dotfiles to determine what needs updating.
The sync command will create new symlinks to the expected files in the dotfiles
repository. However, being filesystem safe, the sync command will not unlink
existing symlinks, nor overwrite existing symlinks. Either interactive or force
mode is required to make such changes.
### Adding individual files
```bash
dfm add --help
```
Sometimes developers want to add a single file to their dotfiles repository.
dfm has an option to add the file from their home directory directly into their
dotfiles repository, then automatically symlink so a system specific file.
For example, let's say we needed to add our `~/.vimrc` file to our dotfiles.
The `$HOME` directory may look roughly like this:
```bash
ls -al ~
drwxr-xr-x 22 user user 4096 Nov 10 11:47 .
drwxr-xr-x 3 root root 4096 Apr 25 2019 ..
...
drwxr-xr-x 13 user user 4096 Jul 9 04:54 .cache
drwxr-xr-x 30 user user 4096 Nov 10 11:47 .config
drwx------ 6 user user 4096 Nov 10 11:47 .local
-rw------- 1 user user 57 Oct 23 19:13 .vimrc
...
```
We can simply add the `~/.vimrc` file, and the developer's home directory will
look like this:
```bash
dfm add ~/.vimrc
ls -al ~
drwxr-xr-x 22 user user 4096 Nov 10 11:47 .
drwxr-xr-x 3 root root 4096 Apr 25 2019 ..
...
drwxr-xr-x 13 user user 4096 Jul 9 04:54 .cache
drwxr-xr-x 30 user user 4096 Nov 10 11:47 .config
drwx------ 6 user user 4096 Nov 10 11:47 .local
lrwxrwxrwx 1 user user 28 Nov 10 11:47 .vimrc -> /home/user/.files/.vimrc##hostname.Linux
...
```
Under the hood, dfm is simply moving the file into the dotfiles repository with
the most restrictive system specific name. Then it will create the symlink so
that `~/.vimrc` points to the repository file.
### Listing the installed (eg synced) files
```bash
dfm list --help
```
dfm has a unique insight into your dotfiles. It knows how to ignore certain
files, it knows what files should be symlinked to others, and it knows when
there is a discrepancy with the installed files versus the dotfiles repo. As
such, simple Bash `ls -R` or `tree` commands will not print just the dotfiles
managed by dfm.
dfm has a `list` command that prints only the files dfm manages, the files it
expects, and the files that might have broken symlinks. The file listing also
adheres to dfm's log level conventions:
- **broken symlinks** (links to non-existent files) are logged at the CRITICAL
level.
- **stale symlinks** (links to the wrong files) are logged at the ERROR level.
- **not installed symlinks** are logged at the WARNING level.
- and **proper symlinks** (links to the correct files) are logged at the INFO
level.
Additionally, the list command has a `--tree` mode that changes the output into
a directory tree structure, rather than a strict list.
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/deliberist/dfmpy",
"name": "dfmpy",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Mike Durso",
"author_email": "rbprogrammer@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f9/9c/a9ff05b5764413ba1a7de43879e5b7c6b788567a5315dc87c9e7a003cbeb/dfmpy-1.0.0.tar.gz",
"platform": null,
"description": "# dfm\n\n[](https://gitlab.com/deliberist/dfmpy/-/commits/main)\n[](https://ci.appveyor.com/project/rbprogrammer/dfmpy)\n[](https://codecov.io/gl/deliberist/dfmpy)\n[](https://pypi.org/project/dfmpy)\n\nSometimes pronounced \"_diff-em-py_\" and is a small play on words. dfm is yet\nanother Dot-Files Manager, but with robust features that can essentially\n\"_diff_\" the dotfiles actually installed versus the expected installed files.\nHence the \"_diff-em_\".\n\ndfm is not just another dotfiles manager, it supports multiple environments\nbased on hostname, system type, or a combination of the two. It also ignores\nfiles/directories based on user defined globs which can be particularly useful\nif dfm has to traverse directories that have large I/O latencies (large\ndirectory inodes, too many files to stat, or even just network mounted\ndirectories, etc.).\n\n## Installation\n\nSince dfm is [registered on Pypi](https://pypi.org/project/dfm), you can install\ndfm through standard `pip` methods.\n\n```bash\npython3 -m pip install --user --upgrade dfmpy\n```\n\nFor more installation details, see\n[INSTALLATION.md](https://gitlab.com/deliberist/dfmpy/blob/main/INSTALLATION.md).\n\n## Config Files\n\nTo use dfm you must first `dfm init` which will create two files config\nfiles:\n\n1. `${XDG_CONFIG_HOME}/dfm/config.ini`\n1. `${XDG_CONFIG_HOME}/dfm/ignore.globs`\n\nwhere `${XDG_CONFIG_HOME}` is usually `~/.config`. dfm uses\n[xdgenvpy](https://pypi.org/project/xdgenvpy) to get a handle on the dfm config\ndirectory.\n\n`config.ini` is the main config file that tells it, among other things, where to\nfind your dotfiles repository, where to install symlinks, and even how to manage\nidentical filenames for different systems.\n\n`ignore.globs` is a set of commonly ignored files and directories that one might\nnever want synced with their dotfiles repository. For example, if you manage\nyour dotfiles repository with Git then you would never want the `.git` directory\nsymlinked to your destination directory. And vice versa, you should never add\nSSH keys (`~/.ssh/id_*`) to your dotfiles repo. The globs in this file tell\ndfm to just skip over the files or directories.\n\n## Usage\n\ndfm makes use of Python's\n[argparse](https://docs.python.org/3/library/argparse.html) library sub-command\nfeature. This gives dfm multiple independent commands with their own set of\nCLI arguments.\n\n### File suffixes\n\nTo maintain dotfiles across multiple systems there needs to be a mechanism that\nallows for all the files to have the same name when install but not collide when\nthey reside in the repository. To get around this dfm makes use of the system's\nhostname and system type appended to the file name.\n\nFor example, developers may want a `~/.vimrc` in their home directory. But in\nthe dotfiles repository we may want all vimrc files next to each other, i.e. in\nthe same directory. dfm searches for a `##` marker in a file to determine if\nthe file has a system specific variant. Suppose our dotfiles repo looks like\nthis:\n\n```bash\ncd ~/.files\ntree\n.\n|-- .vimrc\n|-- .vimrc##host1.Linux\n|-- .vimrc##host2.Linux\n|-- .vimrc##host2.Windows\n|-- .vimrc##host3\n`-- .vimrc##Windows\n\n0 directories, 6 files\n```\n\n- `.vimrc` is the default vimrc file and will be the symlinked file if no other\n system specific file exists.\n\n- `.vimrc##host1.Linux` is a system specific file that will only be symlinked if\n the hostname is \"host1\" and the system type is Linux.\n\n- `.vimrc##host2.Linux` is a system specific file that will only be symlinked if\n the hostname is \"host2\" and the system type is Linux.\n\n- `.vimrc##host2.Windows` is a system specific file that will only be symlinked\n if the hostname is \"host2\" and the system type is Windows.\n\n- `.vimrc##host3` is a system specific file that will only be symlinked if the\n hostname is \"host3\".\n\n- `.vimrc##Windows` is a system specific file that will only be symlinked if the\n system type is Windows.\n\nThe hostname is determined by the return value from\n[socket.gethostname()](https://docs.python.org/3/library/socket.html#socket.gethostname),\nand the system type is determined by the return value from\n[platform.system()](https://docs.python.org/3/library/platform.html#platform.system).\n\n### Common arguments\n\n```bash\ndfm --help\n```\n\n`-v` is the verbose flag, which can be used multiple times. This flag controls\nwhich log level gets printed. The default log level is set to ERROR, which is\nlowered to WARNING when one `-v` flag is set. Multiple `-v` flags will lower\nthe log level even further.\n\n`-i` turns on interactive mode. dfm strives to be as filesystem safe as\npossible. By default it will not attempt to overwrite files. The interactive\nflag tells dfm to ask for permission when it performs a potentially dangerous\noperation.\n\n`-f` turns on force mode. Again, dfm strives to be filesystem safe. The\ndefault commands will not overwrite files nor delete files without explicit user\ndirection. While interactive mode can help with this, sometimes developers want\nto just force an operation and live with the consequences. Effectively, force\nmode short circuits interactive mode and assumes the developers accepts the\noperation that dfm is trying to perform (e.g. overwriting a file).\n\n### Install dfm\n\n```bash\ndfm init --help\n```\n\nCurrently, dfm requires initialization after installation. We merely need to\nrun the `init` command.\n\n```bash\npython3 -m pip install --user --upgrade dfmpy\ndfm init\n```\n\nNext, if you don't want to have your dotfiles repository under `~/.files/` then\nyou have one of two options:\n\n1. Create a symlink, something like:\n `ln -s /home/user/.local/git/dotfiles/source/ ~/.files`. Or\n1. Update `~/.config/dfm/config.ini` and change the `repository_dir` property to\n point to your actual dotfiles repo.\n\n### Sync your dotfiles\n\n```bash\ndfm sync --help\n```\n\nOnce installed and initialized, dfm will utilize the\n`${XDG_CONFIG_HOME}/dfm/config.ini` config file when it needs to (re)sync your\ndotfiles. Per the default `config.ini` file, dfm assumes your dotfiles repo is\ninitially located at `~/.local/share/dotfiles`. If this is not the case, you\nneed to modify your `config.ini` accordingly.\n\n```bash\ndfm sync -f\n```\n\nThe sync command will use the `dfm/config.ini` file to determine where the\ndotfiles are installed and where the dotfiles repository is. It will then\ncalculate a set of expected symlinks to files. dfm uses this set to traverse\nthe installed dotfiles to determine what needs updating.\n\nThe sync command will create new symlinks to the expected files in the dotfiles\nrepository. However, being filesystem safe, the sync command will not unlink\nexisting symlinks, nor overwrite existing symlinks. Either interactive or force\nmode is required to make such changes.\n\n### Adding individual files\n\n```bash\ndfm add --help\n```\n\nSometimes developers want to add a single file to their dotfiles repository.\ndfm has an option to add the file from their home directory directly into their\ndotfiles repository, then automatically symlink so a system specific file.\n\nFor example, let's say we needed to add our `~/.vimrc` file to our dotfiles.\nThe `$HOME` directory may look roughly like this:\n\n```bash\nls -al ~\ndrwxr-xr-x 22 user user 4096 Nov 10 11:47 .\ndrwxr-xr-x 3 root root 4096 Apr 25 2019 ..\n...\ndrwxr-xr-x 13 user user 4096 Jul 9 04:54 .cache\ndrwxr-xr-x 30 user user 4096 Nov 10 11:47 .config\ndrwx------ 6 user user 4096 Nov 10 11:47 .local\n-rw------- 1 user user 57 Oct 23 19:13 .vimrc\n...\n```\n\nWe can simply add the `~/.vimrc` file, and the developer's home directory will\nlook like this:\n\n```bash\ndfm add ~/.vimrc\nls -al ~\ndrwxr-xr-x 22 user user 4096 Nov 10 11:47 .\ndrwxr-xr-x 3 root root 4096 Apr 25 2019 ..\n...\ndrwxr-xr-x 13 user user 4096 Jul 9 04:54 .cache\ndrwxr-xr-x 30 user user 4096 Nov 10 11:47 .config\ndrwx------ 6 user user 4096 Nov 10 11:47 .local\nlrwxrwxrwx 1 user user 28 Nov 10 11:47 .vimrc -> /home/user/.files/.vimrc##hostname.Linux\n...\n```\n\nUnder the hood, dfm is simply moving the file into the dotfiles repository with\nthe most restrictive system specific name. Then it will create the symlink so\nthat `~/.vimrc` points to the repository file.\n\n### Listing the installed (eg synced) files\n\n```bash\ndfm list --help\n```\n\ndfm has a unique insight into your dotfiles. It knows how to ignore certain\nfiles, it knows what files should be symlinked to others, and it knows when\nthere is a discrepancy with the installed files versus the dotfiles repo. As\nsuch, simple Bash `ls -R` or `tree` commands will not print just the dotfiles\nmanaged by dfm.\n\ndfm has a `list` command that prints only the files dfm manages, the files it\nexpects, and the files that might have broken symlinks. The file listing also\nadheres to dfm's log level conventions:\n\n- **broken symlinks** (links to non-existent files) are logged at the CRITICAL\n level.\n- **stale symlinks** (links to the wrong files) are logged at the ERROR level.\n- **not installed symlinks** are logged at the WARNING level.\n- and **proper symlinks** (links to the correct files) are logged at the INFO\n level.\n\nAdditionally, the list command has a `--tree` mode that changes the output into\na directory tree structure, rather than a strict list.\n",
"bugtrack_url": null,
"license": null,
"summary": "Another dotfiles manager.",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://gitlab.com/deliberist/dfmpy"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "66b28b07a0d8253b091d7c222455992a0b9c5fea81c6c7079b6879eb219c1fab",
"md5": "d0281469217d710bb4b0e439a5aa5a13",
"sha256": "55b9bfda3083897befe26a40a3a9e6a4d831c270b76b21a81ebba6cfe45efdf6"
},
"downloads": -1,
"filename": "dfmpy-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d0281469217d710bb4b0e439a5aa5a13",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 22474,
"upload_time": "2024-12-24T19:52:36",
"upload_time_iso_8601": "2024-12-24T19:52:36.788190Z",
"url": "https://files.pythonhosted.org/packages/66/b2/8b07a0d8253b091d7c222455992a0b9c5fea81c6c7079b6879eb219c1fab/dfmpy-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f99ca9ff05b5764413ba1a7de43879e5b7c6b788567a5315dc87c9e7a003cbeb",
"md5": "4d47aca18e56db0df70cab418b218cbd",
"sha256": "2d255164362149cbdb601604faf6fdf4bebafed761d7a798da7fa855df182040"
},
"downloads": -1,
"filename": "dfmpy-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "4d47aca18e56db0df70cab418b218cbd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21983,
"upload_time": "2024-12-24T19:52:39",
"upload_time_iso_8601": "2024-12-24T19:52:39.136748Z",
"url": "https://files.pythonhosted.org/packages/f9/9c/a9ff05b5764413ba1a7de43879e5b7c6b788567a5315dc87c9e7a003cbeb/dfmpy-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-24 19:52:39",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "deliberist",
"gitlab_project": "dfmpy",
"lcname": "dfmpy"
}