Skip to content

Commit

Permalink
Run all the shell/scripts files through shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoglan committed Oct 9, 2020
1 parent c1d9b2b commit b99b965
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
4 changes: 2 additions & 2 deletions scripts/up
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ while [ "$1" != "--" ]; do
done

shift
run_command="$@ &"
run_command="$*"
last_hash=""
up_pid=0

Expand All @@ -24,7 +24,7 @@ up-checksum() {
}

up-start-process() {
eval "$run_command"
eval "$run_command &"
up_pid=$!
}

Expand Down
5 changes: 3 additions & 2 deletions shell/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ alias d=docker
alias dc=docker-compose

tm() {
tmux new -s "$(basename $PWD)"
tmux new -s "$(basename "$PWD")"
}

alias deflate="ruby -r zlib -e 'STDOUT.write Zlib::Deflate.deflate(STDIN.read)'"
Expand All @@ -28,7 +28,8 @@ hash pbcopy 2>/dev/null || {
}

if [[ -f /usr/libexec/java_home ]] ; then
export JAVA_HOME="$(/usr/libexec/java_home)"
JAVA_HOME="$(/usr/libexec/java_home)"
export JAVA_HOME
fi

alias curl-xhr="curl -H 'X-Requested-With: XMLHttpRequest'"
Expand Down
5 changes: 3 additions & 2 deletions shell/homebrew
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

hash brew 2>/dev/null && {
if [[ -f "$(brew --prefix)/etc/bash_completion" ]] ; then
# shellcheck source=/dev/null
. "$(brew --prefix)/etc/bash_completion"
fi
}
Expand All @@ -26,8 +27,8 @@ bru-leaves() {
}

bru-check-deps() {
while read pkg ; do
egrep -q "$@" -e "^(brew|cask) '$pkg'" || echo "$pkg"
while read -r pkg ; do
grep -Eq "$@" -e "^(brew|cask) '$pkg'" || echo "$pkg"
done
}

Expand Down
17 changes: 9 additions & 8 deletions shell/node
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ alias ne='npm run-script'
export NVM_DIR='/opt/nvm'
NVM_SCRIPT='/usr/local/opt/nvm/nvm.sh'

if [[ -f "$NVM_SCRIPT" ]]; then
if [[ -f "$NVM_SCRIPT" ]] ; then
# shellcheck source=/dev/null
. "$NVM_SCRIPT"
fi

nvm use default

get-nvm-version() {
local version="$(echo "$NVM_BIN" | cut -d / -f 4)"
local version
version="$(echo "$NVM_BIN" | cut -d / -f 4)"

if [[ "$version" == "versions" ]] ; then
echo -n 'node-'
echo "$NVM_BIN" | cut -d / -f 6
Expand All @@ -27,18 +30,16 @@ nvm-old-versions() {
grep '^v' |
sort |
uniq |
while read v ; do
nvm ls "$v" | sed '$ d'
done
while read -r v ; do nvm ls "$v" | sed '$ d' ; done
}

npm-run() {
for task in $@; do
npm run $task
if [[ $? -ne 0 ]] ; then
for task in "$@" ; do
if ! npm run "$task" ; then
exit 1
fi
done
}

# shellcheck source=/dev/null
hash vault 2> /dev/null && . "$( vault --initpath )"
16 changes: 8 additions & 8 deletions shell/prompt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ get-git-branch() {
echo "[$ref]"
}

RED='\e[0;31m'
GREEN='\e[0;32m'
YELLOW='\e[0;33m'
BLUE='\e[1;34m'
BLACK='\e[0;30m'
WHITE='\e[0;37m'
DEFAULT_COLOR='\e[0;39m'
export COL_RED='\e[0;31m'
export COL_GREEN='\e[0;32m'
export COL_YELLOW='\e[0;33m'
export COL_BLUE='\e[1;34m'
export COL_BLACK='\e[0;30m'
export COL_WHITE='\e[0;37m'
export COL_DEFAULT='\e[0;39m'

PS1="$RED(\$(get-nvm-version),\$(get-chruby-version)) $BLUE\w $YELLOW\$(get-git-branch) $DEFAULT_COLOR\n$ "
PS1="$COL_RED(\$(get-nvm-version),\$(get-chruby-version)) $COL_BLUE\w $COL_YELLOW\$(get-git-branch) $COL_DEFAULT\n$ "

# Make Vim et al use the full color palette
if [[ "$COLORTERM" == 'gnome-terminal' ]] ; then
Expand Down
3 changes: 2 additions & 1 deletion shell/ruby
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ alias gem-uninstall='gem list | cut -d " " -f 1 | xargs gem uninstall -Iax'
CHRUBY_SCRIPT='/usr/local/share/chruby/chruby.sh'

if [[ -f "$CHRUBY_SCRIPT" ]] ; then
# shellcheck source=/dev/null
. "$CHRUBY_SCRIPT"
fi

get-chruby-version() {
chruby | grep '*' | cut -d ' ' -f 3
chruby | grep '\*' | cut -d ' ' -f 3
}
6 changes: 3 additions & 3 deletions shell/util
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ follow-redirect() {
}

remove-trailing-lines() {
sed -e :a -e '/^\n*$/{$d;N;}' -e '/\n$/ba' $1 > $1.sed-tmp
chmod --reference $1 $1.sed-tmp
mv $1.sed-tmp $1
sed -e :a -e '/^\n*$/{$d;N;}' -e '/\n$/ba' "$1" > "$1.sed-tmp"
chmod --reference "$1" "$1.sed-tmp"
mv "$1.sed-tmp" "$1"
}

0 comments on commit b99b965

Please sign in to comment.