From 93a75aefafa829b76fa3dce13f3c8d73e04e8ebc Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Tue, 8 Apr 2025 13:52:30 -0400 Subject: [PATCH 1/6] added .ignore support, updated readme for sr.ht migration --- README.md | 94 ++++++++++++++++++++++++++++++++++++----------------- autoyadm.sh | 19 ++++++++++- 2 files changed, 83 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index abf938e..f4975a7 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,34 @@ # AutoYADM -AutoYADM is a small shell utility to automate the process of managing dotfiles with [YADM](https://github.com/yadm-dev/yadm) by allowing the user to define a list of files & directories to be automatically added, committed and pushed whenever the script is run. **Most notably, AutoYADM accounts for newly created files previously untracked by YADM.** +AutoYADM is a small shell utility to automate the process of managing dotfiles +with [YADM](https://github.com/yadm-dev/yadm) by allowing the user to define a +list of files & directories to be automatically added, committed and pushed +whenever the script is run. **Most notably, AutoYADM accounts for newly created +files previously untracked by YADM.** + +The benefits of this approach: + +1. Robust version control thanks to YADM and Git. +2. You won't forget to commit new files in important folders. +3. Maintain control over paths to auto-commit, and paths to only manually + commit. + +I have personally been using AutoYADM to sync my dotfiles between devices +without any problems since October 2024. ## Features -- Configure a list of files & directories to be automatically tracked by YADM +- Configure a list of files & directories to be automatically tracked by YADM. - Tracked directories will also track any new files inside them! -- Automatically add, commit, and push tracked paths +- Automatically add, commit, and push tracked paths. +- `.ignore` support with `fd`. ## Installation Simply clone the repository: ```Bash -git clone git@github.com:ficcdaf/autoyadm.git +git clone https://git.sr.ht/~ficd/autoyadm ``` You may consider adding aliases to your shell configuration: @@ -25,36 +40,44 @@ alias yadmadd="/path/to/autoyadm/yadmadd.sh" alias autoyadm="AUTOYADMPUSH=1 /path/to/autoyadm/autoyadm.sh" ``` -
-Click to see dependencies +**Dependencies**: - [YADM](https://github.com/yadm-dev/yadm) - `git` -- Bash/Zsh -- `openssh` (optional) - -
+- `fd` (optional, but recommended) + - fallback to `find` otherwise +- `openssh` (required for pushing) ## Usage -> Note: The following assumes you have created shell aliases to the two scripts. You may, of course, simply call them directly. +> Note: The following assumes you have created shell aliases to the two scripts. +> You may, of course, simply call them directly. ### Tracking -AutoYADM maintains a list of files and directories for automatic tracking. _**All** children of tracked directories will be tracked, including newly created, previously untracked files._ For example, if you add your Neovim configuration at `~/.config/nvim` to tracking, then any new files you create inside that folder will automatically be added and committed by AutoYADM. +AutoYADM maintains a list of files and directories for automatic tracking. +_**All** children of tracked directories will be tracked, including newly +created, previously untracked files._ For example, if you add your Neovim +configuration at `~/.config/nvim` to tracking, then any new files you create +inside that folder will automatically be added and committed by AutoYADM. -The tracking file is stored in `~/.config/yadm/tracked`. `$XDG_CONFIG_HOME` is respected. The file will be automatically created if it doesn't already exist. You can even add it to tracking: `yadmadd ~/.config/yadm/tracked` +The tracking file is stored in `~/.config/yadm/tracked`. `$XDG_CONFIG_HOME` is +respected. The file will be automatically created if it doesn't already exist. +You can even add it to tracking: `yadmadd ~/.config/yadm/tracked` -> **Important**: Symlinks are _**not**_ added; this is to avoid conflicts with `yadm alt` +> **Important**: Symlinks are _**not**_ added; this is to avoid conflicts with +> `yadm alt` -The tracking file contains the paths to tracked files & directories **relative to $HOME**. For example: +The tracking file contains the paths to tracked files & directories **relative +to $HOME**. For example: ``` .bashrc .config/nvim ``` -To add paths to be tracked, you may use `yadmadd.sh`. Any valid absolute or relative path should work. +To add paths to be tracked, you may use `yadmadd.sh`. Any valid absolute or +relative path should work. ```Bash $ yadmadd ~/.bashrc @@ -67,6 +90,20 @@ $ yadmadd .bashrc .zshrc .config/nvim To remove a target from tracking, simply delete it from the `tracked` file. +### Ignoring Certain Files + +It's possible to ignore certain patterns inside a folder you're otherwise +tracking with `yadmadd`. For example, suppose you've added `.config/foo`, but +you want to specifically ignore `.config/foo/bar.log`. You can use a `.ignore` +file for this: + +```sh +echo "bar.log" > ~/.config/foo/.ignore +``` + +The `.ignore` file must be in the root of the directory you've added with +`yadmadd`. You also need `fd` available on your `$PATH` for ignoring to work. + ### Committing & Pushing To automatically add and commit your tracking targets, use `autoyadm.sh`: @@ -75,7 +112,8 @@ To automatically add and commit your tracking targets, use `autoyadm.sh`: $ autoyadm ``` -By default, automatic pushing is disabled. You can enable it with an environment variable: +By default, automatic pushing is disabled. You can enable it with an environment +variable: ```Bash $ export AUTOYADMPUSH=1 @@ -84,17 +122,24 @@ $ autoyadm $ AUTOYADMPUSH=1 autoyadm ``` -> Note: For auto push to work, ssh-agent must be enabled, and the environment file needs to exist inside `~/.ssh`. Furthermore, you must have SSH setup with your git host. +> Note: For auto push to work, ssh-agent must be enabled, and the environment +> file needs to exist inside `~/.ssh`. Furthermore, you must have SSH setup with +> your git host. ### Calling AutoYADM Automatically -By default, AutoYADM only runs when the user calls it explicitly. If you want to automate this process, you are responsible for setting it up yourself. You may consider configuring a cron job for this. The following example will run AutoYADM every 15 minutes, with automatic push enabled, appending its output to a log file: +By default, AutoYADM only runs when the user calls it explicitly. If you want to +automate this process, you are responsible for setting it up yourself. You may +consider configuring a cron job for this. The following example will run +AutoYADM every 15 minutes, with automatic push enabled, appending its output to +a log file: ```Bash */15 * * * * AUTOYADMPUSH=1 /path/to/autoyadm/audoyadm.sh >> /path/to/log/file.log ``` -If you are on Arch Linux, you can follow these instructions to set up the cron job: +If you are on Arch Linux, you can follow these instructions to set up the cron +job: ```Bash # Install a cron daemon if you @@ -108,12 +153,3 @@ $ crontab -e $ systemctl enable cronie $ systemctl start cronie ``` - -## Feature Roadmap - -- [x] Allow custom `tracked` file location & name -- [ ] Optionally allow symlinks only if they are explicitly added to tracking - -## Contributing - -Contributions are very welcome. This is a very small and simple script, but if you have some improvements or new features, please feel free to submit a PR. Bug reports welcome, too. diff --git a/autoyadm.sh b/autoyadm.sh index 962acc0..7d02ec3 100755 --- a/autoyadm.sh +++ b/autoyadm.sh @@ -4,6 +4,8 @@ # from a file and executes "yadm add" # on all of them, then creates a timestamped # commit and pushes the changes. +# Author: Daniel Fichtinger +# License: MIT AYE="AutoYADM Error:" AYM="AutoYADM:" @@ -35,6 +37,16 @@ if [ -z "$HOST" ]; then HOST="$(hostname)" fi +# check if fd is installed, +# if so we prefer that. Setting this variable +# avoids needing to repeat the check on every +# fd/find invocation. +if command -v fd >/dev/null; then + FD="true" +else + FD="false" +fi + # First we read each path from "tracked" (while read -r relpath; do path="$HOME/$relpath" @@ -42,7 +54,12 @@ fi # if the path points to a directory # This ensures symlinks are not added if [ -d "$path" ]; then - find "$path" -type f -exec yadm add {} + + if [ "$FD" == "true" ]; then + # we prefer fd because it respects .ignore + fd -t f . "$path" -X yadm add + else + find "$path" -type f -exec yadm add {} + + fi # If just a file, we add directly elif [ -f "$path" ]; then yadm add "$path" From 7eab88de41609c22a7cb9323b831879996b9cdf2 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Tue, 8 Apr 2025 13:58:14 -0400 Subject: [PATCH 2/6] added toc and sr.ht links to readme --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index f4975a7..0ef6722 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,21 @@ # AutoYADM + + +- [AutoYADM](#autoyadm) + - [Features](#features) + - [Installation](#installation) + - [Usage](#usage) + - [Tracking](#tracking) + - [Ignoring Certain Files](#ignoring-certain-files) + - [Committing & Pushing](#committing-pushing) + - [Calling AutoYADM Automatically](#calling-autoyadm-automatically) + - [Contributing](#contributing) + + + +> This is part of Daniel's [utility collection](https://sr.ht/~ficd/utils/). + AutoYADM is a small shell utility to automate the process of managing dotfiles with [YADM](https://github.com/yadm-dev/yadm) by allowing the user to define a list of files & directories to be automatically added, committed and pushed @@ -153,3 +169,9 @@ $ crontab -e $ systemctl enable cronie $ systemctl start cronie ``` + +## Contributing + +Please submit patches, questions, and discussion points to the +[~ficd/utils mailing list](https://lists.sr.ht/~ficd/utils), and consider +visiting the [public ticket tracker](https://todo.sr.ht/~ficd/utils). From 8f0001d2936e83852522cbef13b6d67991251086 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Tue, 8 Apr 2025 19:10:36 -0400 Subject: [PATCH 3/6] added ci script for github mirroring --- .build.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .build.yml diff --git a/.build.yml b/.build.yml new file mode 100644 index 0000000..e262506 --- /dev/null +++ b/.build.yml @@ -0,0 +1,15 @@ +image: alpine/latest +packages: + - git + - openssh +secrets: + - 0639564d-6995-4e2e-844b-2f8feb0b7fb1 +environment: + repo: autoyadm + github: git@github.com:ficcdaf/autoyadm.git +tasks: + - mirror: | + ssh-keyscan github.com >> ~/.ssh/known_hosts + cd "$repo" + git remote add github "$github" + git push --mirror github From 465bc51b3949f906e183d33d33bc11ea529bea1a Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Tue, 6 May 2025 14:04:08 -0400 Subject: [PATCH 4/6] fixed support for .gitignore --- README.md | 11 ++++++----- autoyadm.sh | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0ef6722..c49d176 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ without any problems since October 2024. - Configure a list of files & directories to be automatically tracked by YADM. - Tracked directories will also track any new files inside them! - Automatically add, commit, and push tracked paths. -- `.ignore` support with `fd`. +- `.ignore`/`.gitignore` support with `fd`. ## Installation @@ -110,15 +110,16 @@ To remove a target from tracking, simply delete it from the `tracked` file. It's possible to ignore certain patterns inside a folder you're otherwise tracking with `yadmadd`. For example, suppose you've added `.config/foo`, but -you want to specifically ignore `.config/foo/bar.log`. You can use a `.ignore` -file for this: +you want to specifically ignore `.config/foo/bar.log`. You can use a +`.ignore`/`.gitignore` file for this: ```sh echo "bar.log" > ~/.config/foo/.ignore ``` -The `.ignore` file must be in the root of the directory you've added with -`yadmadd`. You also need `fd` available on your `$PATH` for ignoring to work. +The `.ignore`/`.gitignore` file must be in the root of the directory you've +added with `yadmadd`. You also need `fd` available on your `$PATH` for ignoring +to work. ### Committing & Pushing diff --git a/autoyadm.sh b/autoyadm.sh index 7d02ec3..10fb9be 100755 --- a/autoyadm.sh +++ b/autoyadm.sh @@ -55,8 +55,8 @@ fi # This ensures symlinks are not added if [ -d "$path" ]; then if [ "$FD" == "true" ]; then - # we prefer fd because it respects .ignore - fd -t f . "$path" -X yadm add + # we prefer fd because it respects .ignore and .gitignore + fd --no-require-git -t f . "$path" -X yadm add else find "$path" -type f -exec yadm add {} + fi From 41677e43c06fe9be9e1ec063e5a27a6c30d1f520 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Sat, 24 May 2025 21:52:26 -0400 Subject: [PATCH 5/6] fixed fd call to include hidden files --- autoyadm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoyadm.sh b/autoyadm.sh index 10fb9be..ce018f1 100755 --- a/autoyadm.sh +++ b/autoyadm.sh @@ -56,7 +56,7 @@ fi if [ -d "$path" ]; then if [ "$FD" == "true" ]; then # we prefer fd because it respects .ignore and .gitignore - fd --no-require-git -t f . "$path" -X yadm add + fd --no-require-git --hidden -t f . "$path" -X yadm add else find "$path" -type f -exec yadm add {} + fi From 6980d4a7c0f30e5cd2e68759d5d90af7d09f3948 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Thu, 17 Jul 2025 21:56:54 -0400 Subject: [PATCH 6/6] updated links in readme --- README.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/README.md b/README.md index c49d176..1c74b7b 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,6 @@ -> This is part of Daniel's [utility collection](https://sr.ht/~ficd/utils/). - AutoYADM is a small shell utility to automate the process of managing dotfiles with [YADM](https://github.com/yadm-dev/yadm) by allowing the user to define a list of files & directories to be automatically added, committed and pushed @@ -44,7 +42,7 @@ without any problems since October 2024. Simply clone the repository: ```Bash -git clone https://git.sr.ht/~ficd/autoyadm +git clone https://git.ficd.sh/ficd/autoyadm ``` You may consider adding aliases to your shell configuration: @@ -170,9 +168,3 @@ $ crontab -e $ systemctl enable cronie $ systemctl start cronie ``` - -## Contributing - -Please submit patches, questions, and discussion points to the -[~ficd/utils mailing list](https://lists.sr.ht/~ficd/utils), and consider -visiting the [public ticket tracker](https://todo.sr.ht/~ficd/utils).