Refactoring and pretty printing of information
This commit is contained in:
parent
99c7cc50a8
commit
f0f2988423
@ -1,14 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ${DOTFILES}/helpers.sh
|
||||
|
||||
function main()
|
||||
{
|
||||
if [ ! -d "${HOME}/mnt" ]; then
|
||||
mkdir "${HOME}/mnt"
|
||||
mkdir "${HOME}/mnt/music"
|
||||
mkdir "${HOME}/mnt/photos"
|
||||
mkdir "${HOME}/mnt/video"
|
||||
mkdir "${HOME}/mnt/NAS"
|
||||
fi
|
||||
print_info "Setting up user homedir mounts"
|
||||
|
||||
makedir "${HOME}/mnt"
|
||||
makedir "${HOME}/mnt/music"
|
||||
makedir "${HOME}/mnt/photo"
|
||||
makedir "${HOME}/mnt/video"
|
||||
makedir "${HOME}/mnt/NAS"
|
||||
|
||||
|
||||
local auto_file="auto_nas_$(whoami)"
|
||||
@ -73,6 +75,8 @@ function main()
|
||||
|
||||
sudo launchctl load "${plistloc}"
|
||||
fi
|
||||
|
||||
print_ok "User homedir mounts set up"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
@ -1,11 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ${DOTFILES}/helpers.sh
|
||||
|
||||
function main()
|
||||
{
|
||||
print_info "Installing fish shell"
|
||||
|
||||
# Install fish shell
|
||||
if ! brew list | grep fish >/dev/null; then
|
||||
brew install fish
|
||||
fi
|
||||
brewget fish
|
||||
|
||||
# Add to list of shells and set as default
|
||||
if ! grep /usr/local/bin/fish < /etc/shells >/dev/null; then
|
||||
@ -14,13 +16,11 @@ function main()
|
||||
fi
|
||||
|
||||
# Install configuration files
|
||||
if [ ! -d ${HOME}/.config ]; then
|
||||
mkdir ${HOME}/.config
|
||||
fi
|
||||
if [ ! -e ${HOME}/.config/fish ]; then
|
||||
rm -rf ${HOME}/.config/fish
|
||||
ln -s ${DOTFILES}/fish ${HOME}/.config/.
|
||||
fi
|
||||
makedir ${HOME}/.config
|
||||
|
||||
linkfile ${DOTFILES}/fish ${HOME}/.config/fish
|
||||
|
||||
print_ok "Fish shell installed"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
10
git/setup.sh
10
git/setup.sh
@ -1,10 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ${DOTFILES}/helpers.sh
|
||||
|
||||
function main()
|
||||
{
|
||||
if ! brew list | grep git >/dev/null; then
|
||||
brew install git
|
||||
fi
|
||||
print_info "Configuring git"
|
||||
|
||||
brewget git
|
||||
|
||||
if [ ! -f "${HOME}/.gitconfig" ]; then
|
||||
cat << EOF > ${HOME}/.gitconfig
|
||||
@ -14,6 +16,8 @@ function main()
|
||||
excludesfile = ${DOTFILES}/git/gitignore_global
|
||||
EOF
|
||||
fi
|
||||
|
||||
print_ok "Git configured"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
55
helpers.sh
Normal file
55
helpers.sh
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
function print_info() {
|
||||
echo -e "[\\033[36mINFO\\033[0m] $@"
|
||||
}
|
||||
function print_ok() {
|
||||
echo -e "[\\033[32mOK\\033[0m] $@"
|
||||
}
|
||||
function print_warning() {
|
||||
echo -e "[\\033[33mWARNING\\033[0m] $@"
|
||||
}
|
||||
function print_error() {
|
||||
echo -e "[\\033[32mERROR\\033[0m] $@"
|
||||
}
|
||||
|
||||
function brewget()
|
||||
{
|
||||
# Install software using homebrew
|
||||
# if not already installed
|
||||
local brewname=$(basename $1)
|
||||
|
||||
if ! brew list | grep ${brewname} >/dev/null; then
|
||||
print_info "Brewing ${brewname}"
|
||||
brew install "$@"
|
||||
fi
|
||||
}
|
||||
function caskget()
|
||||
{
|
||||
# Install OSX application using homebrew cask
|
||||
# if not already installed
|
||||
local caskname=$(basename $1)
|
||||
|
||||
if ! brew cask list | grep ${caskname} >/dev/null; then
|
||||
print_info "Installing ${caskname} from cask"
|
||||
brew cask install "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function linkfile()
|
||||
{
|
||||
local source=$1
|
||||
local target=$2
|
||||
|
||||
if [ ! -e ${target} ]; then
|
||||
print_info "Symlinking ${source} <- ${target}"
|
||||
rm -rf ${target}
|
||||
ln -s ${source} ${target}
|
||||
fi
|
||||
}
|
||||
function makedir()
|
||||
{
|
||||
if [ ! -d $@ ]; then
|
||||
print_info "Making directory $@"
|
||||
mkdir $@
|
||||
fi
|
||||
}
|
14
install.sh
14
install.sh
@ -15,6 +15,7 @@ function install_homebrew()
|
||||
|
||||
}
|
||||
|
||||
|
||||
function install_casks()
|
||||
{
|
||||
brew cask install google-chrome
|
||||
@ -39,10 +40,11 @@ function setup_kitty()
|
||||
}
|
||||
|
||||
|
||||
export DOTFILES=/Users/thomas/dotfiles
|
||||
DOTFILES=/Users/thomas/dotfiles
|
||||
DOTFILES="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
|
||||
|
||||
ssh/setup.sh
|
||||
git/setup.sh
|
||||
NAS_mounts/setup.sh
|
||||
fish/setup.sh
|
||||
wm/setup.sh
|
||||
${DOTFILES}/ssh/setup.sh
|
||||
${DOTFILES}/git/setup.sh
|
||||
${DOTFILES}/NAS_mounts/setup.sh
|
||||
${DOTFILES}/fish/setup.sh
|
||||
${DOTFILES}/wm/setup.sh
|
||||
|
10
ssh/setup.sh
10
ssh/setup.sh
@ -1,15 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ${DOTFILES}/helpers.sh
|
||||
|
||||
function main()
|
||||
{
|
||||
print_info "Setting up SSH"
|
||||
# copy private key to .ssh
|
||||
# cp ${KEYFILE} ~/.ssh/thomas_rsa
|
||||
# chmod 400 ~/.ssh/thomas_rsa
|
||||
# ssh-add -K ~/.ssh/thomas_rsa
|
||||
if [ ! -e ${HOME}/.ssh/config ]; then
|
||||
rm -f ${HOME}/.ssh/config
|
||||
ln -s ${DOTFILES}/ssh/config ${HOME}/.ssh/config
|
||||
fi
|
||||
linkfile ${DOTFILES}/ssh/config ${HOME}/.ssh/config
|
||||
|
||||
print_ok "SSH settings installed"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
19
wm/setup.sh
19
wm/setup.sh
@ -1,26 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ${DOTFILES}/helpers.sh
|
||||
|
||||
function main()
|
||||
{
|
||||
print_info "Installing window manager"
|
||||
# Install chunkwm and khd
|
||||
if ! brew list | grep chunkwm >/dev/null; then
|
||||
brew install crisidev/homebrew-chunkwm/chunkwm
|
||||
brew install koekeishiya/formulae/khd
|
||||
fi
|
||||
brewget crisidev/homebrew-chunkwm/chunkwm
|
||||
brewget keokeishiya/formulae/khd
|
||||
|
||||
# Link configuration files
|
||||
if [ ! -e "${HOME}/.chunkwmrc" ]; then
|
||||
rm -f "${HOME}/.chunkwmrc"
|
||||
rm -f "${HOME}/.khdrc"
|
||||
ln -s ${DOTFILES}/wm/khdrc ${HOME}/.khdrc
|
||||
ln -s ${DOTFILES}/wm/chunkwmrc ${HOME}/.chunkwmrc
|
||||
fi
|
||||
linkfile ${DOTFILES}/wm/khdrc ${HOME}/.khdrc
|
||||
linkfile ${DOTFILES}/wm/chunkwmrc ${HOME}/.chunkwmrc
|
||||
|
||||
# Start services
|
||||
if ! brew services list | grep chunkwm >/dev/null; then
|
||||
brew services start khd
|
||||
brew services start chunkwm
|
||||
fi
|
||||
|
||||
print_ok "Window manager installed and activated"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
Loading…
x
Reference in New Issue
Block a user