mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 02:06:39 +00:00
Format shell scripts with shfmt
This commit is contained in:
@@ -5,7 +5,6 @@ set -e
|
||||
PACKAGE_LIST_CMD="brew cask list"
|
||||
PACKAGE_INSTALL_CMD="brew cask install"
|
||||
|
||||
|
||||
#
|
||||
# Package list
|
||||
#
|
||||
@@ -136,7 +135,6 @@ PERSONAL_PKGS=(
|
||||
yakyak
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Main
|
||||
#
|
||||
@@ -155,7 +153,6 @@ main() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# The rest...
|
||||
#
|
||||
|
||||
@@ -5,7 +5,6 @@ set -e
|
||||
PACKAGE_LIST_CMD="brew list"
|
||||
PACKAGE_INSTALL_CMD="brew install"
|
||||
|
||||
|
||||
#
|
||||
# Package list
|
||||
#
|
||||
@@ -63,7 +62,6 @@ PERSONAL_PKGS=(
|
||||
"mkvtoolnix --with-qt"
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Main
|
||||
#
|
||||
@@ -78,7 +76,6 @@ main() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# The rest...
|
||||
#
|
||||
|
||||
@@ -31,11 +31,10 @@ if [ -d "$app_path" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Various paths used when creating the app.
|
||||
resource_dir="${app_path}/Contents/Resources"
|
||||
exec_dir="${app_path}/Contents/MacOS"
|
||||
exec_file="${exec_dir}/${name//[[:space:]]}"
|
||||
exec_file="${exec_dir}/${name//[[:space:]]/}"
|
||||
plist_file="${app_path}/Contents/Info.plist"
|
||||
|
||||
app_support="\${HOME}/Library/Application Support"
|
||||
|
||||
@@ -97,8 +97,8 @@ main () {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Restoring volume ${volume} from: ${archive_file}"
|
||||
docker volume create "$volname"
|
||||
echo "Restoring volume ${volname} from: ${archive_file}"
|
||||
docker volume create "${volname}"
|
||||
docker run --rm \
|
||||
--volume "${volname}:/target" \
|
||||
--volume "${archive_dir}:/source" \
|
||||
|
||||
@@ -15,10 +15,9 @@ if [ -f "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" ]; then
|
||||
EMACSCLIENT="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient"
|
||||
fi
|
||||
|
||||
|
||||
# Functions
|
||||
start() {
|
||||
EMACS_GUI_SERVER=1 env $EMACS \
|
||||
EMACS_GUI_SERVER=1 env "$EMACS" \
|
||||
--eval "(setq server-socket-dir \"$SOCKET_DIR\")" --daemon
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
# content, at your own risk of course :) --jimeh
|
||||
#
|
||||
|
||||
|
||||
padlen=13
|
||||
ipaddress=$1
|
||||
ipaddress="$1"
|
||||
|
||||
if [[ "$1" == "--raw" ]] || [[ "$1" == "-r" ]]; then
|
||||
padlen=0
|
||||
@@ -29,7 +28,7 @@ case "$1" in
|
||||
echo "address is given, your own public IP will be used instead."
|
||||
;;
|
||||
*)
|
||||
curl -s "http://www.geoiptool.com/en/?IP=${ipaddress}" -H "User-Agent: " | \
|
||||
curl -s "http://www.geoiptool.com/en/?IP=${ipaddress}" -H "User-Agent: " |
|
||||
awk -F '(</?[^>]+>)+' \
|
||||
"/Host Name/,/Latitude/ {
|
||||
if (/:/) {
|
||||
|
||||
@@ -10,7 +10,7 @@ main() {
|
||||
commits="$(git rev-list "$ref")"
|
||||
|
||||
for commit in $commits; do
|
||||
files="$(git diff-tree --no-commit-id --name-only -r $commit)"
|
||||
files="$(git diff-tree --no-commit-id --name-only -r "$commit")"
|
||||
for file in $files; do
|
||||
echo "${commit}: $file"
|
||||
done
|
||||
|
||||
44
bin/hr
44
bin/hr
@@ -4,43 +4,39 @@
|
||||
#
|
||||
# Copyright (c) 2013 Gil Gonçalves
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
# the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
|
||||
function hr {
|
||||
for i in $(seq 1 $(tput cols));
|
||||
do
|
||||
echo -n "$1";
|
||||
function hr() {
|
||||
for i in $(seq 1 "$(tput cols)"); do
|
||||
echo -n "$1"
|
||||
done
|
||||
|
||||
echo ""
|
||||
}
|
||||
|
||||
if [[ -n "$1" ]]; then
|
||||
space_string="$1"
|
||||
string_size="${#space_string}"
|
||||
|
||||
if [[ -n $1 ]]; then
|
||||
space_string=$1
|
||||
string_size=${#space_string};
|
||||
|
||||
for char_index in $(seq 0 $(expr ${string_size} - 1));
|
||||
do
|
||||
hr ${space_string:char_index:1}
|
||||
for char_index in $(seq 0 "$(expr "${string_size}" - 1)"); do
|
||||
hr "${space_string:char_index:1}"
|
||||
done
|
||||
else
|
||||
hr "="
|
||||
fi
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# Parse confx files and generate the conf files.
|
||||
for file in $HOME/.logrotate.d/*.confx; do
|
||||
content="$(eval "echo \"$(cat "$file")\"")"
|
||||
echo "$content" > ${file/%.confx/.conf}
|
||||
echo "$content" > "${file/%.confx/.conf}"
|
||||
done
|
||||
|
||||
# Run logrorate like normal against conf files.
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
if [ -z $1 ]; then
|
||||
if [ -z "$1" ]; then
|
||||
echo "usage: smart-health-check <device>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
trim() {
|
||||
local string="$@"
|
||||
local string="$*"
|
||||
string="${string#"${string%%[![:space:]]*}"}"
|
||||
string="${string%"${string##*[![:space:]]}"}"
|
||||
echo -n "$string"
|
||||
}
|
||||
|
||||
check-status() {
|
||||
local raw_status="$(smartctl -H $1)"
|
||||
local status="$(echo "$raw_status" | grep "^SMART overall-health")"
|
||||
local device="$1"
|
||||
local raw_status
|
||||
local status
|
||||
|
||||
raw_status="$(smartctl -H "$device")"
|
||||
status="$(echo "$raw_status" | grep "^SMART overall-health")"
|
||||
|
||||
if [[ "$(trim "$status")" != *"PASSED" ]]; then
|
||||
echo "$(tput setaf 1)SMART Status: FAIL:$(tput sgr0)" \
|
||||
"smartctl -H $1:"
|
||||
"smartctl -H ${device}:"
|
||||
echo ""
|
||||
echo "$raw_status"
|
||||
exit 3
|
||||
@@ -26,23 +30,27 @@ check-status() {
|
||||
}
|
||||
|
||||
check-attributes() {
|
||||
local device="$1"
|
||||
local attr
|
||||
local fail=0
|
||||
local raw_status="$(smartctl -A $1)"
|
||||
local report="$(echo "$raw_status" | grep "^ID# ")"
|
||||
local raw_status
|
||||
local report
|
||||
|
||||
raw_status="$(smartctl -A "$device")"
|
||||
report="$(echo "$raw_status" | grep "^ID# ")"
|
||||
|
||||
for id in 1 5 10 196 197 198; do
|
||||
attr="$(echo "$raw_status" | grep "^\s*${id}\s")"
|
||||
if [ -n "$(trim "$attr")" ] && [[ "$(trim "$attr")" != *" 0" ]]; then
|
||||
fail=1
|
||||
report="$report\n$attr"
|
||||
report="${report}\n${attr}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $fail != 0 ]; then
|
||||
echo "$(tput setaf 2)SMART Status: PASSED:$(tput sgr0)" \
|
||||
"$(tput setaf 1)- may FAIL soon:$(tput sgr0)" \
|
||||
"smartctl -A $1:"
|
||||
"smartctl -A ${device}:"
|
||||
echo ""
|
||||
echo -e "$report"
|
||||
exit 2
|
||||
@@ -50,10 +58,11 @@ check-attributes() {
|
||||
}
|
||||
|
||||
main() {
|
||||
check-status $1
|
||||
check-attributes $1
|
||||
local device="$1"
|
||||
|
||||
check-status "$device"
|
||||
check-attributes "$device"
|
||||
echo "SMART Status: $(tput setaf 2)PASSED$(tput sgr0)"
|
||||
}
|
||||
|
||||
|
||||
main $@
|
||||
|
||||
@@ -50,8 +50,8 @@ main() {
|
||||
formulas_list="$(printf '%s\n' "${formulas[@]}" | sort)"
|
||||
|
||||
count="$(
|
||||
comm -13 <(echo "$pinned_list") <(echo "$formulas_list") \
|
||||
| grep -c '[^[:space:]]'
|
||||
comm -13 <(echo "$pinned_list") <(echo "$formulas_list") |
|
||||
grep -c '[^[:space:]]'
|
||||
)"
|
||||
|
||||
echo ":beer:↑${count} | dropdown=false"
|
||||
|
||||
@@ -36,7 +36,6 @@ SYMLINKS=(
|
||||
zshrc
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Initial Setup
|
||||
#
|
||||
@@ -50,7 +49,6 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Main Functions
|
||||
#
|
||||
@@ -102,7 +100,6 @@ install_emacs_config() {
|
||||
git_clone 'git@github.com:jimeh/.emacs.d.git' "$TARGET/.emacs.d"
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Helper functions
|
||||
#
|
||||
@@ -139,7 +136,6 @@ git_clone () {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Argument Handling
|
||||
#
|
||||
|
||||
@@ -3,7 +3,7 @@ set -e
|
||||
|
||||
PREFIX="/opt/emacs"
|
||||
|
||||
help() {
|
||||
show-help() {
|
||||
echo "usage: ./install-emacs.sh <VERSION>"
|
||||
}
|
||||
|
||||
@@ -24,17 +24,31 @@ install() {
|
||||
deps() {
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
build-essential libx11-dev xaw3dg-dev libjpeg-dev libpng12-dev \
|
||||
libgif-dev libtiff4-dev libncurses5-dev libxft-dev librsvg2-dev \
|
||||
libmagickcore-dev libmagick++-dev libxml2-dev libgpm-dev \
|
||||
libghc-gconf-dev libotf-dev libm17n-dev libgnutls-dev
|
||||
build-essential \
|
||||
libghc-gconf-dev \
|
||||
libgif-dev \
|
||||
libgnutls-dev \
|
||||
libgpm-dev \
|
||||
libjpeg-dev \
|
||||
libm17n-dev \
|
||||
libmagick++-dev \
|
||||
libmagickcore-dev \
|
||||
libncurses5-dev \
|
||||
libotf-dev \
|
||||
libpng12-dev \
|
||||
librsvg2-dev \
|
||||
libtiff4-dev \
|
||||
libx11-dev \
|
||||
libxft-dev \
|
||||
libxml2-dev \
|
||||
xaw3dg-dev
|
||||
}
|
||||
|
||||
main() {
|
||||
local command="$1"
|
||||
|
||||
if [ -z "$command" ]; then
|
||||
echo "$(help)" 1>&2
|
||||
show-help 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -45,4 +59,4 @@ main() {
|
||||
fi
|
||||
}
|
||||
|
||||
main $@
|
||||
main "$@"
|
||||
|
||||
@@ -3,7 +3,7 @@ set -e
|
||||
|
||||
PREFIX="/opt/tmux"
|
||||
|
||||
help() {
|
||||
show-help() {
|
||||
echo "usage: ./install-tmux.sh <VERSION>"
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ main() {
|
||||
local command="$1"
|
||||
|
||||
if [ -z "$command" ]; then
|
||||
echo "$(help)" 1>&2
|
||||
show-help 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -45,4 +45,4 @@ main() {
|
||||
fi
|
||||
}
|
||||
|
||||
main $@
|
||||
main "$@"
|
||||
|
||||
@@ -3,7 +3,7 @@ set -e
|
||||
|
||||
PREFIX="/opt/zsh"
|
||||
|
||||
help() {
|
||||
show-help() {
|
||||
echo "usage: ./install-zsh.sh <VERSION>"
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ main() {
|
||||
local command="$1"
|
||||
|
||||
if [ -z "$command" ]; then
|
||||
echo "$(help)" 1>&2
|
||||
show-help 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ authmeo() {
|
||||
# Make and cd into directory
|
||||
# - from: http://alias.sh/make-and-cd-directory
|
||||
mcd() {
|
||||
mkdir -p "$1" && cd "$1";
|
||||
mkdir -p "$1" && cd "$1"
|
||||
}
|
||||
|
||||
# Extract most common archives with single command.
|
||||
|
||||
@@ -68,6 +68,7 @@ if command-exists rbenv; then
|
||||
unset -f load-rbenv _rbenv rbenv
|
||||
eval "$(command rbenv init -)"
|
||||
}
|
||||
fi
|
||||
|
||||
rbenv-each-version() {
|
||||
local current_version="$RBENV_VERSION"
|
||||
@@ -80,7 +81,6 @@ if command-exists rbenv; then
|
||||
|
||||
export RBENV_VERSION="$current_version"
|
||||
}
|
||||
fi
|
||||
|
||||
# Solargraph related commands
|
||||
|
||||
|
||||
15
zshenv
15
zshenv
@@ -10,6 +10,10 @@ fi
|
||||
# Ensure compinit is NOT loaded before Zinit loads in ~/zshrc.
|
||||
skip_global_compinit=1
|
||||
|
||||
# ==============================================================================
|
||||
# PATH Setup
|
||||
# ==============================================================================
|
||||
|
||||
# Ensure values in path variable are unique
|
||||
typeset -U path
|
||||
|
||||
@@ -22,16 +26,19 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
|
||||
# Setup default PATH just like /etc/zprofile does
|
||||
if [ -x "/usr/libexec/path_helper" ]; then
|
||||
eval `/usr/libexec/path_helper -s`
|
||||
eval $(/usr/libexec/path_helper -s)
|
||||
fi
|
||||
|
||||
# Load /etc/zshenv if it exists
|
||||
if [ -f "/etc/zshenv" ]; then
|
||||
source "/etc/zshenv";
|
||||
source "/etc/zshenv"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Path helpers
|
||||
# ==============================================================================
|
||||
# PATH Helpers
|
||||
# ==============================================================================
|
||||
|
||||
path_list () {
|
||||
print -l "${(@)path}"
|
||||
}
|
||||
@@ -52,7 +59,6 @@ path_prepend () {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# System Environment Setup
|
||||
# ==============================================================================
|
||||
@@ -89,7 +95,6 @@ path_prepend "$DOTBIN"
|
||||
# Add user's bin directory to PATH
|
||||
path_prepend "$HOME/bin"
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Private Dotfiles Environment
|
||||
# ==============================================================================
|
||||
|
||||
11
zshrc
11
zshrc
@@ -27,9 +27,10 @@ ZINIT[HOME_DIR]="$HOME/.local/zsh/zinit"
|
||||
ZINIT[BIN_DIR]="${ZINIT[HOME_DIR]}/bin"
|
||||
|
||||
# Ask to clone Zinit if it's not already available on disk.
|
||||
[ ! -d "${ZINIT[BIN_DIR]}" ] && \
|
||||
read -q "REPLY?Zinit not installed, clone to ${ZINIT[BIN_DIR]}? [y/N]:" && \
|
||||
echo && git clone "https://github.com/zdharma/zinit.git" "${ZINIT[BIN_DIR]}"
|
||||
[ ! -d "${ZINIT[BIN_DIR]}" ] &&
|
||||
read -q "REPLY?Zinit not installed, clone to ${ZINIT[BIN_DIR]}? [y/N]:" &&
|
||||
echo &&
|
||||
git clone --depth=1 "https://github.com/zdharma/zinit.git" "${ZINIT[BIN_DIR]}"
|
||||
|
||||
# Load Zinit
|
||||
source "${ZINIT[BIN_DIR]}/zinit.zsh"
|
||||
@@ -64,7 +65,6 @@ zinit light zsh-users/zsh-completions
|
||||
zinit ice wait lucid atload"!_zsh_autosuggest_start"
|
||||
zinit light zsh-users/zsh-autosuggestions
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Private Dotfiles
|
||||
# ==============================================================================
|
||||
@@ -73,7 +73,6 @@ if [ -f "$DOTPFILES/zshrc" ]; then
|
||||
source "$DOTPFILES/zshrc"
|
||||
fi
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Tool specific setup
|
||||
# ==============================================================================
|
||||
@@ -101,7 +100,6 @@ source "$DOTZSH/python.zsh"
|
||||
source "$DOTZSH/ruby.zsh"
|
||||
source "$DOTZSH/rust.zsh"
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Basic Z-Shell settings
|
||||
# ==============================================================================
|
||||
@@ -115,7 +113,6 @@ unsetopt share_history
|
||||
# Disable attempted correction of commands (is wrong 98% of the time).
|
||||
unsetopt correctall
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Local Overrides
|
||||
# ==============================================================================
|
||||
|
||||
Reference in New Issue
Block a user