mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-01-26 11:14:08 +00:00
dfm: menu rework, docs. codestyle fixes.
This commit is contained in:
@@ -76,8 +76,8 @@ alias code_scanner='docker run
|
||||
|
||||
alias zedit='$EDITOR ~/.dotfiles'
|
||||
|
||||
have irssi && \
|
||||
alias irssi="irssi --config='$IRSSI_CONFIG_FILE' --home='$IRSSI_CONFIG_HOME'"
|
||||
have irssi \
|
||||
&& alias irssi="irssi --config='$IRSSI_CONFIG_FILE' --home='$IRSSI_CONFIG_HOME'"
|
||||
|
||||
if [[ -f "$HOME/.aliases.local" ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
# Helper variables, override with ENVs like `VERBOSE=1 dfm help`
|
||||
: "${VERBOSE:=0}"
|
||||
: "${DOTFILES:=$HOME/.dotfiles}"
|
||||
: "${SHARED_SCRIPT:=$DOTFILES/scripts/shared.sh}"
|
||||
: "${INSTALL_SCRIPT:=$DOTFILES/scripts/install-dotfiles.sh}"
|
||||
: "${BREWFILE:=$DOTFILES/Brewfile}"
|
||||
: "${HOSTFILES:=$DOTFILES/hosts}"
|
||||
@@ -18,14 +19,14 @@ SCRIPT=$(basename "$0")
|
||||
VERSION_NVM="v0.39.3"
|
||||
|
||||
# shellcheck source=./../../scripts/shared.sh
|
||||
source "$DOTFILES/scripts/shared.sh"
|
||||
source "$SHARED_SCRIPT"
|
||||
|
||||
function section_install
|
||||
{
|
||||
USAGE_PREFIX="$SCRIPT install"
|
||||
USAGE_PREFIX="$SCRIPT install <command>"
|
||||
|
||||
MENU=(
|
||||
"all:Installs macos defaults, antigen, starship, brew, nvm, npm packages and others"
|
||||
"all:Installs everything in the correct order"
|
||||
"antigen:Updates the antigen.zsh file"
|
||||
"composer:Install composer"
|
||||
"dotenv:Install dotenv-linter"
|
||||
@@ -116,7 +117,7 @@ function section_install
|
||||
|
||||
function section_brew
|
||||
{
|
||||
USAGE_PREFIX="$SCRIPT brew"
|
||||
USAGE_PREFIX="$SCRIPT brew <command>"
|
||||
|
||||
MENU=(
|
||||
"install:Installs items defined in Brewfile"
|
||||
@@ -154,7 +155,7 @@ function section_brew
|
||||
|
||||
function section_dotfiles
|
||||
{
|
||||
USAGE_PREFIX="$SCRIPT dotfiles"
|
||||
USAGE_PREFIX="$SCRIPT dotfiles <command>"
|
||||
|
||||
MENU=(
|
||||
"fmt:Run all formatters"
|
||||
@@ -219,13 +220,13 @@ function section_dotfiles
|
||||
|
||||
function section_check
|
||||
{
|
||||
USAGE_PREFIX="$SCRIPT check"
|
||||
USAGE_PREFIX="$SCRIPT check <command>"
|
||||
X_HOSTNAME=$(hostname)
|
||||
X_ARCH=$(uname)
|
||||
|
||||
MENU=(
|
||||
"arch <arch>:Empty returns current. Exit code 0 when match, 1 when not."
|
||||
"host <host>:Empty returns current. Exit code 0 when match, 1 when not."
|
||||
"arch <arch>:Empty <arch> returns current. Exit code 0=match to current, 1=no match."
|
||||
"host <host>:Empty <host> returns current. Exit code 0=match to current, 1=no match."
|
||||
)
|
||||
|
||||
case "$1" in
|
||||
@@ -246,7 +247,7 @@ function section_check
|
||||
# Secret menu for visual tests
|
||||
function section_tests
|
||||
{
|
||||
USAGE_PREFIX="$SCRIPT tests"
|
||||
USAGE_PREFIX="$SCRIPT tests <command>"
|
||||
|
||||
MENU=(
|
||||
"msg:List all log functions from shared.sh"
|
||||
@@ -277,16 +278,9 @@ function section_tests
|
||||
|
||||
function usage
|
||||
{
|
||||
SECTIONS=(
|
||||
"install"
|
||||
"reset"
|
||||
"brew"
|
||||
"check"
|
||||
"dotfiles"
|
||||
)
|
||||
echo ""
|
||||
menu_usage_header "Usage: $SCRIPT" "${SECTIONS[@]}"
|
||||
echo $" All commands have their own subcommands."
|
||||
msg_prompt "Usage: $SCRIPT <section> <command>"
|
||||
echo $" Empty <command> prints <section> help."
|
||||
echo ""
|
||||
section_install
|
||||
echo ""
|
||||
|
||||
@@ -11,4 +11,3 @@ dir="$1"
|
||||
if [ ! -d "$dir" ]; then
|
||||
mkdir -p "$dir" && exit 0
|
||||
fi
|
||||
|
||||
|
||||
@@ -2,4 +2,3 @@
|
||||
# Source: https://github.com/thirtythreeforty/dotfiles/blob/master/bin/extip
|
||||
|
||||
curl icanhazip.com "${@}"
|
||||
|
||||
|
||||
@@ -11,6 +11,28 @@ CLR_GREEN="\033[1;32m"
|
||||
CLR_BLUE="\033[1;34m"
|
||||
CLR_RESET="\033[0m"
|
||||
|
||||
# -- Color functions -- #
|
||||
function __color_red()
|
||||
{
|
||||
local MSG="$1"
|
||||
echo -e "${CLR_RED}${MSG}${CLR_RESET}"
|
||||
}
|
||||
function __color_yellow()
|
||||
{
|
||||
local MSG="$1"
|
||||
echo -e "${CLR_YELLOW}${MSG}${CLR_RESET}"
|
||||
}
|
||||
function __color_green()
|
||||
{
|
||||
local MSG="$1"
|
||||
echo -e "${CLR_GREEN}${MSG}${CLR_RESET}"
|
||||
}
|
||||
function __color_blue()
|
||||
{
|
||||
local MSG="$1"
|
||||
echo -e "${CLR_BLUE}${MSG}${CLR_RESET}"
|
||||
}
|
||||
|
||||
# -- Helpers -- #
|
||||
function __log_marker()
|
||||
{
|
||||
@@ -68,7 +90,8 @@ function msg_done()
|
||||
echo -e "$(__log_marker) $1 ...$(__log_marker_ok)"
|
||||
}
|
||||
|
||||
function msg_done_suffix() {
|
||||
function msg_done_suffix()
|
||||
{
|
||||
echo -e "$(__log_marker) ...$(__log_marker_ok)"
|
||||
}
|
||||
|
||||
@@ -146,7 +169,7 @@ function menu_usage_header()
|
||||
|
||||
KEYS=""
|
||||
for item in "${MENU_ARRAY[@]}"; do
|
||||
CMD=$(echo "${item}"|awk -F ":" '{print $1}')
|
||||
CMD=$(echo "${item}" | awk -F ":" '{print $1}')
|
||||
KEYS+="${CMD} | "
|
||||
done
|
||||
|
||||
@@ -163,9 +186,9 @@ function menu_usage()
|
||||
shift
|
||||
MENU_ARRAY=("$@")
|
||||
|
||||
menu_usage_header "$MENU_CMD" "${MENU_ARRAY[@]}"
|
||||
msg "$MENU_CMD"
|
||||
|
||||
for item in "${MENU_ARRAY[@]}" ; do
|
||||
for item in "${MENU_ARRAY[@]}"; do
|
||||
CMD=$(echo "${item}" | awk -F ":" '{print $1}')
|
||||
DESC=$(echo "${item}" | awk -F ":" '{print $2}')
|
||||
menu_item "$CMD" "$DESC"
|
||||
@@ -176,7 +199,7 @@ function menu_usage()
|
||||
# usage: have php && php -v
|
||||
function have
|
||||
{
|
||||
command -v "$1" >&/dev/null;
|
||||
command -v "$1" >&/dev/null
|
||||
}
|
||||
|
||||
# Remove directory from the PATH variable
|
||||
|
||||
Reference in New Issue
Block a user