From bacd72f4b43d445304314fe8ba153f298a19ca2c Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 12 Jun 2017 01:21:12 +0200 Subject: [PATCH] more linting --- bash_profile | 1 + bin/install.sh | 46 ++++++++++++++-------------------------- bin/sync-cloud.sh | 8 +++---- bin/tor.sh | 11 +++------- bin/update-dotfiles.sh | 2 +- bin/update-everything.sh | 41 +++++++++++++++-------------------- bin/updaterepos.sh | 34 +++++++++++------------------ 7 files changed, 54 insertions(+), 89 deletions(-) diff --git a/bash_profile b/bash_profile index 57cce7f..4ff65af 100644 --- a/bash_profile +++ b/bash_profile @@ -63,6 +63,7 @@ PROMPT_DIRTRIM=4 if which brew &> /dev/null && [ -f "$(brew --prefix)/share/bash-completion/bash_completion" ]; then source "$(brew --prefix)/share/bash-completion/bash_completion"; elif [ -f /etc/bash_completion ]; then + # shellcheck disable=SC1091 source /etc/bash_completion; fi; diff --git a/bin/install.sh b/bin/install.sh index 9e59e6b..d962c4e 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -14,7 +14,7 @@ set e # ---------------------------------------------------------------------- # dotfiles directory -cd ../ +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" @@ -45,52 +45,38 @@ source ~/.bash_profile # Homebrew # ---------------------------------------------------------------------- -"$(tput setaf 136)" -echo " Brewing all the things. " -echo "=============================================" -"$(tput sgr0)" # reset +echo "$(tput setaf 136) Brewing all the things. " +echo "=============================================$(tput sgr0)" +"" # reset bin/install-brew.sh -"$(tput setaf 64)" # green -echo "---------------------------------------------" -echo " ✓ done" -"$(tput sgr0)" # reset - +echo "$(tput setaf 64)---------------------------------------------" +echo " ✓ done$(tput sgr0)" # ---------------------------------------------------------------------- # npm # ---------------------------------------------------------------------- -"$(tput setaf 136)" -echo " npm all the things. " -echo "=============================================" -"$(tput sgr0)" # reset +echo "$(tput setaf 136) npm all the things. " +echo "=============================================$(tput sgr0)" bin/install-npm.sh -"$(tput setaf 64)" # green -echo "---------------------------------------------" -echo " ✓ done" -"$(tput sgr0)" # reset +echo "$(tput setaf 64)---------------------------------------------" +echo " ✓ done$(tput sgr0)" # ---------------------------------------------------------------------- # Ruby # ---------------------------------------------------------------------- -"$(tput setaf 136)" -echo " Ruby all the things. " -echo "=============================================" -"$(tput sgr0)" # reset +echo "$(tput setaf 136) Ruby all the things. " +echo "=============================================$(tput sgr0)" bin/install-ruby.sh -"$(tput setaf 64)" # green -echo "---------------------------------------------" -echo " ✓ done" -"$(tput sgr0)" # reset +echo "$(tput setaf 64)---------------------------------------------" +echo " ✓ done$(tput sgr0)" -"$(tput setaf 64)" # green -echo "=============================================" +echo "$(tput setaf 64)=============================================" echo " ✓ all done" -echo "=============================================" -"$(tput sgr0)" # reset +echo "=============================================$(tput sgr0)" diff --git a/bin/sync-cloud.sh b/bin/sync-cloud.sh index a3b9ff7..84b1f27 100755 --- a/bin/sync-cloud.sh +++ b/bin/sync-cloud.sh @@ -15,13 +15,13 @@ DEFAULTS_AMAZON='--exclude .DS_Store' # Sync up Movies -rclone sync $MOVIES_DIR amazon:/Movies $DEFAULTS_AMAZON +rclone sync "$MOVIES_DIR" amazon:/Movies "$DEFAULTS_AMAZON" # Sync up TV Shows -rclone sync "$TVSHOWS_DIR" amazon:"/TV Shows" $DEFAULTS_AMAZON +rclone sync "$TVSHOWS_DIR" amazon:"/TV Shows" "$DEFAULTS_AMAZON" # Sync up iTunes -rclone sync $ITUNES_DIR amazon:/Music/iTunes $DEFAULTS_AMAZON +rclone sync "$ITUNES_DIR" amazon:/Music/iTunes "$DEFAULTS_AMAZON" # Sync down all S3 buckets -rclone sync s3: $S3BACKUP_DIR +#rclone sync s3: $S3BACKUP_DIR diff --git a/bin/tor.sh b/bin/tor.sh index 37da4b1..fb570fc 100755 --- a/bin/tor.sh +++ b/bin/tor.sh @@ -22,9 +22,7 @@ while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & # trap ctrl-c and call disable_proxy() function disable_proxy() { sudo networksetup -setsocksfirewallproxystate $INTERFACE off - echo "$(tput setaf 64)" #green - echo "SOCKS proxy disabled." - echo "$(tput sgr0)" # color reset + echo "$(tput setaf 64)SOCKS proxy disabled.$(tput sgr0)" } trap disable_proxy INT @@ -32,10 +30,7 @@ trap disable_proxy INT sudo networksetup -setsocksfirewallproxy $INTERFACE 127.0.0.1 9050 off sudo networksetup -setsocksfirewallproxystate $INTERFACE on -echo "$(tput setaf 64)" # green -echo "SOCKS proxy 127.0.0.1:9050 enabled." -echo "$(tput setaf 136)" # orange -echo "Starting Tor..." -echo "$(tput sgr0)" # color reset +echo "$(tput setaf 64)SOCKS proxy 127.0.0.1:9050 enabled." +echo "$(tput setaf 136)Starting Tor...$(tput sgr0)" tor diff --git a/bin/update-dotfiles.sh b/bin/update-dotfiles.sh index 1ebcb2b..ddf4ca8 100755 --- a/bin/update-dotfiles.sh +++ b/bin/update-dotfiles.sh @@ -12,7 +12,7 @@ # ---------------------------------------------------------------------- # dotfiles directory -cd ../ +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" diff --git a/bin/update-everything.sh b/bin/update-everything.sh index 58f0786..aa86edf 100755 --- a/bin/update-everything.sh +++ b/bin/update-everything.sh @@ -5,10 +5,9 @@ # macOS # ------------- -"$(tput setaf 136)" -echo "Update macOS Apps " -echo "------------------------------" -"$(tput sgr0)" # reset +echo "$(tput setaf 136) + Update macOS Apps" +echo "------------------------------$(tput sgr0)" #sudo softwareupdate -i -a @@ -18,10 +17,9 @@ mas upgrade # Homebrew # ------------- -"$(tput setaf 136)" -echo "Update Homebrew " -echo "------------------------------" -"$(tput sgr0)" # reset +echo "$(tput setaf 136) + Update Homebrew" +echo "------------------------------$(tput sgr0)" brew update brew upgrade @@ -32,10 +30,8 @@ brew cleanup # npm # ------------- -"$(tput setaf 136)" -echo "Update npm " -echo "------------------------------" -"$(tput sgr0)" # reset +echo "$(tput setaf 136) Update npm" +echo "------------------------------$(tput sgr0)" # update npm itself npm install npm -g @@ -47,10 +43,9 @@ npm update -g # Ruby # ------------- -"$(tput setaf 136)" -echo "Update rvm " -echo "------------------------------" -"$(tput sgr0)" # reset +echo "$(tput setaf 136) + Update rvm" +echo "------------------------------$(tput sgr0)" # update rvm itself rvm get stable @@ -66,14 +61,12 @@ rvm cleanup all # GPG # ------------- -"$(tput setaf 136)" -echo "Refresh GPG keys " -echo "------------------------------" -"$(tput sgr0)" # reset +echo "$(tput setaf 136) + Refresh GPG keys" +echo "------------------------------$(tput sgr0)" gpg --refresh-keys -"$(tput setaf 64)" # green -echo "-------------------------------" -echo " ✓ all done" -"$(tput sgr0)" # reset +echo "$(tput setaf 64) + -------------------------------" +echo " ✓ all done$(tput sgr0)" diff --git a/bin/updaterepos.sh b/bin/updaterepos.sh index f3db6e5..d99e26d 100755 --- a/bin/updaterepos.sh +++ b/bin/updaterepos.sh @@ -13,39 +13,33 @@ updateRepo() { local dir="$1" local original_dir="$2" - cd "$dir" # switch to the git repo + cd "$dir" || return # switch to the git repo repo_url=$(git config --get remote.origin.url) echo "$(tput setaf 136)Updating Repo: $dir with url: $repo_url$(tput sgr0)" main_branch="master" if [ "$repo_url" == "git@someserver:repo/repo.git" ]; then # if you have a repo where the primary branch isnt master - $main_branch="trunk" + main_branch="trunk" fi # update the repo, then stash any local changes - echo "$(tput setaf 240)" # gray - echo "calling: git fetch --all && git stash" - echo "$(tput sgr0)" # color reset + echo "$(tput setaf 240)calling: git fetch --all && git stash$(tput sgr0)" (git fetch --all && git stash) current_branch=$(git rev-parse --abbrev-ref HEAD) # switch to master/trunk branch and rebase it, then switch back to original branch - if [ $current_branch != $main_branch ]; then - echo "$(tput setaf 240)" # gray - echo "calling: git checkout $main_branch && git rebase && git checkout $current_branch" - echo "$(tput sgr0)" # color reset - (git checkout $main_branch && git rebase && git checkout $current_branch) + if [ "$current_branch" != $main_branch ]; then + echo "$(tput setaf 240)calling: git checkout $main_branch && git rebase && git checkout $current_branch $(tput sgr0)" + (git checkout $main_branch && git rebase && git checkout "$current_branch") fi # rebase the original branch and then stash pop back to original state - echo "$(tput setaf 240)" # gray - echo "calling: git rebase && git stash pop on branch: $current_branch" - echo "$(tput sgr0)" # color reset + echo "$(tput setaf 240)calling: git rebase && git stash pop on branch: $current_branch $(tput sgr0)" (git rebase && git stash pop ) # switch back to the starting directory - cd $original_dir + cd "$original_dir" || return echo "" } @@ -56,17 +50,13 @@ if [ -z "$directory_to_update" ] ; then directory_to_update=$PWD fi -echo "$(tput setaf 240)" -echo "Updating git repos in directory: $directory_to_update" -echo "$(tput sgr0)" +echo "$(tput setaf 240)Updating git repos in directory: $directory_to_update $(tput sgr0)" count=0 -for dir in $(find $directory_to_update -maxdepth 4 -type d -name .git | xargs -n 1 dirname); do - updateRepo $dir $directory_to_update +for dir in $(find "$directory_to_update" -maxdepth 4 -type d -name .git | xargs -n 1 dirname); do + updateRepo "$dir" "$directory_to_update" ((count+=1)) done -echo "$(tput setaf 76)" # green -echo "✓ $count local git repos have been updated!" -echo "$(tput sgr0)" # color reset \ No newline at end of file +echo "$(tput setaf 76)✓ $count local git repos have been updated!$(tput sgr0)"