chore: more cleanup, linting and fixes

This commit is contained in:
2024-09-19 12:40:16 +03:00
parent 78716fa8ce
commit e2c37d29e8
6 changed files with 104 additions and 82 deletions

5
.gitattributes vendored
View File

@@ -220,8 +220,3 @@ git/* text
**/alias text
ssh/* text
# Git Crypt special files
*-secret filter=git-crypt diff=git-crypt
*.key filter=git-crypt diff=git-crypt
secrets/** filter=git-crypt diff=git-crypt

View File

@@ -77,10 +77,6 @@ brew "cryptography"
brew "curl"
# Lightweight DNS forwarder and DHCP server
brew "dnsmasq"
# Spellchecker wrapping library
brew "enchant"
# Banner-like program prints strings as ASCII art
brew "figlet"
# Lock file during command
brew "flock"
# Libraries to talk to Microsoft SQL Server and Sybase databases
@@ -91,28 +87,14 @@ brew "gd"
brew "gh"
# Distributed revision control system
brew "git"
# Enable transparent encryption/decryption of files in a git repo
brew "git-crypt"
# Small git utilities
brew "git-extras"
# See your latest local git branches, formatted real fancy
brew "git-recent"
# Render markdown on the CLI
brew "glow"
# GNU implementation of the famous stream editor
brew "gnu-sed"
# Validating, recursive, caching DNS resolver
brew "unbound"
# GNU Transport Layer Security (TLS) Library
brew "gnutls"
# GNU Pretty Good Privacy (PGP) package
brew "gnupg"
# Library access to GnuPG
brew "gpgme"
# Open source suite of directory software
brew "openldap"
# Manage your GnuPG keys with ease!
brew "gpg-tui"
# Image manipulation
brew "netpbm"
# C/C++ and Java libraries for Unicode and globalization
@@ -125,8 +107,6 @@ brew "pango"
brew "librsvg"
# Graph visualization software from AT&T and Bell Labs
brew "graphviz"
# GNU grep, egrep and fgrep
brew "grep"
# Popular GNU data compression program
brew "gzip"
# Improved top (interactive process viewer)
@@ -157,18 +137,14 @@ brew "libuv"
brew "libyaml"
# Package manager for the Lua programming language
brew "luarocks"
# LZMA-based compression program similar to gzip or bzip2
brew "lzip"
# Swiss Army Knife for macOS
brew "m-cli"
# NCurses Disk Usage
brew "ncdu"
# HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
brew "nginx"
# Port scanning utility for large networks
brew "nmap"
# Cryptography and SSL/TLS Toolkit
brew "openssl@1.1"
# Open source suite of directory software
brew "openldap"
# General-purpose scripting language
brew "php"
# Manage compile and link flags for libraries
@@ -193,10 +169,8 @@ brew "wget"
brew "xdg-ninja", args: ["HEAD"]
# Watcher for macOS 10.14+ light/dark mode changes
brew "cormacrelf/tap/dark-notify"
# lets you quickly switch between multiple git user profiles
brew "gesquive/tap/git-user"
# Automated code review tool integrated with any code analysis tools regardless of programming language.
brew "reviewdog/tap/reviewdog"
# Igbinary PHP extension
brew "shivammathur/extensions/igbinary@8.3"
# Imagick PHP extension
brew "shivammathur/extensions/imagick@8.3"
# Mcrypt PHP extension

View File

@@ -44,6 +44,23 @@ if ! declare -f msg_done > /dev/null; then
}
fi
if ! declare -f array_diff > /dev/null; then
# Function to compare two arrays and return the difference
# Example: array_diff DIFFERENCE ARRAY1 ARRAY2
# $1 - variable to store the difference
# $2 - first array
# $3 - second array
# Output to $1 the difference between $2 and $3
# Source: https://stackoverflow.com/a/42399479/594940
array_diff()
{
eval local ARR1=\(\"\${$2[@]}\"\)
eval local ARR2=\(\"\${$3[@]}\"\)
local IFS=$'\n'
mapfile -t "$1" < <(comm -23 <(echo "${ARR1[*]}" | sort) <(echo "${ARR2[*]}" | sort))
}
fi
VERSION_NVM="v0.39.5"
# Loads configs for better installation experience
@@ -293,6 +310,7 @@ section_brew()
"autoupdate:Setups brew auto-update and runs it immediately"
"leaves:List brew leaves (installed on request)"
"clean:Clean up brew packages"
"untracked:List untracked brew packages"
)
x-have brew && {
@@ -318,6 +336,46 @@ section_brew()
leaves)
brew leaves --installed-on-request
;;
untracked)
declare -a BREW_LIST_ALL
while IFS= read -r line; do
BREW_LIST_ALL+=("$line")
done < <(brew list --formula --installed-on-request -1 --full-name)
while IFS= read -r c; do
BREW_LIST_ALL+=("$c")
done < <(brew list --cask -1 --full-name)
# Remove entries that are installed as dependencies
declare -a BREW_LIST_DEPENDENCIES
while IFS= read -r l; do
BREW_LIST_DEPENDENCIES+=("$l")
done < <(brew list -1 --installed-as-dependency)
declare -a BREW_LIST_BUNDLED
while IFS= read -r b; do
BREW_LIST_BUNDLED+=("$b")
done < <(brew bundle list --all --file="$BREWFILE")
declare -a BREW_LIST_TRACKED_WITHOUT_DEPS
for f in "${BREW_LIST_ALL[@]}"; do
if [[ ! " ${BREW_LIST_DEPENDENCIES[@]} " =~ " ${f} " ]]; then
BREW_LIST_TRACKED_WITHOUT_DEPS+=("$f")
fi
done
array_diff BREW_LIST_UNTRACKED BREW_LIST_TRACKED_WITHOUT_DEPS BREW_LIST_BUNDLED
# If there are no untracked packages, exit
if [ ${#BREW_LIST_UNTRACKED[@]} -eq 0 ]; then
msg_yay "No untracked packages found!"
exit 0
fi
echo "Untracked:"
for f in "${BREW_LIST_UNTRACKED[@]}"; do
echo " $f"
done
;;
clean)
brew bundle cleanup --file="$BREWFILE" && msg_yay "Done!"
;;
@@ -421,7 +479,9 @@ section_dotfiles()
! x-have shfmt && msg_err "shfmt not found, install with asdf"
# Format shell scripts according to following rules.
fd --full-path "$DOTFILES" -tx \
--hidden \
-E '*.pl' -E '*.php' -E '*.py' -E '*.zsh' -E 'plugins' -E 'fzf' -E 'dotbot' \
-E 'test' -E '**/bin/asdf/**' -E '**/tldr/*' \
-x shfmt \
--language-dialect bash \
--func-next-line --list --write \

View File

@@ -29,23 +29,17 @@ rainbowColor()
let t=$f*255/43
let q=255-t
if [ $h -eq 0 ]
then
if [ $h -eq 0 ]; then
echo "255 $t 0"
elif [ $h -eq 1 ]
then
elif [ $h -eq 1 ]; then
echo "$q 255 0"
elif [ $h -eq 2 ]
then
elif [ $h -eq 2 ]; then
echo "0 255 $t"
elif [ $h -eq 3 ]
then
elif [ $h -eq 3 ]; then
echo "0 $q 255"
elif [ $h -eq 4 ]
then
elif [ $h -eq 4 ]; then
echo "$t 0 255"
elif [ $h -eq 5 ]
then
elif [ $h -eq 5 ]; then
echo "255 0 $q"
else
# execution should never reach here
@@ -96,4 +90,3 @@ for i in $(seq 255 128); do
echo -n " "
done
resetOutput

Binary file not shown.