# ~/.bash_aliases # --- Persistent SSH Agent --- # Reuses existing agent across login sessions to prevent process bloat SSH_ENV="$HOME/.ssh/agent_env" function start_ssh_agent { /usr/bin/ssh-agent -s | sed 's/^echo/#echo/' > "${SSH_ENV}" chmod 600 "${SSH_ENV}" . "${SSH_ENV}" > /dev/null ssh-add ~/.ssh/github_rsa ~/.ssh/zippy-id_rsa ~/.ssh/zappy-id_root_rsa.key 2>/dev/null } if [ -f "${SSH_ENV}" ]; then . "${SSH_ENV}" > /dev/null ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent > /dev/null || start_ssh_agent else start_ssh_agent fi # --- Improved Search Functions (Requires ripgrep) --- function fastfindtext() { if [ -z "$1" ]; then echo "Usage: fastfindtext " return 1 fi # rg is superior for ISO workflows as it ignores hidden/binary/git-ignored files rg -li "$1" \ -g '!{node_modules,bin,lib,lib64,dist,.git,__pycache__}' \ -g '!*.{o,pcap,so,a,tar,sql}' } # Finding filenames function f() { sudo find . -name "*$@*" 2>/dev/null; } function fs() { sudo find . -iname "$@*" 2>/dev/null; } function fe() { sudo find . -iname "*$@" 2>/dev/null; } # --- Security & Networking --- alias netconns='sudo ss -tunp' alias openports='sudo ss -tulwn' alias lsock='sudo lsof -i -P' alias watchlogs='sudo tail -n 50 -f /var/log/syslog' alias cpu_hogs='ps wwaxr -o pid,stat,%cpu,time,command | head -10' # --- File & Directory Operations --- alias h='history' alias ll='ls -alF' alias la='ls -A' alias l='ls -CF' alias disksize='df -kh' alias dirsize='sudo du -h -d 1 . 2>/dev/null' alias lsize='ls -lSrh --color | grep -v "^d"' alias ldate='ls -ltr --color' # --- Modern Workflow (Python/uv & Nginx) --- alias uvr='uv run' alias editnginx='vi /etc/nginx/sites-enabled/default' alias restartnginx='nginx -t && systemctl reload nginx' # Cat all enabled Nginx site configurations with headers alias llnginx='for f in /etc/nginx/sites-enabled/*; do echo -e "\n\e[1;33m--- $f ---\e[0m"; cat "$f"; done' # --- Git --- alias gs='git status' alias ga='git add .' alias gc='git commit -m' alias gp='git push' # --- Miscellaneous --- alias renew="source ~/.bashrc" alias ccat="clear ; cat " alias work="/root/bin/task-manager-curses/bin/python /root/bin/task-manager-curses/tasks.py --db /root/bin/task-manager-curses/tasks.db" # Tree view function function tree (){ pwd ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' } # Search for file and open in vi vii() { local file_path=$(find . -type f -name "$1" -print -quit) if [[ -n "$file_path" ]]; then vi "$file_path" else echo "File '$1' not found." fi } alias lsgroups='uv run --project "/root/bin/lsgroup" --directory "$PWD" "/root/bin/lsgroup/lsgroup.py"'