Skip to content

Commit

Permalink
Fix install script
Browse files Browse the repository at this point in the history
  • Loading branch information
szajbus committed Aug 23, 2021
1 parent 6abb5b4 commit 3b7fb3f
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions install.sh
@@ -1,22 +1,18 @@
#!/bin/sh
#!/bin/bash
# Usage:
# install.sh

function ask {
local answer=false

echo -n " ${argv[1]} (y/N): "
read -sq && local answer=true
$answer && echo yes || echo no
$answer && return 0
read -p " $1 (y/N) " -n 1 -r
[[ $REPLY =~ ^[Yy]$ ]] && return 0
}

function install-dotfiles {
local src="${HOME}/dotfiles/${argv[1]}"
local dest="${HOME}/${argv[2]}"
local src="${HOME}/dotfiles/$1"
local dest="${HOME}/$2"
local secrets=false

[[ $argv[1] == 'secrets' ]] && local secrets=true
[[ $1 == 'secrets' ]] && local secrets=true

if $secrets; then
[[ ! -e $dest ]] && cp $src $dest
Expand All @@ -26,26 +22,26 @@ function install-dotfiles {
fi

[[ -d $src ]] && local slash='/'
echo "+ ${argv[1]}${slash}"
echo "+ $1${slash}"
}

function execute-script {
local script="${HOME}/dotfiles/install/${argv[1]}"
local script="${HOME}/dotfiles/install/$1"
`${script} > /dev/null 2>&1`
echo "+ ${argv[1]}"
echo "+ $1"
}

function ask-execute-script {
ask "install ${argv[1]}?" && execute-script $argv[1]
ask "install $1?" && execute-script $1
}

function group {
echo "[${argv[1]}]"
echo "[$1]"
}

function copy-files {
cp -f ${HOME}/dotfiles/${argv[1]}/* ${argv[2]}
echo "+ ${argv[1]}"
cp -f ${HOME}/dotfiles/$1/* $2
echo "+ $1"
}

local backup=false
Expand Down Expand Up @@ -96,7 +92,7 @@ if [[ $(uname) == "Darwin" ]]; then
ask-execute-script osx-defaults
ask-execute-script spotlight-reindex
copy-files fonts ~/Library/fonts
else;
else
group linux
install-dotfiles hushlogin .hushlogin
fi

0 comments on commit 3b7fb3f

Please sign in to comment.