# Aliases # alias alias_name="command_to_run" # . (DOT) - ls current directory #_________________________________________________________________ alias .='ls -lA --group-directories-first' # .. (DOT DOT) - up one directory (& ls) #_________________________________________________________________ alias ..='cd .. && ls' # ... (DOT DOT DOT) - up 2 directories (& ls) #_________________________________________________________________ alias ...='cd ../.. && ls' # HOME - shortcut to home directory (this may already be # in place but if so, no harm done #_________________________________________________________________ alias ~='cd ~' # EDIT .aliases then refresh (source) it #_________________________________________________________________ alias als='nano ~/.aliases && source ~/.aliases' alias edal='nano ~/.aliases && source ~/.aliases' # EDIT .bashrc then refresh (source) it #_________________________________________________________________ alias brc='nano ~/.bashrc && source ~/.bashrc' alias edbrc='nano ~/.bashrc && source ~/.bashrc' # CALC - CLI calculator #_________________________________________________________________ alias calc='bc -l' # CD THEN LS - Change dir then list contents #_________________________________________________________________ fn_cdls() { cd "$1" ls } alias cdd='fn_cdls' alias cdls='fn_cdls' alias lscd='fn_cdls' # Get CPU info #_________________________________________________________________ alias cpuinfo='lscpu' # docker-compose DOWN #_________________________________________________________________ alias dcdown='docker-compose down' alias dcdn='docker-compose down' # docker-compose UP #_________________________________________________________________ alias dcup='docker-compose up -d' # INSTALL from .deb file #_________________________________________________________________ alias deb='sudo dpkg -i' # Download a file (wget) with resume by default #_________________________________________________________________ alias download='wget -c' alias dl='wget -c' # EDIT docker-compose.yml #_________________________________________________________________ alias edcy='[ -e "./docker-compose.yaml" ] && nano docker-compose.yaml || nano docker-compose.yml' # EDIT (file using nano editor) #_________________________________________________________________ alias edit='nano' # output file tree as text (ctrl+F!) #_________________________________________________________________ alias filetree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' > .filetree && xdg-open .filetree" # fix nano key bindings #_________________________________________________________________ alias fixnano='wget -c https://raw.githubusercontent.com/don-ferris/bash-scripts/main/fixnano.sh && bash ./fixnano.sh" & aliases' # git pull #_________________________________________________________________ alias gitpull='clear && echo "$GITTOKEN" | xclip -selection clipboard && git pull' # set env var GITTOKEN = [gittoken] in .bashrc # git push #_________________________________________________________________ alias gitpush='clear && echo "$GITTOKEN" | xclip -selection clipboard && git commit -m "commit" && git push origin main' # set env var GITTOKEN = [gittoken] in .bashrc # git token #_________________________________________________________________ alias gittoken='[[ -z "$GITTOKEN" ]] && echo "GITTOKEN environment variable is not set. Edit ~/.bashrc and add a line near the bottom that says export gittoken=[your Github PAT]" || (echo "$GITTOKEN" | xclip -selection clipboard && echo "GitHub Personal Access Token has been copied to the clipboard.")' # GO (to a Docker container directory) #_________________________________________________________________ fn_go() { if [ -d "~/docker/$1" ]; then cd ~/docker/$1 elif [ -d "~/docker/$1" ]; then cd ~/docker/$1 else cd ~/docker fi ls } alias go='fn_go' # INST - apt -install #_________________________________________________________________ alias inst='apt install -y' alias install='apt install -y' # List aliases #_________________________________________________________________ alias lsal='alias' alias al='alias' # MAKE DIR then CD into it #_________________________________________________________________ fn_md () { mkdir "$1" cd "$1" pwd } alias md='fn_md' # pass options to free #_________________________________________________________________ alias meminfo='free -m -l -t' # IP (PUBLIC) - Print my public IP #_________________________________________________________________ alias myip='curl ipinfo.io/ip' # NUKE - force remove file(s*) or directory #_________________________________________________________________ alias nuke='rm -rf' # PING (quick ping) #_________________________________________________________________ alias ping='ping -c 8 -i .2' # PYTHON3 #_________________________________________________________________ alias py='python3' # sudo shortcut #_________________________________________________________________ alias S='sudo' # SCRIPTS - List scripts (create dir if it doesn't exist) #_________________________________________________________________ fn_scripts() { DIR=~/scripts if [ ! -d "$DIR" ]; then mkdir ~/scripts fi pushd ~/scripts chmod +x * ls -al echo "Current directory is now ~/scripts. Use popd to return to the previous directory." } alias scripts='fn_scripts' alias scr='fn_scripts' # SYSINFO - Generate a quick system report #_________________________________________________________________ fn_sysinfo() { OUTFILE=$HOME/.sysinfo echo " SYSTEM MEMORY USAGE " > $OUTFILE free -m -l -t >> $OUTFILE echo " ================================================================ TOP PROCESSES - MEMORY " >> $OUTFILE ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head >> $OUTFILE echo " ================================================================ TOP PROCESSES - CPU " >> $OUTFILE ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head >> $OUTFILE echo " ================================================================ PARTITION USAGE " >> $OUTFILE df -hlT --exclude-type=tmpfs --exclude-type=devtmpfs >> $OUTFILE echo " ================================================================ TOP DISK CONSUMPTION (IN $HOME) " >> $OUTFILE du -hsx * | sort -rh | head -10 >> $OUTFILE echo " " >> $OUTFILE xdg-open $OUTFILE } alias sysinfo='fn_sysinfo' # MACHINE (BASIC INFO) - basic info re: this PC #_________________________________________________________________ alias thispc='uname -a' # get top process eating cpu #_________________________________________________________________ alias top10cpu='ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head' # get top process eating memory #_________________________________________________________________ alias top10mem='ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head' # Easy update & upgrade #_________________________________________________________________ alias upd8='sudo apt update && sudo apt upgrade -y'