From 1faaa176b78e098ad33b8b0a9279ea5e884450a6 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sun, 10 Sep 2017 14:40:28 +0200 Subject: [PATCH] renaming & refactor --- aliases => bash_aliases | 0 exports => bash_exports | 0 bash_profile | 7 ++++--- bashrc | 1 + bin/install.sh | 35 +++++++++++++++++++---------------- bin/update-dotfiles.sh | 39 +++++++++++++-------------------------- 6 files changed, 37 insertions(+), 45 deletions(-) rename aliases => bash_aliases (100%) rename exports => bash_exports (100%) diff --git a/aliases b/bash_aliases similarity index 100% rename from aliases rename to bash_aliases diff --git a/exports b/bash_exports similarity index 100% rename from exports rename to bash_exports diff --git a/bash_profile b/bash_profile index 4ff65af..b0aea9e 100644 --- a/bash_profile +++ b/bash_profile @@ -9,15 +9,16 @@ # https://github.com/rtomayko/dotfiles ######################################################################## +# shellcheck source=/dev/null # ---------------------------------------------------------------------- # Load ~/.private, ~/.bash_prompt # ---------------------------------------------------------------------- -for file in ~/.{exports,private,bash_paths,bash_prompt,aliases,inputrc}; do - [ -r "$file" ] && [ -f "$file" ] && source "$file" +for FILE in ~/.{bash_exports,bash_paths,bash_prompt,bash_aliases,private,inputrc}; do + [ -r "$FILE" ] && [ -f "$FILE" ] && source "$FILE" done; -unset file; +unset FILE; # ---------------------------------------------------------------------- # SHELL OPTIONS diff --git a/bashrc b/bashrc index 29828ea..bab09c8 100644 --- a/bashrc +++ b/bashrc @@ -1,3 +1,4 @@ #!/usr/bin/env bash +# shellcheck source=/dev/null [ -n "$PS1" ] && source ~/.bash_profile; diff --git a/bin/install.sh b/bin/install.sh index d962c4e..c46e886 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -9,15 +9,8 @@ set e -# ---------------------------------------------------------------------- -# Variables -# ---------------------------------------------------------------------- - -# dotfiles directory -cd ../ || exit - # list of files/folders to symlink in homedir -files="aliases bashrc bash_profile bash_paths bash_prompt exports gemrc gitconfig gitignore hushlogin inputrc private npmrc bin tmux.conf" +FILES="bash_aliases bashrc bash_profile bash_paths bash_prompt bash_exports gemrc gitconfig gitignore hushlogin inputrc private npmrc bin tmux.conf" # ---------------------------------------------------------------------- # create the private file first, will be symlinked but ignored by git @@ -27,19 +20,29 @@ touch private # ---------------------------------------------------------------------- # create symlinks from the homedir to any files in the dotfiles directory -# specified in $files +# specified in $FILES # ---------------------------------------------------------------------- -for file in $files; do - ln -s "$file" ~/."$file" - echo "$(tput setaf 64)✓$(tput sgr0) Created symlink to $(tput setaf 37)$file$(tput sgr0)" +for FILE in $FILES; do + + # remove old symlinks if present + if [ -h "$HOME/.$FILE" ]; then + rm "$HOME/.$FILE" + echo "$(tput setaf 64)✓$(tput sgr0) Removed old symlink to $(tput setaf 37)$FILE$(tput sgr0)" + fi + + # symlink files + ln -s "$PWD/$FILE" "$HOME/.$FILE" + echo "$(tput setaf 64)✓$(tput sgr0) Created new symlink to $(tput setaf 37)$FILE$(tput sgr0)" + done # ---------------------------------------------------------------------- # source what we just created # ---------------------------------------------------------------------- -source ~/.bash_profile +# shellcheck source=/dev/null +source "$HOME/.bash_profile" # ---------------------------------------------------------------------- # Homebrew @@ -49,7 +52,7 @@ echo "$(tput setaf 136) Brewing all the things. " echo "=============================================$(tput sgr0)" "" # reset -bin/install-brew.sh +./bin/install-brew.sh echo "$(tput setaf 64)---------------------------------------------" echo " ✓ done$(tput sgr0)" @@ -60,7 +63,7 @@ echo " ✓ done$(tput sgr0)" echo "$(tput setaf 136) npm all the things. " echo "=============================================$(tput sgr0)" -bin/install-npm.sh +./bin/install-npm.sh echo "$(tput setaf 64)---------------------------------------------" echo " ✓ done$(tput sgr0)" @@ -72,7 +75,7 @@ echo " ✓ done$(tput sgr0)" echo "$(tput setaf 136) Ruby all the things. " echo "=============================================$(tput sgr0)" -bin/install-ruby.sh +./bin/install-ruby.sh echo "$(tput setaf 64)---------------------------------------------" echo " ✓ done$(tput sgr0)" diff --git a/bin/update-dotfiles.sh b/bin/update-dotfiles.sh index ddf4ca8..d7a8e9b 100755 --- a/bin/update-dotfiles.sh +++ b/bin/update-dotfiles.sh @@ -7,41 +7,28 @@ # https://github.com/michaeljsmalley/dotfiles/blob/master/makesymlinks.sh ######################################################################## -# ---------------------------------------------------------------------- -# Variables -# ---------------------------------------------------------------------- - -# dotfiles directory -cd ../ || exit - # list of files/folders to symlink in homedir -files="aliases bashrc bash_profile bash_paths bash_prompt editorconfig exports gemrc gitconfig gitignore hushlogin inputrc private npmrc bin tmux.conf" +FILES="bash_aliases bashrc bash_profile bash_paths bash_prompt bash_exports editorconfig gemrc gitconfig gitignore hushlogin inputrc private npmrc bin tmux.conf" +for FILE in $FILES; do -# ---------------------------------------------------------------------- -# delete existing dotfiles in ~ -# ---------------------------------------------------------------------- + # remove old symlinks if present + if [ -h "$HOME/.$FILE" ]; then + rm "$HOME/.$FILE" + echo "$(tput setaf 64)✓$(tput sgr0) Removed old symlink to $(tput setaf 37)$FILE$(tput sgr0)" + fi + + # symlink files + ln -s "$PWD/$FILE" "$HOME/.$FILE" + echo "$(tput setaf 64)✓$(tput sgr0) Created new symlink to $(tput setaf 37)$FILE$(tput sgr0)" -for file in $files; do - rm ~/."$file" done - -# ---------------------------------------------------------------------- -# create symlinks from the homedir to any files in the ~/dotfiles directory -# specified in $files -# ---------------------------------------------------------------------- - -for file in $files; do - ln -s "$file" ~/."$file" - echo "$(tput setaf 64)✓$(tput sgr0) Created symlink to $(tput setaf 37)$file$(tput sgr0)" -done - - # ---------------------------------------------------------------------- # source what we just created # ---------------------------------------------------------------------- -source ~/.bash_profile +# shellcheck source=/dev/null +source "$HOME/.bash_profile" exit