mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 09:46:42 +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_LIST_CMD="brew cask list"
|
||||||
PACKAGE_INSTALL_CMD="brew cask install"
|
PACKAGE_INSTALL_CMD="brew cask install"
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Package list
|
# Package list
|
||||||
#
|
#
|
||||||
@@ -136,7 +135,6 @@ PERSONAL_PKGS=(
|
|||||||
yakyak
|
yakyak
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Main
|
# Main
|
||||||
#
|
#
|
||||||
@@ -155,7 +153,6 @@ main() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# The rest...
|
# The rest...
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ set -e
|
|||||||
PACKAGE_LIST_CMD="brew list"
|
PACKAGE_LIST_CMD="brew list"
|
||||||
PACKAGE_INSTALL_CMD="brew install"
|
PACKAGE_INSTALL_CMD="brew install"
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Package list
|
# Package list
|
||||||
#
|
#
|
||||||
@@ -63,7 +62,6 @@ PERSONAL_PKGS=(
|
|||||||
"mkvtoolnix --with-qt"
|
"mkvtoolnix --with-qt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Main
|
# Main
|
||||||
#
|
#
|
||||||
@@ -78,7 +76,6 @@ main() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# The rest...
|
# The rest...
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ icon="$3"
|
|||||||
|
|
||||||
if [ -z "$name" ] || [ -z "$url" ]; then
|
if [ -z "$name" ] || [ -z "$url" ]; then
|
||||||
echo 'usage: create-chrome-ssb "Google Music"' \
|
echo 'usage: create-chrome-ssb "Google Music"' \
|
||||||
'"https://play.google.com/music"'
|
'"https://play.google.com/music"'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -31,11 +31,10 @@ if [ -d "$app_path" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Various paths used when creating the app.
|
# Various paths used when creating the app.
|
||||||
resource_dir="${app_path}/Contents/Resources"
|
resource_dir="${app_path}/Contents/Resources"
|
||||||
exec_dir="${app_path}/Contents/MacOS"
|
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"
|
plist_file="${app_path}/Contents/Info.plist"
|
||||||
|
|
||||||
app_support="\${HOME}/Library/Application Support"
|
app_support="\${HOME}/Library/Application Support"
|
||||||
@@ -46,10 +45,10 @@ bundle_identifier="me.jimeh.chrome-ssb.${name}"
|
|||||||
mkdir -p "$resource_dir" "$exec_dir"
|
mkdir -p "$resource_dir" "$exec_dir"
|
||||||
|
|
||||||
# convert the icon and copy into Resources
|
# convert the icon and copy into Resources
|
||||||
if [ -f "$icon" ] ; then
|
if [ -f "$icon" ]; then
|
||||||
sips -s format tiff "$icon" \
|
sips -s format tiff "$icon" \
|
||||||
--out "${resource_dir}/icon.tiff" \
|
--out "${resource_dir}/icon.tiff" \
|
||||||
--resampleWidth 128 >& /dev/null
|
--resampleWidth 128 >&/dev/null
|
||||||
tiff2icns -noLarge "${resource_dir}/icon.tiff" >&/dev/null
|
tiff2icns -noLarge "${resource_dir}/icon.tiff" >&/dev/null
|
||||||
|
|
||||||
if [ -f "${resource_dir}/icon.tiff" ]; then
|
if [ -f "${resource_dir}/icon.tiff" ]; then
|
||||||
@@ -58,7 +57,7 @@ if [ -f "$icon" ] ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Create the executable.
|
# Create the executable.
|
||||||
cat > "$exec_file" <<EOF
|
cat > "$exec_file" << EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
mkdir -p "${profile_dir}"
|
mkdir -p "${profile_dir}"
|
||||||
exec "${chrome_path}" \\
|
exec "${chrome_path}" \\
|
||||||
@@ -70,7 +69,7 @@ EOF
|
|||||||
chmod +x "$exec_file"
|
chmod +x "$exec_file"
|
||||||
|
|
||||||
# Create the Info.plist.
|
# Create the Info.plist.
|
||||||
cat > "$plist_file" <<EOF
|
cat > "$plist_file" << EOF
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
|
||||||
<plist version=”1.0″>
|
<plist version=”1.0″>
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
abs_dirname () {
|
abs_dirname() {
|
||||||
local path="$1"
|
local path="$1"
|
||||||
local cwd
|
local cwd
|
||||||
cwd="$(pwd)"
|
cwd="$(pwd)"
|
||||||
|
|
||||||
while [ -n "$path" ]; do
|
while [ -n "$path" ]; do
|
||||||
cd "${path%/*}" 2>/dev/null
|
cd "${path%/*}" 2> /dev/null
|
||||||
local name="${path##*/}"
|
local name="${path##*/}"
|
||||||
path="$(resolve_link "$name" || true)"
|
path="$(resolve_link "$name" || true)"
|
||||||
done
|
done
|
||||||
@@ -16,16 +16,16 @@ abs_dirname () {
|
|||||||
cd "$cwd"
|
cd "$cwd"
|
||||||
}
|
}
|
||||||
|
|
||||||
abs_path () {
|
abs_path() {
|
||||||
local path="$1"
|
local path="$1"
|
||||||
echo "$(cd "$(abs_dirname "$path")" && pwd)/$(basename "$path")"
|
echo "$(cd "$(abs_dirname "$path")" && pwd)/$(basename "$path")"
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve_link () {
|
resolve_link() {
|
||||||
$(type -p greadlink readlink | head -1) "$1"
|
$(type -p greadlink readlink | head -1) "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve_dest () {
|
resolve_dest() {
|
||||||
local dest="$1"
|
local dest="$1"
|
||||||
|
|
||||||
if [ -z "$dest" ]; then
|
if [ -z "$dest" ]; then
|
||||||
@@ -42,7 +42,7 @@ resolve_dest () {
|
|||||||
echo "$dest"
|
echo "$dest"
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve_dest_dir () {
|
resolve_dest_dir() {
|
||||||
local dest="$1"
|
local dest="$1"
|
||||||
local dir
|
local dir
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ resolve_dest_dir () {
|
|||||||
echo "$dir"
|
echo "$dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
help () {
|
help() {
|
||||||
echo "usage: docker-volume-backup <volume> [<output-filename>]"
|
echo "usage: docker-volume-backup <volume> [<output-filename>]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Backs up contents of a Docker volume to a gzipped tar archive."
|
echo "Backs up contents of a Docker volume to a gzipped tar archive."
|
||||||
@@ -66,7 +66,7 @@ help () {
|
|||||||
echo " Defaults to: ./<volume>_<date>_<time>.tar.gz"
|
echo " Defaults to: ./<volume>_<date>_<time>.tar.gz"
|
||||||
}
|
}
|
||||||
|
|
||||||
main () {
|
main() {
|
||||||
local volname="$1"
|
local volname="$1"
|
||||||
local dest="$2"
|
local dest="$2"
|
||||||
local dest_dir
|
local dest_dir
|
||||||
@@ -76,7 +76,7 @@ main () {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! docker volume inspect "$volname" &>/dev/null; then
|
if ! docker volume inspect "$volname" &> /dev/null; then
|
||||||
echo "ERROR: Volume \"${volname}\" does not exist." 1>&2
|
echo "ERROR: Volume \"${volname}\" does not exist." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -87,10 +87,10 @@ main () {
|
|||||||
|
|
||||||
echo "Starting volume backup to: ${dest}"
|
echo "Starting volume backup to: ${dest}"
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
--volume "${volname}:/source/${volname}" \
|
--volume "${volname}:/source/${volname}" \
|
||||||
--volume "${dest_dir}:/target" \
|
--volume "${dest_dir}:/target" \
|
||||||
alpine:latest \
|
alpine:latest \
|
||||||
sh -c "cd /source && tar -cvzf \"/target/${dest_file}\" \"${volname}\""
|
sh -c "cd /source && tar -cvzf \"/target/${dest_file}\" \"${volname}\""
|
||||||
|
|
||||||
echo "Volume \"${volname}\" was backed up to: ${dest}"
|
echo "Volume \"${volname}\" was backed up to: ${dest}"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
abs_dirname () {
|
abs_dirname() {
|
||||||
local path="$1"
|
local path="$1"
|
||||||
local cwd
|
local cwd
|
||||||
cwd="$(pwd)"
|
cwd="$(pwd)"
|
||||||
|
|
||||||
while [ -n "$path" ]; do
|
while [ -n "$path" ]; do
|
||||||
cd "${path%/*}" 2>/dev/null
|
cd "${path%/*}" 2> /dev/null
|
||||||
local name="${path##*/}"
|
local name="${path##*/}"
|
||||||
path="$(resolve_link "$name" || true)"
|
path="$(resolve_link "$name" || true)"
|
||||||
done
|
done
|
||||||
@@ -16,12 +16,12 @@ abs_dirname () {
|
|||||||
cd "$cwd"
|
cd "$cwd"
|
||||||
}
|
}
|
||||||
|
|
||||||
abs_path () {
|
abs_path() {
|
||||||
local path="$1"
|
local path="$1"
|
||||||
echo "$(cd "$(abs_dirname "$path")" && pwd)/$(basename "$path")"
|
echo "$(cd "$(abs_dirname "$path")" && pwd)/$(basename "$path")"
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve_link () {
|
resolve_link() {
|
||||||
$(type -p greadlink readlink | head -1) "$1"
|
$(type -p greadlink readlink | head -1) "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ resolve_archive() {
|
|||||||
echo "$archive"
|
echo "$archive"
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve_volname () {
|
resolve_volname() {
|
||||||
local archive="$1"
|
local archive="$1"
|
||||||
local file
|
local file
|
||||||
local dir
|
local dir
|
||||||
@@ -47,13 +47,13 @@ resolve_volname () {
|
|||||||
dir="$(dirname "$archive")"
|
dir="$(dirname "$archive")"
|
||||||
|
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
--volume "${dir}:/source" \
|
--volume "${dir}:/source" \
|
||||||
alpine:latest \
|
alpine:latest \
|
||||||
sh -c "tar --exclude=\"*/*/*\" -tzf \"/source/${file}\" \
|
sh -c "tar --exclude=\"*/*/*\" -tzf \"/source/${file}\" \
|
||||||
| grep -v '^[^/]\+/[^/]\+$' | sed s'/.$//'" 2>/dev/null
|
| grep -v '^[^/]\+/[^/]\+$' | sed s'/.$//'" 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
help () {
|
help() {
|
||||||
echo "usage: docker-volume-restore <archive> [<volume-name>]"
|
echo "usage: docker-volume-restore <archive> [<volume-name>]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Restores contents from a *.tar.gz archive to a Docker volume."
|
echo "Restores contents from a *.tar.gz archive to a Docker volume."
|
||||||
@@ -66,7 +66,7 @@ help () {
|
|||||||
echo " top-level directory in the archive."
|
echo " top-level directory in the archive."
|
||||||
}
|
}
|
||||||
|
|
||||||
main () {
|
main() {
|
||||||
local archive="$1"
|
local archive="$1"
|
||||||
local volname="$2"
|
local volname="$2"
|
||||||
local archive_volname
|
local archive_volname
|
||||||
@@ -92,19 +92,19 @@ main () {
|
|||||||
volname="$archive_volname"
|
volname="$archive_volname"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if docker volume inspect "$volname" &>/dev/null; then
|
if docker volume inspect "$volname" &> /dev/null; then
|
||||||
echo "ERROR: Volume \"${volname}\" already exists." 1>&2
|
echo "ERROR: Volume \"${volname}\" already exists." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Restoring volume ${volume} from: ${archive_file}"
|
echo "Restoring volume ${volname} from: ${archive_file}"
|
||||||
docker volume create "$volname"
|
docker volume create "${volname}"
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
--volume "${volname}:/target" \
|
--volume "${volname}:/target" \
|
||||||
--volume "${archive_dir}:/source" \
|
--volume "${archive_dir}:/source" \
|
||||||
alpine:latest \
|
alpine:latest \
|
||||||
sh -c "cd /target && tar --strip-components=1 \
|
sh -c "cd /target && tar --strip-components=1 \
|
||||||
-xvzf \"/source/${archive_file}\""
|
-xvzf \"/source/${archive_file}\""
|
||||||
|
|
||||||
echo "Volume \"${volname}\" was restored from: ${archive_file}"
|
echo "Volume \"${volname}\" was restored from: ${archive_file}"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,20 +15,19 @@ if [ -f "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" ]; then
|
|||||||
EMACSCLIENT="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient"
|
EMACSCLIENT="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
start () {
|
start() {
|
||||||
EMACS_GUI_SERVER=1 env $EMACS \
|
EMACS_GUI_SERVER=1 env "$EMACS" \
|
||||||
--eval "(setq server-socket-dir \"$SOCKET_DIR\")" --daemon
|
--eval "(setq server-socket-dir \"$SOCKET_DIR\")" --daemon
|
||||||
}
|
}
|
||||||
|
|
||||||
stop () {
|
stop() {
|
||||||
env $EMACSCLIENT -s "$SOCKET_FILE" --eval "(kill-emacs)"
|
env $EMACSCLIENT -s "$SOCKET_FILE" --eval "(kill-emacs)"
|
||||||
}
|
}
|
||||||
|
|
||||||
status () {
|
status() {
|
||||||
echo -n 'Emacs GUI Server... '
|
echo -n 'Emacs GUI Server... '
|
||||||
! result="$(eval $EMACSCLIENT -s "$SOCKET_FILE" --eval \"\(print \'OK\)\" 2>/dev/null)"
|
! result="$(eval $EMACSCLIENT -s "$SOCKET_FILE" --eval \"\(print \'OK\)\" 2> /dev/null)"
|
||||||
if [[ $result == "OK" ]]; then
|
if [[ $result == "OK" ]]; then
|
||||||
echo 'RUNNING'
|
echo 'RUNNING'
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ fi
|
|||||||
|
|
||||||
# Execute emacsclient
|
# Execute emacsclient
|
||||||
exec env TERM=screen-24bit \
|
exec env TERM=screen-24bit \
|
||||||
$EMACSCLIENT --alternate-editor=$ALTERNATE_EDITOR "$@"
|
$EMACSCLIENT --alternate-editor=$ALTERNATE_EDITOR "$@"
|
||||||
|
|||||||
@@ -7,9 +7,8 @@
|
|||||||
# content, at your own risk of course :) --jimeh
|
# content, at your own risk of course :) --jimeh
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
padlen=13
|
padlen=13
|
||||||
ipaddress=$1
|
ipaddress="$1"
|
||||||
|
|
||||||
if [[ "$1" == "--raw" ]] || [[ "$1" == "-r" ]]; then
|
if [[ "$1" == "--raw" ]] || [[ "$1" == "-r" ]]; then
|
||||||
padlen=0
|
padlen=0
|
||||||
@@ -19,7 +18,7 @@ elif [[ "$2" == "--raw" ]] || [[ "$2" == "-r" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"-h" | "--help" )
|
"-h" | "--help")
|
||||||
echo "usage: geoiptool [<ipaddress>]"
|
echo "usage: geoiptool [<ipaddress>]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
@@ -28,8 +27,8 @@ case "$1" in
|
|||||||
echo "Look up details for given IP address via http://www.geoiptool.com/. If no IP"
|
echo "Look up details for given IP address via http://www.geoiptool.com/. If no IP"
|
||||||
echo "address is given, your own public IP will be used instead."
|
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 '(</?[^>]+>)+' \
|
awk -F '(</?[^>]+>)+' \
|
||||||
"/Host Name/,/Latitude/ {
|
"/Host Name/,/Latitude/ {
|
||||||
if (/:/) {
|
if (/:/) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ main() {
|
|||||||
commits="$(git rev-list "$ref")"
|
commits="$(git rev-list "$ref")"
|
||||||
|
|
||||||
for commit in $commits; do
|
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
|
for file in $files; do
|
||||||
echo "${commit}: $file"
|
echo "${commit}: $file"
|
||||||
done
|
done
|
||||||
|
|||||||
52
bin/hr
52
bin/hr
@@ -4,43 +4,39 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2013 Gil Gonçalves
|
# Copyright (c) 2013 Gil Gonçalves
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# this software and associated documentation files (the "Software"), to deal in
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
# the Software without restriction, including without limitation the rights to
|
# in the Software without restriction, including without limitation the rights
|
||||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
# the Software, and to permit persons to whom the Software is furnished to do so,
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
# subject to the following conditions:
|
# furnished to do so, subject to the following conditions:
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in all
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
# copies or substantial portions of the Software.
|
# copies or substantial portions of the Software.
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
# 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"
|
||||||
|
done
|
||||||
|
|
||||||
function hr {
|
echo ""
|
||||||
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
|
for char_index in $(seq 0 "$(expr "${string_size}" - 1)"); do
|
||||||
space_string=$1
|
hr "${space_string:char_index:1}"
|
||||||
string_size=${#space_string};
|
done
|
||||||
|
|
||||||
for char_index in $(seq 0 $(expr ${string_size} - 1));
|
|
||||||
do
|
|
||||||
hr ${space_string:char_index:1}
|
|
||||||
done
|
|
||||||
else
|
else
|
||||||
hr "="
|
hr "="
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -46,25 +46,25 @@ OPT_ALL=""
|
|||||||
parse-arguments() {
|
parse-arguments() {
|
||||||
while getopts ":p:e:w:bah" opt; do
|
while getopts ":p:e:w:bah" opt; do
|
||||||
case ${opt} in
|
case ${opt} in
|
||||||
p )
|
p)
|
||||||
OPT_PROC="$OPTARG"
|
OPT_PROC="$OPTARG"
|
||||||
;;
|
;;
|
||||||
e )
|
e)
|
||||||
OPT_BIN="$OPTARG"
|
OPT_BIN="$OPTARG"
|
||||||
;;
|
;;
|
||||||
w )
|
w)
|
||||||
OPT_WIN="$OPTARG"
|
OPT_WIN="$OPTARG"
|
||||||
;;
|
;;
|
||||||
b )
|
b)
|
||||||
OPT_BRING="1"
|
OPT_BRING="1"
|
||||||
;;
|
;;
|
||||||
a )
|
a)
|
||||||
OPT_ALL="1"
|
OPT_ALL="1"
|
||||||
;;
|
;;
|
||||||
h )
|
h)
|
||||||
show-help
|
show-help
|
||||||
;;
|
;;
|
||||||
\? )
|
\?)
|
||||||
error-help "Invalid option: -${OPTARG}\n" 1>&2
|
error-help "Invalid option: -${OPTARG}\n" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
@@ -81,7 +81,7 @@ parse-arguments() {
|
|||||||
OPT_BIN="$OPT_PROC"
|
OPT_BIN="$OPT_PROC"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v "$OPT_BIN" &>/dev/null; then
|
if ! command -v "$OPT_BIN" &> /dev/null; then
|
||||||
error "\"${OPT_BIN}\" does not seem to be a valid executable."
|
error "\"${OPT_BIN}\" does not seem to be a valid executable."
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# Parse confx files and generate the conf files.
|
# Parse confx files and generate the conf files.
|
||||||
for file in $HOME/.logrotate.d/*.confx; do
|
for file in $HOME/.logrotate.d/*.confx; do
|
||||||
content="$(eval "echo \"$(cat "$file")\"")"
|
content="$(eval "echo \"$(cat "$file")\"")"
|
||||||
echo "$content" > ${file/%.confx/.conf}
|
echo "$content" > "${file/%.confx/.conf}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Run logrorate like normal against conf files.
|
# Run logrorate like normal against conf files.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
if bundle check &>/dev/null && (bundle list | grep rubocop &>/dev/null); then
|
if bundle check &> /dev/null && (bundle list | grep rubocop &> /dev/null); then
|
||||||
exec bundle exec rubocop "$@"
|
exec bundle exec rubocop "$@"
|
||||||
else
|
else
|
||||||
exec rubocop "$@"
|
exec rubocop "$@"
|
||||||
|
|||||||
@@ -1,24 +1,28 @@
|
|||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
if [ -z $1 ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "usage: smart-health-check <device>"
|
echo "usage: smart-health-check <device>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
trim() {
|
trim() {
|
||||||
local string="$@"
|
local string="$*"
|
||||||
string="${string#"${string%%[![:space:]]*}"}"
|
string="${string#"${string%%[![:space:]]*}"}"
|
||||||
string="${string%"${string##*[![:space:]]}"}"
|
string="${string%"${string##*[![:space:]]}"}"
|
||||||
echo -n "$string"
|
echo -n "$string"
|
||||||
}
|
}
|
||||||
|
|
||||||
check-status() {
|
check-status() {
|
||||||
local raw_status="$(smartctl -H $1)"
|
local device="$1"
|
||||||
local status="$(echo "$raw_status" | grep "^SMART overall-health")"
|
local raw_status
|
||||||
|
local status
|
||||||
|
|
||||||
|
raw_status="$(smartctl -H "$device")"
|
||||||
|
status="$(echo "$raw_status" | grep "^SMART overall-health")"
|
||||||
|
|
||||||
if [[ "$(trim "$status")" != *"PASSED" ]]; then
|
if [[ "$(trim "$status")" != *"PASSED" ]]; then
|
||||||
echo "$(tput setaf 1)SMART Status: FAIL:$(tput sgr0)" \
|
echo "$(tput setaf 1)SMART Status: FAIL:$(tput sgr0)" \
|
||||||
"smartctl -H $1:"
|
"smartctl -H ${device}:"
|
||||||
echo ""
|
echo ""
|
||||||
echo "$raw_status"
|
echo "$raw_status"
|
||||||
exit 3
|
exit 3
|
||||||
@@ -26,23 +30,27 @@ check-status() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
check-attributes() {
|
check-attributes() {
|
||||||
|
local device="$1"
|
||||||
local attr
|
local attr
|
||||||
local fail=0
|
local fail=0
|
||||||
local raw_status="$(smartctl -A $1)"
|
local raw_status
|
||||||
local report="$(echo "$raw_status" | grep "^ID# ")"
|
local report
|
||||||
|
|
||||||
|
raw_status="$(smartctl -A "$device")"
|
||||||
|
report="$(echo "$raw_status" | grep "^ID# ")"
|
||||||
|
|
||||||
for id in 1 5 10 196 197 198; do
|
for id in 1 5 10 196 197 198; do
|
||||||
attr="$(echo "$raw_status" | grep "^\s*${id}\s")"
|
attr="$(echo "$raw_status" | grep "^\s*${id}\s")"
|
||||||
if [ -n "$(trim "$attr")" ] && [[ "$(trim "$attr")" != *" 0" ]]; then
|
if [ -n "$(trim "$attr")" ] && [[ "$(trim "$attr")" != *" 0" ]]; then
|
||||||
fail=1
|
fail=1
|
||||||
report="$report\n$attr"
|
report="${report}\n${attr}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $fail != 0 ]; then
|
if [ $fail != 0 ]; then
|
||||||
echo "$(tput setaf 2)SMART Status: PASSED:$(tput sgr0)" \
|
echo "$(tput setaf 2)SMART Status: PASSED:$(tput sgr0)" \
|
||||||
"$(tput setaf 1)- may FAIL soon:$(tput sgr0)" \
|
"$(tput setaf 1)- may FAIL soon:$(tput sgr0)" \
|
||||||
"smartctl -A $1:"
|
"smartctl -A ${device}:"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "$report"
|
echo -e "$report"
|
||||||
exit 2
|
exit 2
|
||||||
@@ -50,10 +58,11 @@ check-attributes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
check-status $1
|
local device="$1"
|
||||||
check-attributes $1
|
|
||||||
|
check-status "$device"
|
||||||
|
check-attributes "$device"
|
||||||
echo "SMART Status: $(tput setaf 2)PASSED$(tput sgr0)"
|
echo "SMART Status: $(tput setaf 2)PASSED$(tput sgr0)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
main $@
|
main $@
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
count=1
|
count=1
|
||||||
echo "====> Attempt $count"
|
echo "====> Attempt $count"
|
||||||
while "$@"; do
|
while "$@"; do
|
||||||
(( count++ ))
|
((count++))
|
||||||
echo "====> Attempt $count"
|
echo "====> Attempt $count"
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -41,15 +41,15 @@ main() {
|
|||||||
|
|
||||||
if [ "$count" -gt 0 ]; then
|
if [ "$count" -gt 0 ]; then
|
||||||
echo 'Upgrade all casks | terminal=true refresh=true' \
|
echo 'Upgrade all casks | terminal=true refresh=true' \
|
||||||
'bash=/usr/local/bin/brew param1=cask param2=upgrade'
|
'bash=/usr/local/bin/brew param1=cask param2=upgrade'
|
||||||
echo '---'
|
echo '---'
|
||||||
|
|
||||||
echo 'Upgrade:'
|
echo 'Upgrade:'
|
||||||
for i in "${!formulas[@]}"; do
|
for i in "${!formulas[@]}"; do
|
||||||
echo "${formulas[$i]}"
|
echo "${formulas[$i]}"
|
||||||
echo "--${current_version[$i]} → ${new_version[$i]} |" \
|
echo "--${current_version[$i]} → ${new_version[$i]} |" \
|
||||||
"terminal=true refresh=true bash=/usr/local/bin/brew param1=cask" \
|
"terminal=true refresh=true bash=/usr/local/bin/brew param1=cask" \
|
||||||
"param2=upgrade param3=${formulas[$i]}"
|
"param2=upgrade param3=${formulas[$i]}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ main() {
|
|||||||
formulas_list="$(printf '%s\n' "${formulas[@]}" | sort)"
|
formulas_list="$(printf '%s\n' "${formulas[@]}" | sort)"
|
||||||
|
|
||||||
count="$(
|
count="$(
|
||||||
comm -13 <(echo "$pinned_list") <(echo "$formulas_list") \
|
comm -13 <(echo "$pinned_list") <(echo "$formulas_list") |
|
||||||
| grep -c '[^[:space:]]'
|
grep -c '[^[:space:]]'
|
||||||
)"
|
)"
|
||||||
|
|
||||||
echo ":beer:↑${count} | dropdown=false"
|
echo ":beer:↑${count} | dropdown=false"
|
||||||
@@ -64,7 +64,7 @@ main() {
|
|||||||
|
|
||||||
if [ "$count" -gt 0 ]; then
|
if [ "$count" -gt 0 ]; then
|
||||||
echo 'Upgrade all formula | terminal=true refresh=true' \
|
echo 'Upgrade all formula | terminal=true refresh=true' \
|
||||||
'bash=/usr/local/bin/brew param1=upgrade'
|
'bash=/usr/local/bin/brew param1=upgrade'
|
||||||
echo '---'
|
echo '---'
|
||||||
|
|
||||||
echo 'Upgrade:'
|
echo 'Upgrade:'
|
||||||
@@ -77,8 +77,8 @@ main() {
|
|||||||
|
|
||||||
echo "$pkg"
|
echo "$pkg"
|
||||||
echo "--${current_version[$i]} → ${new_version[$i]} |" \
|
echo "--${current_version[$i]} → ${new_version[$i]} |" \
|
||||||
"terminal=true refresh=true bash=/usr/local/bin/brew" \
|
"terminal=true refresh=true bash=/usr/local/bin/brew" \
|
||||||
"param1=upgrade param2=${pkg}"
|
"param1=upgrade param2=${pkg}"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "${#pinned[@]}" -gt 0 ]; then
|
if [ "${#pinned[@]}" -gt 0 ]; then
|
||||||
|
|||||||
30
install.sh
30
install.sh
@@ -36,12 +36,11 @@ SYMLINKS=(
|
|||||||
zshrc
|
zshrc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Initial Setup
|
# Initial Setup
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ -n "${BASH_SOURCE[0]}" ] && [ -f "${BASH_SOURCE[0]}" ] ; then
|
if [ -n "${BASH_SOURCE[0]}" ] && [ -f "${BASH_SOURCE[0]}" ]; then
|
||||||
ROOT_PATH=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
ROOT_PATH=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
elif [ -n "$0" ] && [ -f "$0" ]; then
|
elif [ -n "$0" ] && [ -f "$0" ]; then
|
||||||
ROOT_PATH=$(cd "$(dirname "$0")" && pwd)
|
ROOT_PATH=$(cd "$(dirname "$0")" && pwd)
|
||||||
@@ -50,12 +49,11 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Main Functions
|
# Main Functions
|
||||||
#
|
#
|
||||||
|
|
||||||
install_symlinks () {
|
install_symlinks() {
|
||||||
# Symlink dotfiles root
|
# Symlink dotfiles root
|
||||||
symlink "$ROOT_PATH" "$TARGET/$DOTFILES_LINK"
|
symlink "$ROOT_PATH" "$TARGET/$DOTFILES_LINK"
|
||||||
|
|
||||||
@@ -70,12 +68,12 @@ install_symlinks () {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
install_private () {
|
install_private() {
|
||||||
git_clone "git@github.com:jimeh/dotfiles-private.git" \
|
git_clone "git@github.com:jimeh/dotfiles-private.git" \
|
||||||
"$ROOT_PATH/$PRIVATE_PATH"
|
"$ROOT_PATH/$PRIVATE_PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
install_launch_agents () {
|
install_launch_agents() {
|
||||||
mkdir -p "$HOME/Library/LaunchAgents"
|
mkdir -p "$HOME/Library/LaunchAgents"
|
||||||
for file in $ROOT_PATH/launch_agents/*.plist; do
|
for file in $ROOT_PATH/launch_agents/*.plist; do
|
||||||
symlink "$file" "$HOME/Library/LaunchAgents/$(basename "$file")"
|
symlink "$file" "$HOME/Library/LaunchAgents/$(basename "$file")"
|
||||||
@@ -87,11 +85,11 @@ install_launch_agents () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install_homebrew () {
|
install_homebrew() {
|
||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
||||||
}
|
}
|
||||||
|
|
||||||
install_rbenv () {
|
install_rbenv() {
|
||||||
git_clone 'https://github.com/rbenv/rbenv.git' "$TARGET/.rbenv"
|
git_clone 'https://github.com/rbenv/rbenv.git' "$TARGET/.rbenv"
|
||||||
git_clone 'https://github.com/rbenv/ruby-build.git' "$TARGET/.rbenv/plugins/ruby-build"
|
git_clone 'https://github.com/rbenv/ruby-build.git' "$TARGET/.rbenv/plugins/ruby-build"
|
||||||
}
|
}
|
||||||
@@ -102,7 +100,6 @@ install_emacs_config() {
|
|||||||
git_clone 'git@github.com:jimeh/.emacs.d.git' "$TARGET/.emacs.d"
|
git_clone 'git@github.com:jimeh/.emacs.d.git' "$TARGET/.emacs.d"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Helper functions
|
# Helper functions
|
||||||
#
|
#
|
||||||
@@ -127,7 +124,7 @@ symlink() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
git_clone () {
|
git_clone() {
|
||||||
local clone_url="$1"
|
local clone_url="$1"
|
||||||
local target="$2"
|
local target="$2"
|
||||||
|
|
||||||
@@ -139,28 +136,27 @@ git_clone () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Argument Handling
|
# Argument Handling
|
||||||
#
|
#
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
symlinks|links)
|
symlinks | links)
|
||||||
install_symlinks
|
install_symlinks
|
||||||
;;
|
;;
|
||||||
emacs-config|emacs)
|
emacs-config | emacs)
|
||||||
install_emacs_config
|
install_emacs_config
|
||||||
;;
|
;;
|
||||||
private)
|
private)
|
||||||
install_private
|
install_private
|
||||||
;;
|
;;
|
||||||
homebrew|brew)
|
homebrew | brew)
|
||||||
install_homebrew
|
install_homebrew
|
||||||
;;
|
;;
|
||||||
rbenv)
|
rbenv)
|
||||||
install_rbenv
|
install_rbenv
|
||||||
;;
|
;;
|
||||||
launch_agents|agents)
|
launch_agents | agents)
|
||||||
install_launch_agents
|
install_launch_agents
|
||||||
;;
|
;;
|
||||||
info)
|
info)
|
||||||
@@ -173,7 +169,7 @@ case "$1" in
|
|||||||
echo 'Available commands:'
|
echo 'Available commands:'
|
||||||
echo ' info: Target and source directory info.'
|
echo ' info: Target and source directory info.'
|
||||||
echo ' symlinks: Install symlinks for various dotfiles into' \
|
echo ' symlinks: Install symlinks for various dotfiles into' \
|
||||||
'target directory.'
|
'target directory.'
|
||||||
echo ' emacs_config: Install Emacs configuration.'
|
echo ' emacs_config: Install Emacs configuration.'
|
||||||
echo ' private: Install private dotfiles.'
|
echo ' private: Install private dotfiles.'
|
||||||
echo ' homebrew: Install Homebrew (Mac OS X only).'
|
echo ' homebrew: Install Homebrew (Mac OS X only).'
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ set -e
|
|||||||
|
|
||||||
PREFIX="/opt/emacs"
|
PREFIX="/opt/emacs"
|
||||||
|
|
||||||
help() {
|
show-help() {
|
||||||
echo "usage: ./install-emacs.sh <VERSION>"
|
echo "usage: ./install-emacs.sh <VERSION>"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,17 +24,31 @@ install() {
|
|||||||
deps() {
|
deps() {
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y \
|
sudo apt-get install -y \
|
||||||
build-essential libx11-dev xaw3dg-dev libjpeg-dev libpng12-dev \
|
build-essential \
|
||||||
libgif-dev libtiff4-dev libncurses5-dev libxft-dev librsvg2-dev \
|
libghc-gconf-dev \
|
||||||
libmagickcore-dev libmagick++-dev libxml2-dev libgpm-dev \
|
libgif-dev \
|
||||||
libghc-gconf-dev libotf-dev libm17n-dev libgnutls-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() {
|
main() {
|
||||||
local command="$1"
|
local command="$1"
|
||||||
|
|
||||||
if [ -z "$command" ]; then
|
if [ -z "$command" ]; then
|
||||||
echo "$(help)" 1>&2
|
show-help 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -45,4 +59,4 @@ main() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main $@
|
main "$@"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ set -e
|
|||||||
|
|
||||||
PREFIX="/opt/tmux"
|
PREFIX="/opt/tmux"
|
||||||
|
|
||||||
help() {
|
show-help() {
|
||||||
echo "usage: ./install-tmux.sh <VERSION>"
|
echo "usage: ./install-tmux.sh <VERSION>"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,17 +24,17 @@ install() {
|
|||||||
deps() {
|
deps() {
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y \
|
sudo apt-get install -y \
|
||||||
bc \
|
bc \
|
||||||
build-essential \
|
build-essential \
|
||||||
libevent-dev \
|
libevent-dev \
|
||||||
libncurses5-dev
|
libncurses5-dev
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local command="$1"
|
local command="$1"
|
||||||
|
|
||||||
if [ -z "$command" ]; then
|
if [ -z "$command" ]; then
|
||||||
echo "$(help)" 1>&2
|
show-help 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -45,4 +45,4 @@ main() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main $@
|
main "$@"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ set -e
|
|||||||
|
|
||||||
PREFIX="/opt/zsh"
|
PREFIX="/opt/zsh"
|
||||||
|
|
||||||
help() {
|
show-help() {
|
||||||
echo "usage: ./install-zsh.sh <VERSION>"
|
echo "usage: ./install-zsh.sh <VERSION>"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,14 +24,14 @@ install() {
|
|||||||
deps() {
|
deps() {
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y \
|
sudo apt-get install -y \
|
||||||
build-essential
|
build-essential
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local command="$1"
|
local command="$1"
|
||||||
|
|
||||||
if [ -z "$command" ]; then
|
if [ -z "$command" ]; then
|
||||||
echo "$(help)" 1>&2
|
show-help 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -72,29 +72,29 @@ authmeo() {
|
|||||||
# Make and cd into directory
|
# Make and cd into directory
|
||||||
# - from: http://alias.sh/make-and-cd-directory
|
# - from: http://alias.sh/make-and-cd-directory
|
||||||
mcd() {
|
mcd() {
|
||||||
mkdir -p "$1" && cd "$1";
|
mkdir -p "$1" && cd "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Extract most common archives with single command.
|
# Extract most common archives with single command.
|
||||||
# - from: http://alias.sh/extract-most-know-archives-one-command
|
# - from: http://alias.sh/extract-most-know-archives-one-command
|
||||||
extract() {
|
extract() {
|
||||||
if [ -f $1 ] ; then
|
if [ -f $1 ]; then
|
||||||
case $1 in
|
case $1 in
|
||||||
*.tar.bz2) tar xvjf $1 ;;
|
*.tar.bz2) tar xvjf $1 ;;
|
||||||
*.tar.gz) tar xvzf $1 ;;
|
*.tar.gz) tar xvzf $1 ;;
|
||||||
*.tar.xz) tar xvJf $1 ;;
|
*.tar.xz) tar xvJf $1 ;;
|
||||||
*.bz2) bunzip2 $1 ;;
|
*.bz2) bunzip2 $1 ;;
|
||||||
*.rar) unrar e $1 ;;
|
*.rar) unrar e $1 ;;
|
||||||
*.gz) gunzip $1 ;;
|
*.gz) gunzip $1 ;;
|
||||||
*.tar) tar xvf $1 ;;
|
*.tar) tar xvf $1 ;;
|
||||||
*.tbz2) tar xvjf $1 ;;
|
*.tbz2) tar xvjf $1 ;;
|
||||||
*.tbz) tar xvjf $1 ;;
|
*.tbz) tar xvjf $1 ;;
|
||||||
*.tgz) tar xvzf $1 ;;
|
*.tgz) tar xvzf $1 ;;
|
||||||
*.txz) tar xvJf $1 ;;
|
*.txz) tar xvJf $1 ;;
|
||||||
*.zip) unzip $1 ;;
|
*.zip) unzip $1 ;;
|
||||||
*.Z) uncompress $1 ;;
|
*.Z) uncompress $1 ;;
|
||||||
*.7z) 7z x $1 ;;
|
*.7z) 7z x $1 ;;
|
||||||
*) echo "'$1' cannot be extracted via extract()" ;;
|
*) echo "'$1' cannot be extracted via extract()" ;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
echo "'$1' is not a valid file"
|
echo "'$1' is not a valid file"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ alias d="docker"
|
|||||||
alias dc="docker-compose"
|
alias dc="docker-compose"
|
||||||
alias co="docker-compose"
|
alias co="docker-compose"
|
||||||
|
|
||||||
docker_remove_exited () {
|
docker_remove_exited() {
|
||||||
docker rm "$(docker ps -f='status=exited' -q)"
|
docker rm "$(docker ps -f='status=exited' -q)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Go (golang) setup.
|
# Go (golang) setup.
|
||||||
#
|
#
|
||||||
|
|
||||||
install_go_global_packages () {
|
install_go_global_packages() {
|
||||||
local packages=(
|
local packages=(
|
||||||
github.com/akavel/up
|
github.com/akavel/up
|
||||||
github.com/asciimoo/wuzz
|
github.com/asciimoo/wuzz
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ alias flush_dns="dscacheutil -flushcache"
|
|||||||
alias open_ports="sudo lsof -i -Pn | grep LISTEN"
|
alias open_ports="sudo lsof -i -Pn | grep LISTEN"
|
||||||
|
|
||||||
# Open man page in Preview.
|
# Open man page in Preview.
|
||||||
pman () {
|
pman() {
|
||||||
man -t "${1}" | open -f -a /Applications/Preview.app
|
man -t "${1}" | open -f -a /Applications/Preview.app
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,9 +20,9 @@ alias unfix_wifi="sudo ifconfig awdl0 up"
|
|||||||
# Disable the system built-in cmd+ctrl+d global hotkey to lookup word in
|
# Disable the system built-in cmd+ctrl+d global hotkey to lookup word in
|
||||||
# dictionary on OS X. Must reboot after running.
|
# dictionary on OS X. Must reboot after running.
|
||||||
# - from: ://apple.stackexchange.com/a/114269
|
# - from: ://apple.stackexchange.com/a/114269
|
||||||
osx-disable-lookup-word-hotkey () {
|
osx-disable-lookup-word-hotkey() {
|
||||||
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 70 \
|
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 70 \
|
||||||
'<dict><key>enabled</key><false/></dict>'
|
'<dict><key>enabled</key><false/></dict>'
|
||||||
echo "Command-Control-D hotkey disabled. Please reboot to take effect."
|
echo "Command-Control-D hotkey disabled. Please reboot to take effect."
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ alias osx-enable-lowpri-throttle='sudo sysctl debug.lowpri_throttle_enabled=1'
|
|||||||
# Set all relevant power management settings to force the machine to save a
|
# Set all relevant power management settings to force the machine to save a
|
||||||
# sleep image and immediately enter "standby" along with FileVault destroying
|
# sleep image and immediately enter "standby" along with FileVault destroying
|
||||||
# disk decryption keys.
|
# disk decryption keys.
|
||||||
pm-hibernate () {
|
pm-hibernate() {
|
||||||
sudo pmset -a hibernatemode 25
|
sudo pmset -a hibernatemode 25
|
||||||
sudo pmset -a standby 1
|
sudo pmset -a standby 1
|
||||||
sudo pmset -a standbydelayhigh 0
|
sudo pmset -a standbydelayhigh 0
|
||||||
@@ -50,7 +50,7 @@ pm-hibernate () {
|
|||||||
|
|
||||||
# Restore all settings modified by pm-hibernate to their defaults, effectively
|
# Restore all settings modified by pm-hibernate to their defaults, effectively
|
||||||
# restoring default sleep behavior for macOS laptops.
|
# restoring default sleep behavior for macOS laptops.
|
||||||
pm-safesleep () {
|
pm-safesleep() {
|
||||||
sudo pmset -a hibernatemode 3
|
sudo pmset -a hibernatemode 3
|
||||||
sudo pmset -a standbydelayhigh 86400
|
sudo pmset -a standbydelayhigh 86400
|
||||||
sudo pmset -a standbydelaylow 0
|
sudo pmset -a standbydelaylow 0
|
||||||
@@ -59,13 +59,13 @@ pm-safesleep () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Trigger hibernation now.
|
# Trigger hibernation now.
|
||||||
hibernate () {
|
hibernate() {
|
||||||
pm-hibernate
|
pm-hibernate
|
||||||
sudo pmset sleepnow
|
sudo pmset sleepnow
|
||||||
}
|
}
|
||||||
|
|
||||||
# Trigger a safe-sleep now.
|
# Trigger a safe-sleep now.
|
||||||
safesleep () {
|
safesleep() {
|
||||||
pm-safesleep
|
pm-safesleep
|
||||||
sudo pmset sleepnow
|
sudo pmset sleepnow
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ alias ngi="npm install -g"
|
|||||||
alias cof="coffee"
|
alias cof="coffee"
|
||||||
alias tl="tldr"
|
alias tl="tldr"
|
||||||
|
|
||||||
install_node_global_packages () {
|
install_node_global_packages() {
|
||||||
local packages=(
|
local packages=(
|
||||||
@prettier/plugin-php
|
@prettier/plugin-php
|
||||||
@prettier/plugin-ruby
|
@prettier/plugin-ruby
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Python environment setup
|
# Python environment setup
|
||||||
#
|
#
|
||||||
|
|
||||||
install_python_global_packages () {
|
install_python_global_packages() {
|
||||||
local packages=(
|
local packages=(
|
||||||
'ansible'
|
'ansible'
|
||||||
'grip'
|
'grip'
|
||||||
|
|||||||
36
zsh/ruby.zsh
36
zsh/ruby.zsh
@@ -2,7 +2,7 @@
|
|||||||
# Ruby environment setup.
|
# Ruby environment setup.
|
||||||
#
|
#
|
||||||
|
|
||||||
install_ruby_global_packages () {
|
install_ruby_global_packages() {
|
||||||
local packages=(
|
local packages=(
|
||||||
'bundler:~> 1.0'
|
'bundler:~> 1.0'
|
||||||
'bundler:~> 2.0'
|
'bundler:~> 2.0'
|
||||||
@@ -68,39 +68,39 @@ if command-exists rbenv; then
|
|||||||
unset -f load-rbenv _rbenv rbenv
|
unset -f load-rbenv _rbenv rbenv
|
||||||
eval "$(command rbenv init -)"
|
eval "$(command rbenv init -)"
|
||||||
}
|
}
|
||||||
|
|
||||||
rbenv-each-version () {
|
|
||||||
local current_version="$RBENV_VERSION"
|
|
||||||
|
|
||||||
for v in $(ls "${HOME}/.rbenv/versions"); do
|
|
||||||
echo "==> Ruby $v:"
|
|
||||||
export RBENV_VERSION="$v"
|
|
||||||
eval $*
|
|
||||||
done
|
|
||||||
|
|
||||||
export RBENV_VERSION="$current_version"
|
|
||||||
}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rbenv-each-version() {
|
||||||
|
local current_version="$RBENV_VERSION"
|
||||||
|
|
||||||
|
for v in $(ls "${HOME}/.rbenv/versions"); do
|
||||||
|
echo "==> Ruby $v:"
|
||||||
|
export RBENV_VERSION="$v"
|
||||||
|
eval $*
|
||||||
|
done
|
||||||
|
|
||||||
|
export RBENV_VERSION="$current_version"
|
||||||
|
}
|
||||||
|
|
||||||
# Solargraph related commands
|
# Solargraph related commands
|
||||||
|
|
||||||
solargraph-install () {
|
solargraph-install() {
|
||||||
rbenv-each-version "gem install solargraph"
|
rbenv-each-version "gem install solargraph"
|
||||||
}
|
}
|
||||||
|
|
||||||
solargraph-download-cores () {
|
solargraph-download-cores() {
|
||||||
rbenv-each-version "solargraph download-core"
|
rbenv-each-version "solargraph download-core"
|
||||||
}
|
}
|
||||||
|
|
||||||
solargraph-list-versions () {
|
solargraph-list-versions() {
|
||||||
rbenv-each-version "gem list -q solargraph"
|
rbenv-each-version "gem list -q solargraph"
|
||||||
}
|
}
|
||||||
|
|
||||||
rubygems-upgrade () {
|
rubygems-upgrade() {
|
||||||
rbenv-each-version "gem update --system"
|
rbenv-each-version "gem update --system"
|
||||||
}
|
}
|
||||||
|
|
||||||
upgrade-bundler () {
|
upgrade-bundler() {
|
||||||
rbenv-each-version \
|
rbenv-each-version \
|
||||||
"gem install --no-document 'bundler:~> 1.0' 'bundler:~> 2.0'"
|
"gem install --no-document 'bundler:~> 1.0' 'bundler:~> 2.0'"
|
||||||
}
|
}
|
||||||
|
|||||||
15
zshenv
15
zshenv
@@ -10,6 +10,10 @@ fi
|
|||||||
# Ensure compinit is NOT loaded before Zinit loads in ~/zshrc.
|
# Ensure compinit is NOT loaded before Zinit loads in ~/zshrc.
|
||||||
skip_global_compinit=1
|
skip_global_compinit=1
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# PATH Setup
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
# Ensure values in path variable are unique
|
# Ensure values in path variable are unique
|
||||||
typeset -U path
|
typeset -U path
|
||||||
|
|
||||||
@@ -22,16 +26,19 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
|
|||||||
|
|
||||||
# Setup default PATH just like /etc/zprofile does
|
# Setup default PATH just like /etc/zprofile does
|
||||||
if [ -x "/usr/libexec/path_helper" ]; then
|
if [ -x "/usr/libexec/path_helper" ]; then
|
||||||
eval `/usr/libexec/path_helper -s`
|
eval $(/usr/libexec/path_helper -s)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load /etc/zshenv if it exists
|
# Load /etc/zshenv if it exists
|
||||||
if [ -f "/etc/zshenv" ]; then
|
if [ -f "/etc/zshenv" ]; then
|
||||||
source "/etc/zshenv";
|
source "/etc/zshenv"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Path helpers
|
# ==============================================================================
|
||||||
|
# PATH Helpers
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
path_list () {
|
path_list () {
|
||||||
print -l "${(@)path}"
|
print -l "${(@)path}"
|
||||||
}
|
}
|
||||||
@@ -52,7 +59,6 @@ path_prepend () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# System Environment Setup
|
# System Environment Setup
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@@ -89,7 +95,6 @@ path_prepend "$DOTBIN"
|
|||||||
# Add user's bin directory to PATH
|
# Add user's bin directory to PATH
|
||||||
path_prepend "$HOME/bin"
|
path_prepend "$HOME/bin"
|
||||||
|
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Private Dotfiles Environment
|
# 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"
|
ZINIT[BIN_DIR]="${ZINIT[HOME_DIR]}/bin"
|
||||||
|
|
||||||
# Ask to clone Zinit if it's not already available on disk.
|
# Ask to clone Zinit if it's not already available on disk.
|
||||||
[ ! -d "${ZINIT[BIN_DIR]}" ] && \
|
[ ! -d "${ZINIT[BIN_DIR]}" ] &&
|
||||||
read -q "REPLY?Zinit not installed, clone to ${ZINIT[BIN_DIR]}? [y/N]:" && \
|
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]}"
|
echo &&
|
||||||
|
git clone --depth=1 "https://github.com/zdharma/zinit.git" "${ZINIT[BIN_DIR]}"
|
||||||
|
|
||||||
# Load Zinit
|
# Load Zinit
|
||||||
source "${ZINIT[BIN_DIR]}/zinit.zsh"
|
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 ice wait lucid atload"!_zsh_autosuggest_start"
|
||||||
zinit light zsh-users/zsh-autosuggestions
|
zinit light zsh-users/zsh-autosuggestions
|
||||||
|
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Private Dotfiles
|
# Private Dotfiles
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@@ -73,7 +73,6 @@ if [ -f "$DOTPFILES/zshrc" ]; then
|
|||||||
source "$DOTPFILES/zshrc"
|
source "$DOTPFILES/zshrc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Tool specific setup
|
# Tool specific setup
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@@ -101,7 +100,6 @@ source "$DOTZSH/python.zsh"
|
|||||||
source "$DOTZSH/ruby.zsh"
|
source "$DOTZSH/ruby.zsh"
|
||||||
source "$DOTZSH/rust.zsh"
|
source "$DOTZSH/rust.zsh"
|
||||||
|
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Basic Z-Shell settings
|
# Basic Z-Shell settings
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@@ -115,7 +113,6 @@ unsetopt share_history
|
|||||||
# Disable attempted correction of commands (is wrong 98% of the time).
|
# Disable attempted correction of commands (is wrong 98% of the time).
|
||||||
unsetopt correctall
|
unsetopt correctall
|
||||||
|
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Local Overrides
|
# Local Overrides
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user