#!/usr/bin/env zsh #!   ░▒▓ #!   ░▒▒░▓▓ #!   ░▒▒▒░░░▓▓          ___________ #! ░░▒▒▒░░░░░▓▓        //___________/ #! ░░▒▒▒░░░░░▓▓     _   _ _    _ _____ #! ░░▒▒░░░░░▓▓▓▓▓▓ | | | | |  | |  __/ #! ░▒▒░░░░▓▓   ▓▓ | |_| | |_/ /| |___ #!  ░▒▒░░▓▓   ▓▓   \__  |____/ |____/ ▀█ █▀ █░█ #!    ░▒▓▓   ▓▓  //____/ █▄ ▄█ █▀█ # HyDE's ZSH env configuration # This file is sourced by ZSH on startup # And ensures that we have an obstruction-free ~/.zshrc file # This also ensures that the proper HyDE $ENVs are loaded function command_not_found_handler { local purple='\e[1;35m' bright='\e[0;1m' green='\e[1;32m' reset='\e[0m' printf "${green}zsh${reset}: command ${purple}NOT${reset} found: ${bright}'%s'${reset}\n" "$1" PM="pm.sh" # Try to find pm.sh in common locations if [ ! command -v "${PM}" ] &>/dev/null; then for path in "/usr/lib/hyde" "/usr/local/lib/hyde" "$HOME/.local/lib/hyde" "$HOME/.local/bin"; do if [[ -x "$path/pm.sh" ]]; then PM="$path/pm.sh" break else unset PM fi done fi if ! command -v "${PM}" &>/dev/null; then printf "${bright}${red}We cannot find package manager script (${purple}pm.sh${red}) from ${green}HyDE${reset}\n" return 127 fi if ! "${PM}" fq "/usr/bin/$1"; then printf "${bright}${green}[ ${1} ]${reset} ${purple}NOT${reset} found in the system and no package provides it.\n" return 127 else printf "${green}[ ${1} ] ${reset} might be provided by the above packages.\n" for entry in $entries; do # Assuming the entry already has ANSI color codes, we don't add more colors printf " %s\n" "${entry}" done fi return 127 } function load_zsh_plugins { # Oh-my-zsh installation path zsh_paths=( "$HOME/.oh-my-zsh" "/usr/local/share/oh-my-zsh" "/usr/share/oh-my-zsh" ) for zsh_path in "${zsh_paths[@]}"; do [[ -d $zsh_path ]] && export ZSH=$zsh_path && break; done # Load Plugins hyde_plugins=(git zsh-256color zsh-autosuggestions zsh-syntax-highlighting) plugins+=("${plugins[@]}" "${hyde_plugins[@]}" git zsh-256color zsh-autosuggestions zsh-syntax-highlighting) # Deduplicate plugins plugins=("${plugins[@]}") plugins=($(printf "%s\n" "${plugins[@]}" | sort -u)) # Loads om-my-zsh [[ -r $ZSH/oh-my-zsh.sh ]] && source $ZSH/oh-my-zsh.sh } # Function to display a slow load warning function slow_load_warning { local lock_file="/tmp/.hyde_slow_load_warning.lock" local load_time=$SECONDS # Check if the lock file exists if [[ ! -f $lock_file ]]; then # Create the lock file touch $lock_file # Display the warning if load time exceeds the limit time_limit=3 if ((load_time > time_limit)); then cat </dev/null; then for path in "/usr/lib/hyde" "/usr/local/lib/hyde" "$HOME/.local/lib/hyde" "$HOME/.local/bin"; do if [[ -x "$path/pm.sh" ]]; then PM="$path/pm.sh" break fi done fi # Optionally load user configuration // useful for customizing the shell without modifying the main file [[ -f ~/.hyde.zshrc ]] && source ~/.hyde.zshrc # Load plugins load_zsh_plugins # Helpful aliases if [[ -x "$(which eza)" ]]; then alias l='eza -lh --icons=auto' \ ll='eza -lha --icons=auto --sort=name --group-directories-first' \ ld='eza -lhD --icons=auto' \ lt='eza --icons=auto --tree' fi alias c='clear' \ in='$PM install' \ un='$PM remove' \ up='$PM upgrade' \ pl='$PM search installed' \ pa='$PM search all' \ vc='code' \ fastfetch='fastfetch --logo-type kitty' \ ..='cd ..' \ ...='cd ../..' \ .3='cd ../../..' \ .4='cd ../../../..' \ .5='cd ../../../../..' \ mkdir='mkdir -p' # Always mkdir a path (this doesn't inhibit functionality to make a single dir) # TODO: add handlers in pm.sh # for these aliases please manually add the following lines to your .zshrc file.(Using yay as the aur helper) # pc='yay -Sc' # remove all cached packages # po='yay -Qtdq | $PM -Rns -' # remove orphaned packages # Warn if the shell is slow to load autoload -Uz add-zsh-hook add-zsh-hook -Uz precmd slow_load_warning # add-zsh-hook zshexit cleanup fi