feat: added support for tracked
file in yadm
config directory
This commit is contained in:
parent
65ca523293
commit
047cc909aa
3 changed files with 33 additions and 10 deletions
|
@ -43,7 +43,7 @@ alias autoyadm="AUTOYADMPUSH=1 /path/to/autoyadm/autoyadm.sh"
|
|||
|
||||
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.
|
||||
|
||||
> _Both scripts and the `tracked` file **must** be in the same directory._
|
||||
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`
|
||||
|
||||
|
@ -67,8 +67,6 @@ $ yadmadd .bashrc .zshrc .config/nvim
|
|||
|
||||
To remove a target from tracking, simply delete it from the `tracked` file.
|
||||
|
||||
> Note: `tracked` is in the `.gitignore` of this repository. If you want to add it to tracking, you will need to remove the `tracked` entry from `.gitignore`. Removing `.git` is not sufficient because YADM respects any `.gitignore` file it encounters.
|
||||
|
||||
### Committing & Pushing
|
||||
|
||||
To automatically add and commit your tracking targets, use `autoyadm.sh`:
|
||||
|
@ -113,7 +111,7 @@ $ systemctl start cronie
|
|||
|
||||
## Feature Roadmap
|
||||
|
||||
- [ ] Allow custom `tracked` file location & name
|
||||
- [x] Allow custom `tracked` file location & name
|
||||
- [ ] Optionally allow symlinks only if they are explicitly added to tracking
|
||||
|
||||
## Contributing
|
||||
|
|
19
autoyadm.sh
19
autoyadm.sh
|
@ -7,8 +7,21 @@
|
|||
|
||||
AYE="AutoYADM Error:"
|
||||
AYM="AutoYADM:"
|
||||
# We get the absolute path to the script's parent directory.
|
||||
AUTOYADMDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
function get_tracked_file {
|
||||
if [ -e "$XDG_CONFIG_HOME" ]; then
|
||||
if [ ! -f "$XDG_CONFIG_HOME/yadm/tracked" ]; then
|
||||
mkdir -p "$XDG_CONFIG_HOME/yadm"
|
||||
touch "$XDG_CONFIG_HOME/yadm/tracked"
|
||||
fi
|
||||
echo "$XDG_CONFIG_HOME/yadm/tracked"
|
||||
elif [ -f "$HOME/.config/yadm/tracked" ]; then
|
||||
echo "$HOME/.config/yadm/tracked"
|
||||
else
|
||||
echo "$AYM Please move your tracked file to ~/.config/yadm/tracked."
|
||||
echo "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/tracked"
|
||||
fi
|
||||
}
|
||||
|
||||
# We check not to overwrite the user's env setting
|
||||
if [ -z "$AUTOYADMPUSH" ] || ((!AUTOYADMPUSH)); then
|
||||
|
@ -38,7 +51,7 @@ fi
|
|||
echo "$AYE Target $path must be a directory or a file!"
|
||||
exit 1
|
||||
fi
|
||||
done) <"$AUTOYADMDIR/tracked"
|
||||
done) <"$(get_tracked_file)"
|
||||
|
||||
# Now we also stage files already tracked by YADM
|
||||
# that have been renamed or deleted; since the above
|
||||
|
|
18
yadmadd.sh
18
yadmadd.sh
|
@ -4,8 +4,20 @@
|
|||
# arguments and appends them to the "tracked"
|
||||
# file, for use by autoyadm.sh
|
||||
|
||||
# We get the absolute path to the script's parent directory.
|
||||
AUTOYADMDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
function get_tracked_file {
|
||||
if [ -e "$XDG_CONFIG_HOME" ]; then
|
||||
if [ ! -f "$XDG_CONFIG_HOME/yadm/tracked" ]; then
|
||||
mkdir -p "$XDG_CONFIG_HOME/yadm"
|
||||
touch "$XDG_CONFIG_HOME/yadm/tracked"
|
||||
fi
|
||||
echo "$XDG_CONFIG_HOME/yadm/tracked"
|
||||
elif [ -f "$HOME/.config/yadm/tracked" ]; then
|
||||
echo "$HOME/.config/yadm/tracked"
|
||||
else
|
||||
echo "$AYM Please move your tracked file to ~/.config/yadm/tracked."
|
||||
echo "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/tracked"
|
||||
fi
|
||||
}
|
||||
|
||||
AYE="AutoYADM Error:"
|
||||
AYM="AutoYADM:"
|
||||
|
@ -35,7 +47,7 @@ for arg in "$@"; do
|
|||
# convert to path relative to ~
|
||||
rel=${abs#"$HOME/"}
|
||||
# append to tracked file
|
||||
echo "$rel" >>"$AUTOYADMDIR/tracked"
|
||||
echo "$rel" >>"$(get_tracked_file)"
|
||||
echo "$AYM Tracking $HOME/$rel as '$rel'"
|
||||
else
|
||||
echo "$AYM Path must be inside the home directory."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue