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