Refactor a few things

This commit is contained in:
david pickle 2025-01-12 14:30:08 -06:00
parent 1340729f50
commit 7cda3112e0
6 changed files with 16 additions and 37 deletions

View File

@ -4,23 +4,15 @@ dry="0"
execute() {
log "execute $@"
if [[ $dry != "1" ]]; then
"$@"
fi
[[ $dry != "1" ]] && "$@"
}
log() {
if [[ $dry != "1" ]]; then
echo "$@"
else
echo "[DRY RUN]: $@"
fi
[[ $dry != "1" ]] && echo "$@" || echo "[DRY RUN]: $@"
}
while [[ $# > 0 ]]; do
if [[ $1 == "--dry" ]]; then
dry="1"
fi
[[ $1 == "--dry" ]] && dry="1"
shift
done
@ -31,11 +23,8 @@ copy_dir() {
to=$2
pushd $from > /dev/null
dirs=(`find . -mindepth 1 -maxdepth 1 -type d`)
echo $dirs
for dir in $dirs; do
if [[ -d $to/$dir ]]; then
execute rm -rf $to/$dir
fi
[[ -d $to/$dir ]] && execute rm -rf $to/$dir
execute cp -rp $dir $to/$dir
done
popd > /dev/null
@ -45,11 +34,10 @@ copy_file() {
from=$1
to=$2
filename=$(basename $from)
if [[ -e $to/$filename ]]; then
execute rm $to/$filename
fi
[[ -e $to/$filename ]] && execute rm $to/$filename
execute cp -p $from $to/$filename
}
copy_dir .config $HOME/.config
copy_dir .local $HOME/.local
# copy_file .zxcv $HOME

View File

@ -1,5 +1,5 @@
#!/bin/zsh
if [[ ! -d $HOME/bin ]]; then
mkdir $HOME/bin
fi
[[ ! -d $HOME/bin ]] && mkdir $HOME/bin
[[ ! -d $HOME/.config ]] && mkdir $HOME/.config
[[ ! -d $HOME/.local ]] && mkdir $HOME/.local

16
run
View File

@ -5,25 +5,15 @@ dry="0"
execute() {
log "execute $@"
if [[ $dry != "1" ]]; then
"$@"
fi
[[ $dry != "1" ]] && "$@"
}
log() {
if [[ $dry != "1" ]]; then
echo "$@"
else
echo "[DRY RUN]: $@"
fi
[[ $dry != "1" ]] && echo "$@" || echo "[DRY RUN]: $@"
}
while [[ $# > 0 ]]; do
if [[ $1 == "--dry" ]]; then
dry="1"
else
single_script_filter="$1"
fi
[[ $1 == "--dry" ]] && dry="1" || single_script_filter="$1"
shift
done

View File

@ -1,3 +0,0 @@
#!/bin/zsh
brew install git tmux

2
runs/git Executable file
View File

@ -0,0 +1,2 @@
#!/bin/zsh
brew install git

2
runs/tmux Executable file
View File

@ -0,0 +1,2 @@
#!/bin/zsh
brew install tmux