Merge branch 'master' of github.com:Lissy93/dotfiles

This commit is contained in:
Alicia Sykes 2023-02-26 13:00:36 +00:00
commit 461e32cab1
5 changed files with 159 additions and 74 deletions

4
config/.gitconfig Normal file
View File

@ -0,0 +1,4 @@
[interactive]
diffFilter = diff-so-fancy --patch
[pull]
rebase = false

View File

@ -17,6 +17,28 @@ utils_dir="${XDG_CONFIG_HOME}/utils"
# If not running interactively, don't do anything # If not running interactively, don't do anything
[[ $- != *i* ]] && return [[ $- != *i* ]] && return
# MacOS-specific services
if [ "$(uname -s)" = "Darwin" ]; then
# Add Brew to path, if it's installed
if [[ -d /opt/homebrew/bin ]]; then
export PATH=/opt/homebrew/bin:$PATH
fi
# If using iTerm, import the shell integration if availible
if [[ -f "${XDG_CONFIG_HOME}/zsh/.iterm2_shell_integration.zsh" ]]; then
source "${XDG_CONFIG_HOME}/zsh/.iterm2_shell_integration.zsh"
fi
# Append the Android SDK locations to path
if [[ -d "${HOME}/Library/Android/" ]]; then
export PATH="${HOME}/Library/Android/sdk/emulator:${PATH}"
export ANDROID_HOME="${HOME}/Library/Android/sdk"
export ANDROID_SDK_ROOT="${HOME}/Library/Android/sdk"
export ANDROID_AVD_HOME="${ANDROID_SDK_ROOT}/tools/emulator"
export NODE_BINARY="/usr/local/bin/node"
fi
fi
# Source all ZSH config files (if present) # Source all ZSH config files (if present)
if [[ -d $zsh_dir ]]; then if [[ -d $zsh_dir ]]; then
# Import alias files # Import alias files

View File

