From f8d09c5cfd6d1d9595b64547dc9d29c63e40c5f2 Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Thu, 5 Dec 2024 13:49:22 -0500 Subject: Moved .local/bin to scripts --- util | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 util (limited to 'util') diff --git a/util b/util new file mode 100755 index 0000000..4b0dff2 --- /dev/null +++ b/util @@ -0,0 +1,41 @@ +#!/bin/zsh + +set -o shwordsplit + +log() { + if [[ $dry == "1" ]]; then + echo "[DRY_RUN]: $1" + else + echo "$1" + fi +} + +execute() { + log "execute $@" + if [[ $dry == "1" ]]; then + return + fi + "$@" +} + +copy_dir() { + from=$1 + to=$2 + pushd $from + dirs="$(find . -maxdepth 1 -mindepth 1 -type d)" + for dir in $dirs; do + execute rm -rf $to/$dir + execute cp -r $dir $to/$dir + done + popd +} + +copy_file() { + from=$1 + to=$2 + name=$(basename $from) + + execute rm $to/$name + execute cp $from $to/$name +} + -- cgit v1.2.3