AutoYADM commit: 2024-11-10 00:34:11
This commit is contained in:
parent
7f706ba05c
commit
4fb68f0552
7 changed files with 293 additions and 0 deletions
37
.config/yadm/yadmadd.sh
Executable file
37
.config/yadm/yadmadd.sh
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script takes file or directories as
|
||||
# arguments and appends them to the "tracked"
|
||||
# file, for use by autoyadm.sh
|
||||
|
||||
YADMDIR="$HOME/.config/yadm"
|
||||
AYE="AutoYADM Error:"
|
||||
AYM="AutoYADM:"
|
||||
|
||||
# We check if any arguments have been provided
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "$AYE $0 <file_or_directory> [<file_or_directory> ...]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# We loop through arguments
|
||||
for arg in "$@"; do
|
||||
# check if current arg is a real path
|
||||
if [ ! -e "$arg" ]; then
|
||||
echo "$AYE '$arg' is not a valid path."
|
||||
continue
|
||||
fi
|
||||
# get its absolute path
|
||||
abs=$(realpath "$arg")
|
||||
# check if it's inside home dir
|
||||
if [[ "$abs" == "$HOME"* ]]; then
|
||||
# convert to path relative to ~
|
||||
rel=${abs#"$HOME/"}
|
||||
# append to tracked file
|
||||
echo "$HOME/$rel" >>"$YADMDIR/tracked"
|
||||
echo "$AYM Tracking $HOME/$rel"
|
||||
else
|
||||
echo "$AYM Path must be inside the home directory."
|
||||
exit 1
|
||||
fi
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue