Extract zsh functions to standalone bash script files

This commit is contained in:
Evie Litherland-Smith 2024-01-14 14:38:22 +00:00
parent ad894d1236
commit 9ccaee7f5e
3 changed files with 35 additions and 0 deletions

8
home/scripts/git-sync-all.sh Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
for DIRECTORY in $HOME/.nixos $HOME/.emacs $HOME/.password-store $HOME/.elfeed $HOME/Documents/Org $HOME/Documents/References; do
echo "--- $DIRECTORY ---"
mkdir -p $DIRECTORY
cd $DIRECTORY && git-sync
cd -
done

View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
HOST=$1
for TARGET in bat git starship.toml; do
SOURCE="$HOME/.config/$TARGET"
TMP_TARGET=/tmp/rsync-local-config
TMP_SOURCE=$TMP_TARGET
NIX_SED="sed -i 's|/nix/.*/bin/||g'"
NIX_REPLACE="$NIX_SED $TMP_TARGET"
if [[ -e $SOURCE ]]; then
if [[ -d $SOURCE ]]; then
SOURCE=$SOURCE/
TMP_SOURCE=$TMP_SOURCE/
NIX_REPLACE="fd -g '**' $TMP_TARGET -tfile -x $NIX_SED {};"
fi
rsync -avzL --exclude=".git*" $SOURCE $TMP_TARGET
chmod u+rw -R $TMP_SOURCE
sh -c "$NIX_REPLACE"
rsync -avzL --delete --exclude=".git*" $TMP_SOURCE $HOST:.config/$TARGET
rm -rf $TMP_SOURCE
fi
done

View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
FILETYPE=$(xdg-mime query filetype $@)
DEFAULT=$(xdg-mime query default $FILETYPE)
echo "$FILETYPE -> $DEFAULT"