From a90bb8e21707fe469efaea572d68f1d64b490c12 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Thu, 12 Jan 2023 11:55:57 +0000 Subject: [PATCH] Reuse common commands in functions --- install.sh | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 84a9ba76..867a76f3 100755 --- a/install.sh +++ b/install.sh @@ -1,23 +1,51 @@ #! /usr/bin/env sh # Install various dotfiles into their proper places +create_symlink () { + FILENAME="$(basename $FILE)" + if [ ! -e "$1/$FILENAME" ] + then + ln -s $(readlink -f "$2") "$1/$FILENAME" + echo "$(readlink -f $2) -> $1/$FILENAME" + else + echo "$1/$FILENAME already exists" + fi +} + +git_clone_if_missing () { + if [ ! -d $2 ] + then + git clone --depth 1 $1 $2 + else + echo "$1 already checked out -> $2" + fi +} + # .config files CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}" mkdir -p "$CONFIG_DIR" for FILE in config/*; do - FILENAME="$(basename $FILE)" - if [ ! -e "$CONFIG_DIR/$FILENAME" ] - then - ln -s $(readlink -f "$FILE") "$CONFIG_DIR/$FILENAME" - echo "$(readlink -f $FILE) -> $CONFIG_DIR/$FILENAME" - else - echo "$CONFIG_DIR/$FILENAME already exists" - fi + create_symlink $CONFIG_DIR $FILE done +# Install arch packages +sudo pacman --needed -S $(awk '{print $1}' pacman.txt) || echo "Issue install pacman packages" + # nvim setup - install Packer +PACKER_REPO="https://github.com/wbthomason/packer.nvim" PACKER_DIR="$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim" -if [ ! -d $PACKER_DIR ]; then - git clone --depth 1 https://github.com/wbthomason/packer.nvim $PACKER_DIR +git_clone_if_missing $PACKER_REPO $PACKER_DIR + +# oh-my-zsh links (if available) +OHMYZSH_DIR="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}" +if [ -d $OHMYZSH_DIR ] +then + # Powerlevel10k theme + POWERLEVEL_REPO="https://github.com/romkatv/powerlevel10k.git" + POWERLEVEL_DIR="$OHMYZSH_DIR/themes/powerlevel10k" + git_clone_if_missing $POWERLEVEL_REPO $POWERLEVEL_DIR + # git clone --depth=1 ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k + # aliases + create_symlink $OHMYZSH_DIR "./aliases.zsh" fi