Refactor a few things
This commit is contained in:
parent
1340729f50
commit
7cda3112e0
@ -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
|
@ -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
16
run
@ -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
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
brew install git tmux
|
Loading…
Reference in New Issue
Block a user