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

View File

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

16
run
View File

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