From 9ccaee7f5efb4496db24be210685952a79ea8ba7 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Sun, 14 Jan 2024 14:38:22 +0000 Subject: [PATCH] Extract zsh functions to standalone bash script files --- home/scripts/git-sync-all.sh | 8 ++++++++ home/scripts/rsync-local-config.sh | 22 ++++++++++++++++++++++ home/scripts/xdg-query-program.sh | 5 +++++ 3 files changed, 35 insertions(+) create mode 100755 home/scripts/git-sync-all.sh create mode 100755 home/scripts/rsync-local-config.sh create mode 100755 home/scripts/xdg-query-program.sh diff --git a/home/scripts/git-sync-all.sh b/home/scripts/git-sync-all.sh new file mode 100755 index 00000000..fd9e5171 --- /dev/null +++ b/home/scripts/git-sync-all.sh @@ -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 diff --git a/home/scripts/rsync-local-config.sh b/home/scripts/rsync-local-config.sh new file mode 100755 index 00000000..877e33fd --- /dev/null +++ b/home/scripts/rsync-local-config.sh @@ -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 diff --git a/home/scripts/xdg-query-program.sh b/home/scripts/xdg-query-program.sh new file mode 100755 index 00000000..1444de5c --- /dev/null +++ b/home/scripts/xdg-query-program.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +FILETYPE=$(xdg-mime query filetype $@) +DEFAULT=$(xdg-mime query default $FILETYPE) +echo "$FILETYPE -> $DEFAULT"