@ -69,9 +69,13 @@ alias yarn-nuke='reinstall_modules'
# Prints out versions of core Node.js packages # Prints out versions of core Node.js packages
print_node_versions () { print_node_versions () {
versions='' versions=''
format_verion_number () {
echo "$($1 --version 2>&1 | head -n 1 | sed 's/[^0-9.]*//g')"
}
get_version () { get_version () {
if hash $1 2> /dev/null || command -v $1 >/dev/null; then if hash $1 2> /dev/null || command -v $1 >/dev/null; then
versions="$versions\e[36m\e[1m $2: \033[0m$($1 --version)\n\033[0m" versions="$versions\e[36m\e[1m $2: \033[0m$(format_verion_number $1) \n\033[0m"
else else
versions="$versions\e[33m\e[1m $2: \033[0m\033[3m Not installed\n\033[0m" versions="$versions\e[33m\e[1m $2: \033[0m\033[3m Not installed\n\033[0m"
fi fi
@ -84,6 +88,11 @@ print_node_versions () {
get_version 'npm' 'NPM' get_version 'npm' 'NPM'
get_version 'yarn' 'Yarn' get_version 'yarn' 'Yarn'
get_version 'nvm' 'NVM' get_version 'nvm' 'NVM'
get_version 'ni' 'ni'
get_version 'pnpm' 'pnpm'
get_version 'tsc' 'TypeScript'
get_version 'bun' 'Bun'
get_version 'deno' 'Deno'
get_version 'git' 'Git' get_version 'git' 'Git'
echo -e $versions echo -e $versions
} }

View File

@ -23,6 +23,7 @@ tap 'browsh-org/homebrew-browsh'
tap 'espanso/espanso' tap 'espanso/espanso'
tap 'jesseduffield/lazygit' tap 'jesseduffield/lazygit'
tap 'koekeishiya/formulae' tap 'koekeishiya/formulae'
tap 'kdash-rs/kdash'
############################################################# #############################################################
# Command Line # # Command Line #
@ -66,6 +67,7 @@ brew 'zoxide' # Auto-learning navigation (better cd)
# CLI Monitoring and Performance Apps # CLI Monitoring and Performance Apps
brew 'bmon' # Bandwidth utilization monitor brew 'bmon' # Bandwidth utilization monitor
brew 'ctop' # Container metrics and monitoring brew 'ctop' # Container metrics and monitoring
brew 'dog' # DNS lookup client (better dig)
brew 'bpytop' # Resource monitoring (like htop) brew 'bpytop' # Resource monitoring (like htop)
brew 'dua-cli' # Disk usage analyzer and monitor (better du) brew 'dua-cli' # Disk usage analyzer and monitor (better du)
brew 'glances' # Resource monitor + web and API brew 'glances' # Resource monitor + web and API
@ -78,6 +80,8 @@ brew 'aspell' # Spell check
brew 'browsh' # Web browser, in terminal brew 'browsh' # Web browser, in terminal
brew 'buku' # Bookmark manager brew 'buku' # Bookmark manager
brew 'cmus' # Music player brew 'cmus' # Music player
brew 'cointop' # Crypto prices and portfolio
brew 'ddgr' # Web search, via DuckDuckGo
brew 'khal' # Calendar client brew 'khal' # Calendar client
brew 'mutt' # Email client brew 'mutt' # Email client
brew 'newsboat' # RSS / ATOM reader brew 'newsboat' # RSS / ATOM reader
@ -89,6 +93,7 @@ brew 'task' # Todo + task management
brew 'httpie' # HTTP / API testing testing client brew 'httpie' # HTTP / API testing testing client
brew 'lazydocker' # Full Docker management app brew 'lazydocker' # Full Docker management app
brew 'lazygit' # Full Git managemtne app brew 'lazygit' # Full Git managemtne app
brew 'kdash' # Kubernetes management
# CLI External Sercvices # CLI External Sercvices
cask 'ngrok' # Reverse proxy for sharing localhost cask 'ngrok' # Reverse proxy for sharing localhost

127
utils/free-up-disk-space.sh Normal file → Executable file
View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
###################################################################### ######################################################################
# 📊 Free up disk space # # 📊 Free up disk space #
@ -31,17 +31,40 @@ PLAIN_B='\033[1;37m'
RESET='\033[0m' RESET='\033[0m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
PURPLE='\033[0;35m' PURPLE='\033[0;35m'
PURPLE_B='\033[1;35m'
# Herlper func, to check if a command exists
function fuds_command_exists () {
command -v "$1" &> /dev/null
}
# Helper func, to check if a file or directory exists
function fuds_file_or_dir_exists () {
[ -e "$1" ]
}
# Helper func, to detect if running on a Mac
function fuds_is_macos () {
fuds_command_exists "sw_vers"
}
# Prints the title
function fuds_print_title () {
echo -e "${GREEN_B}"
if fuds_command_exists "figlet" ; then
figlet "Free Up Disk Space"
else
echo "Free Up Disk Space"
fi
echo -e "${RESET}"
}
# Finds and outputs used, total and free disk space
function fuds_check_space () { function fuds_check_space () {
convert_to_gb() { echo "$(($1/1048576))" ; } diskMsg=$(df -H | awk '$NF=="/"{
storage_used="$(df --output=used / | tail -n 1)" printf("You'\''re using %sB out of %sB total\n", $3, $2) }')
storage_free="$(df --output=avail / | tail -n 1)" diskMsg2=$(df -H | awk '$NF=="/"{ printf("There'\''s %sB of free space remaining\n", $4) }')
storage_total="$(($storage_used + $storage_free))" echo -e "$PURPLE_B$diskMsg$PURPLE\n$diskMsg2$RESET"
math_str="${storage_used} / ${storage_total} * 100"
storage_percent="$(echo "${math_str}" | bc -l)"
echo "Disk ${storage_percent%%.*}% full"
echo "You're using $(convert_to_gb $storage_used) GB out of $(convert_to_gb $storage_total) GB."\
"($(convert_to_gb $storage_free) GB free)."
} }
function fuds_clean_pacman () { function fuds_clean_pacman () {
@ -103,10 +126,11 @@ function fuds_remove_broken () {
} }
function fuds_show_help () { function fuds_show_help () {
echo "Usage: free-up-disk-space [OPTION]" fuds_print_title
echo "Free up disk space on *nix based systems"
echo "" echo -e "${PURPLE_B}Free up disk space on *nix based systems\n"
echo "Options:" echo -e "Usage:${PURPLE} free-up-disk-space [OPTION]"
echo -e "${PURPLE_B}Options:${PURPLE}"
echo " -h, --help Show this help message" echo " -h, --help Show this help message"
echo " -r, --run Run all tasks" echo " -r, --run Run all tasks"
echo " -p, --pacman Clean pacman cache and remove orphaned packages" echo " -p, --pacman Clean pacman cache and remove orphaned packages"
@ -119,70 +143,90 @@ function fuds_show_help () {
echo " -d, --dups Find and delete duplicated files" echo " -d, --dups Find and delete duplicated files"
echo " -b, --broken Remove broken symlinks and empty files + folders" echo " -b, --broken Remove broken symlinks and empty files + folders"
echo "" echo ""
echo "Examples:" echo -e "${PURPLE_B}Examples:${PURPLE}"
echo " free-up-disk-space -r" echo " free-up-disk-space -r"
echo " free-up-disk-space -p -f -a -s -j -t -c -d -b" echo " free-up-disk-space -p -f -a -s -j -t -c -d -b"
} }
function free_up_disk_space () { function free_up_disk_space () {
# Print title
fuds_print_title
# Check available disk space # Check available disk space
fuds_check_space fuds_check_space
# Prompt to clean pacman cache # Prompt to clean pacman cache
if fuds_command_exists "pacman" ; then
echo -e "\n${CYAN_B}Would you like to clean pacman cache? (y/N)${RESET}" echo -e "\n${CYAN_B}Would you like to clean pacman cache? (y/N)${RESET}"
read -n 1 -r ans_clean_pacman read -n 1 -r ans_clean_pacman
if [[ $ans_clean_pacman =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then if [[ $ans_clean_pacman =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then
fuds_clean_pacman fuds_clean_pacman
fi fi
fi
# Prompt to remove unused Flatpak packages # Prompt to remove unused Flatpak packages
if fuds_command_exists "flatpak" ; then
echo -e "\n${CYAN_B}Would you like to remove unused Flatpak packages? (y/N)${RESET}" echo -e "\n${CYAN_B}Would you like to remove unused Flatpak packages? (y/N)${RESET}"
read -n 1 -r ans_clean_flatpak read -n 1 -r ans_clean_flatpak
if [[ $ans_clean_flatpak =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then if [[ $ans_clean_flatpak =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then
fuds_clean_flatpak fuds_clean_flatpak
fi fi
fi
# Prompt to remove obsolete packages # Prompt to remove obsolete packages
if fuds_command_exists "apt" ; then
echo -e "\n${CYAN_B}Would you like to remove obsolete packages? (y/N)${RESET}" echo -e "\n${CYAN_B}Would you like to remove obsolete packages? (y/N)${RESET}"
read -n 1 -r ans_clean_apt read -n 1 -r ans_clean_apt
if [[ $ans_clean_apt =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then if [[ $ans_clean_apt =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then
fuds_clean_apt fuds_clean_apt
fi fi
fi
# Prompt to remove disabled snaps # Prompt to remove disabled snaps
if fuds_command_exists "snap" ; then
echo -e "\n${CYAN_B}Would you like to remove disabled snaps? (y/N)${RESET}" echo -e "\n${CYAN_B}Would you like to remove disabled snaps? (y/N)${RESET}"
read -n 1 -r ans_remove_dead_snaps read -n 1 -r ans_remove_dead_snaps
if [[ $ans_remove_dead_snaps =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then if [[ $ans_remove_dead_snaps =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then
fuds_remove_dead_snaps fuds_remove_dead_snaps
fi fi
fi
# Prompt to configure journal logs # Prompt to configure journal logs
if fuds_command_exists "journalctl" ; then
echo -e "\n${CYAN_B}Would you like to configure journal logs? (y/N)${RESET}" echo -e "\n${CYAN_B}Would you like to configure journal logs? (y/N)${RESET}"
read -n 1 -r ans_journal_configure read -n 1 -r ans_journal_configure
if [[ $ans_journal_configure =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then if [[ $ans_journal_configure =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then
fuds_journal_configure fuds_journal_configure
fi fi
fi
# Prompt to empty trash # Prompt to empty trash
if fuds_file_or_dir_exists "$HOME/.local/share/Trash" ; then
echo -e "\n${CYAN_B}Would you like to empty trash? (y/N)${RESET}" echo -e "\n${CYAN_B}Would you like to empty trash? (y/N)${RESET}"
read -n 1 -r ans_empty_trash read -n 1 -r ans_empty_trash
if [[ $ans_empty_trash =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then if [[ $ans_empty_trash =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then
fuds_empty_trash fuds_empty_trash
fi fi
fi
# Prompt to remove thumbnails and other caches # Prompt to remove thumbnails and other caches
if fuds_file_or_dir_exists "$HOME/.cache/thumbnails" ; then
echo -e "\n${CYAN_B}Would you like to remove thumbnails and other caches? (y/N)${RESET}" echo -e "\n${CYAN_B}Would you like to remove thumbnails and other caches? (y/N)${RESET}"
read -n 1 -r ans_clear_caches read -n 1 -r ans_clear_caches
if [[ $ans_clear_caches =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then if [[ $ans_clear_caches =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then
fuds_clear_caches fuds_clear_caches
fi fi
fi
# Prompt to find and delete duplicated files # Prompt to find and delete duplicated files
if fuds_command_exists "fdupes" ; then
echo -e "\n${CYAN_B}Would you like to find and delete duplicated files? (y/N)${RESET}" echo -e "\n${CYAN_B}Would you like to find and delete duplicated files? (y/N)${RESET}"
read -n 1 -r ans_remove_duplicates read -n 1 -r ans_remove_duplicates
if [[ $ans_remove_duplicates =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then if [[ $ans_remove_duplicates =~ ^[Yy]$ ]] || [[ $AUTO_YES = true ]] ; then
fuds_remove_duplicates fuds_remove_duplicates
fi fi
fi
# Prompt to remove broken symlinks and empty files + folders # Prompt to remove broken symlinks and empty files + folders
echo -e "\n${CYAN_B}Would you like to remove broken symlinks and empty files + folders? (y/N)${RESET}" echo -e "\n${CYAN_B}Would you like to remove broken symlinks and empty files + folders? (y/N)${RESET}"
@ -192,37 +236,38 @@ function free_up_disk_space () {
fi fi
} }
function fuds_start () {
# Show help menu
if [[ $@ == *"--help"* ]]; then
fuds_show_help
elif [ -z $@ ] || [[ $@ == *"--run"* ]]; then
# Begin the guided process
free_up_disk_space
else
# Run specific tasks, based on which flags are present
if [[ $@ == *"--pacman"* ]]; then fuds_clean_pacman; fi
if [[ $@ == *"--flatpak"* ]]; then fuds_clean_flatpak; fi
if [[ $@ == *"--apt"* ]]; then fuds_clean_apt; fi
if [[ $@ == *"--snaps"* ]]; then fuds_remove_dead_snaps; fi
if [[ $@ == *"--journal"* ]]; then fuds_journal_configure; fi
if [[ $@ == *"--trash"* ]]; then fuds_empty_trash; fi
if [[ $@ == *"--caches"* ]]; then fuds_clear_caches; fi
if [[ $@ == *"--dups"* ]]; then fuds_remove_duplicates; fi
if [[ $@ == *"--broken"* ]]; then fuds_remove_broken; fi
fi
# New line and reset afterwards
echo -e "\n${RESET}"
}
# Determine if file is being run directly or sourced # Determine if file is being run directly or sourced
([[ -n $ZSH_EVAL_CONTEXT && $ZSH_EVAL_CONTEXT =~ :file$ ]] || ([[ -n $ZSH_EVAL_CONTEXT && $ZSH_EVAL_CONTEXT =~ :file$ ]] ||
[[ -n $KSH_VERSION && $(cd "$(dirname -- "$0")" && [[ -n $KSH_VERSION && $(cd "$(dirname -- "$0")" &&
printf '%s' "${PWD%/}/")$(basename -- "$0") != "${.sh.file}" ]] || printf '%s' "${PWD%/}/")$(basename -- "$0") != "${.sh.file}" ]] ||
[[ -n $BASH_VERSION ]] && (return 0 2>/dev/null)) && sourced=1 || sourced=0 [[ -n $BASH_VERSION ]] && (return 0 2>/dev/null)) && sourced=1 || sourced=0
# If script being called directly, invoke transfer or show help # Either start now (if exectuted directly) or export the function (if sourced)
if [ $sourced -eq 0 ]; then if [ $sourced -eq 0 ]; then
if [[ $@ == *"--help"* ]]; then fuds_start $@
fuds_show_help else
elif [[ $@ == *"--pacman"*]]; then alias free-up-disk-space='fuds_start $@'
fuds_clean_pacman
elif [[ $@ == *"--flatpak"*]]; then
fuds_clean_flatpak
elif [[ $@ == *"--apt"*]]; then
fuds_clean_apt
elif [[ $@ == *"--snaps"*]]; then
fuds_remove_dead_snaps
elif [[ $@ == *"--journal"*]]; then
fuds_journal_configure
elif [[ $@ == *"--trash"*]]; then
fuds_empty_trash
elif [[ $@ == *"--caches"*]]; then
fuds_clear_caches
elif [[ $@ == *"--dups"*]]; then
fuds_remove_duplicates
elif [[ $@ == *"--broken"*]]; then
fuds_remove_broken
elif [[ $@ == *"--run"*]]; then
free_up_disk_space
else
free_up_disk_space
fi
fi fi