Skip to content

Instantly share code, notes, and snippets.

@jcanfield
Last active May 23, 2025 18:47
Show Gist options
  • Save jcanfield/3fdef375abae81626a401a44d66c173c to your computer and use it in GitHub Desktop.
Save jcanfield/3fdef375abae81626a401a44d66c173c to your computer and use it in GitHub Desktop.
Bash Aliases (.bash_aliases) for DEB based system
# Zsh Aliases Configuration
# by @jcanfield
# =============================================================================
# SHORTENED COMMANDS
# =============================================================================
alias ll='ls -l'
alias la='ls -a'
alias lc='ls -CF'
alias l='exa -l' # Removed $1 parameter for better zsh compatibility
alias grep='grep --color=auto'
alias ..='cd ..'
alias ...='cd ../..'
# =============================================================================
# NAVIGATION ALIASES
# =============================================================================
alias dl='cd ~/Downloads'
alias docs='cd ~/Documents'
alias desktop='cd ~/Desktop'
# =============================================================================
# SYSTEM ALIASES
# =============================================================================
alias update='sudo apt update && sudo apt upgrade' # Debian/Ubuntu
alias diskspace='df -h'
alias freemem='free -mhw'
alias searchmans='apropos -v'
# =============================================================================
# GIT ALIASES
# =============================================================================
alias gs='git status'
alias ga='git add'
alias gc='git commit -m'
alias gp='git push'
alias gl='git pull'
# =============================================================================
# NETWORK MONITORING ALIASES
# =============================================================================
# Comprehensive view with bmon (interactive, modern UI)
alias netmon='bmon -p eth0'
# Real-time bandwidth usage with iftop (requires sudo, shows connections)
# CAUTION: iftop can be resource intensive on very busy interfaces.
alias iftop_live='sudo iftop -i eth0 -P -n'
# Real-time bandwidth usage per process with nethogs (requires sudo)
# You might need to install nethogs if it's not already on your system
# alias nethogs_live='sudo nethogs eth0'
# Historical daily traffic with vnstat (shows daily, weekly, monthly stats)
# After initial install, vnstat needs to collect data for a bit.
alias netstats='vnstat -i eth0'
alias netstats_hourly='vnstat -i eth0 -h' # Hourly stats
alias netstats_daily='vnstat -i eth0 -d' # Daily stats
# Speedometer for simple ASCII bar graphs (visualize speed)
alias netmeter_dl='speedometer -r eth0' # Download speed
alias netmeter_ul='speedometer -t eth0' # Upload speed
alias netmeter_full='speedometer -r eth0 -t eth0' # Both DL/UL
# Bandwidth Meter NG (bwm-ng) for simple, configurable output
alias bwm_simple='bwm-ng -I eth0'
alias bwm_csv='bwm-ng -I eth0 -o csv -u bytes' # CSV output for logging/parsing
# CBM - Color Bandwidth Meter (simple, quick overview)
alias cbm_overview='cbm' # CBM typically monitors all interfaces
# iperf3 for network performance testing (client side, needs server)
# To test bandwidth to a remote iperf3 server (e.g., test.example.com)
# You would need to have an iperf3 server running on the remote end: iperf3 -s
alias iperf_test='iperf3 -c your_iperf3_server_ip -p 5201 -P 10' # Test with 10 parallel streams
alias iperf_server='iperf3 -s' # Run iperf3 as a server
# =============================================================================
# CUSTOM ALIASES
# =============================================================================
alias myip='curl ifconfig.me'
alias lsip='curl ipinfo.io 2>/dev/null | jq .'
alias weather='curl wttr.in/Dacono\&0' # Requires curl and internet connection
alias extendweather='curl wttr.in/Dacono\&5'
alias showmoon='curl wttr.in/Moon'
alias refresh='clear && source ~/.zshrc' # Changed from ~/.bash_profile to ~/.zshrc
alias networkload='nload -u m -t 2000 eth0'
# Alternative reload command
# alias reloadzsh='clear && source ~/.zshrc'
# Example of an alias that helps correct typos
alias ubdate='sudo apt update && sudo apt upgrade' # corrects a common typo
# =============================================================================
# ADVANCED FUNCTIONS
# =============================================================================
alias testspeed='testspeed_func'
testspeed_func() {
if [[ -z "$1" ]]; then
echo "Usage: testspeed <URL>"
return 1
fi
curl -s -w 'Testing Website Response Time for :%{url_effective}\n\nLookup Time:\t\t%{time_namelookup}\nConnect Time:\t\t%{time_connect}\nPre-transfer Time:\t%{time_pretransfer}\nStart-transfer Time:\t%{time_starttransfer}\n\nTotal Time:\t\t%{time_total}\n' -o /dev/null "$1"
}
alias reddit='/home/jcanfield/.local/bin/tuir'
# alias weather='wego -location 80012 -u imperial'
# =============================================================================
# DIRECTORY RELATED ALIASES
# =============================================================================
# alias ls-size='du -ha --max-depth=1 | sort -n'
# alias ls-size2='du -ha --max-depth=2 | sort -n'
# alias ls-dirsize='ls_dirsize_func'
# ls_dirsize_func() {
# echo "Listing sizes for $1..." && du -h "$1" --max-depth=1 | sort -n
# }
# alias list-sizes='du -sch ./* | sort -n'
# =============================================================================
# GIT RELATED ALIASES
# =============================================================================
alias rm-dsstore-old="echo 'Removing DS_Store files..' && find . -type f \( -name '.DS_Store' -o -name '._.DS_Store' \) -delete -print 2>&1 | grep -v 'Permission denied'"
alias rm-dsstore-old2="echo 'Removing DS_Store files..' && find . -name '.DS_Store' -type f -delete"
alias git-rm-dsstore-old="echo 'Removing all .DS_Store files from directory and repository' && find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch"
# =============================================================================
# MISCELLANEOUS
# =============================================================================
alias screensaver='screensaver_func'
screensaver_func() {
/home/jcanfield/.apps/ascii-matrix/ascii-matrix -f "$1"
}
# =============================================================================
# COMPARE FILES AND DIRECTORIES
# =============================================================================
alias compare-dir='compare_dir_func'
compare_dir_func() {
if [[ $# -ne 2 ]]; then
echo "Usage: compare-dir <dir1> <dir2>"
return 1
fi
du -sh "$1" "$2" && echo "Comparing $1 with $2..."
}
alias diff-dir='diff_dir_func'
diff_dir_func() {
if [[ $# -ne 2 ]]; then
echo "Usage: diff-dir <dir1> <dir2>"
return 1
fi
diff -qr "$1" "$2" && echo "Diff with $1 and $2..."
}
# =============================================================================
# SYSTEM UPDATES AND PACKAGE MANAGERS
# =============================================================================
alias update-system-full='~/.bin/apt-upgrade-system'
# =============================================================================
# ZSH FUNCTIONS
# =============================================================================
# Create directory and cd into it (converted from bash function)
mkcd() {
if [[ -z "$1" ]]; then
echo "Usage: mkcd <directory_name>"
return 1
fi
mkdir -p "$1" && cd "$1"
}
# Aliases for DEB based systems
# by @jcanfield
# Shortened commands
alias ll='ls -l'
alias la='ls -a'
alias lc='ls -CF'
alias l="exa -l $1"
alias grep='grep --color=auto'
alias ..='cd ..'
alias ...='cd ../..'
# Navigation aliases
alias dl='cd ~/Downloads'
alias docs='cd ~/Documents'
alias desktop='cd ~/Desktop'
# System aliases
alias update='sudo apt update && sudo apt upgrade' # Debian/Ubuntu example
alias diskspace='df -h'
#alias freemem='free -m'
alias freemem='free -mhw'
alias searchmans='apropos -v'
# Git aliases
alias gs='git status'
alias ga='git add'
alias gc='git commit -m'
alias gp='git push'
alias gl='git pull'
# Network aliases
# --- Network Monitoring Aliases ---
# Comprehensive view with bmon (interactive, modern UI)
alias netmon='bmon -p eth0'
# Real-time bandwidth usage with iftop (requires sudo, shows connections)
# CAUTION: iftop can be resource intensive on very busy interfaces.
alias iftop_live='sudo iftop -i eth0 -P -n'
# Real-time bandwidth usage per process with nethogs (requires sudo, excellent for finding culprits)
# You might need to install nethogs if it's not already on your system
# alias nethogs_live='sudo nethogs eth0'
# Historical daily traffic with vnstat (shows daily, weekly, monthly stats)
# After initial install, vnstat needs to collect data for a bit.
alias netstats='vnstat -i eth0'
alias netstats_hourly='vnstat -i eth0 -h' # Hourly stats
alias netstats_daily='vnstat -i eth0 -d' # Daily stats
# Speedometer for simple ASCII bar graphs (visualize speed)
alias netmeter_dl='speedometer -r eth0' # Download speed
alias netmeter_ul='speedometer -t eth0' # Upload speed
alias netmeter_full='speedometer -r eth0 -t eth0' # Both DL/UL
# Bandwidth Meter NG (bwm-ng) for simple, configurable output
alias bwm_simple='bwm-ng -I eth0'
alias bwm_csv='bwm-ng -I eth0 -o csv -u bytes' # CSV output for logging/parsing
# CBM - Color Bandwidth Meter (simple, quick overview)
alias cbm_overview='cbm' # CBM typically monitors all interfaces, eth0 specific might not be an option.
# iperf3 for network performance testing (client side, needs server)
# To test bandwidth to a remote iperf3 server (e.g., test.example.com)
# You would need to have an iperf3 server running on the remote end: iperf3 -s
alias iperf_test='iperf3 -c your_iperf3_server_ip -p 5201 -P 10' # Test with 10 parallel streams
alias iperf_server='iperf3 -s' # Run iperf3 as a server (useful on another VPS to test from this one)
# Custom aliases
alias myip='curl ifconfig.me'
alias lsip='curl ipinfo.io 2>/dev/null | jq '.''
alias weather='curl wttr.in/Dacono&0' # Requires curl and internet connection
alias extendweather='curl wttr.in/Dacono&5'
alias showmoon='curl wttr.in/Moon'
alias refresh='clear && source ~/.bash_profile'
alias networkload='nload -u m -t 2000 eth0'
# Or perhaps
# alias reloadbash='clear && source ~/.bashrc'
# Example of a function aliased
function mkcd() {
mkdir -p "$1" && cd "$1"
}
alias mkcd='mkcd'
# Example of an alias that helps correct typos
alias ubdate="sudo apt update && sudo apt upgrade" #corrects a common typ
## Advanced functions
alias testspeed="curl -s -w 'Testing Website Response Time for :%{url_effective}\n\nLookup Time:\t\t%{time_namelookup}\nConnect Time:\t\t%{time_connect}\nPre-transfer Time:\t%{time_pretransfer}\nStart-transfer Time:\t%{time_starttransfer}\n\nTotal Time:\t\t%{time_total}\n' -o /dev/null $1"
alias reddit="/home/jcanfield/.local/bin/tuir"
#alias weather="wego -location 80012 -u imperial"
## Direcotry related aliases
#alias ls-size="du -ha --max-depth=1 | sort -n"
#alias ls-size2="du -ha --max-depth=2 | sort -n"
#alias ls-dirsize='echo "Listing sizes for $1..." && du -h "$1" --max-depth=1 | sort -n'
#alias list-sizes="du -sch ./* | sort -n"
#alias l="exa -l"
## GIT related aliases
alias rm-dsstore-old="echo 'Removing DS_Store files..' && find . -type f \( -name '.DS_Store' -o -name '._.DS_Store' \) -delete -print 2>&1 | grep -v 'Permission denied'"
alias rm-dsstore-old2="echo 'Removing DS_Store files..' && find . -name '.DS_Store' -type f -delete"
alias git-rm-dsstore-old="echo 'Removing all .DS_Store files from directory and repository' && find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch"
## MISC
alias screensaver="/home/jcanfield/.apps/ascii-matrix/ascii-matrix -f $1
## Compare Files and Dirs
alias compare-dir='du -sh $1 $2 && echo "Comparing $1 with $2..."'
alias diff-dir='diff -qr $1 $2 && echo "Diff with $1 and $2..."'
## System Updates and Package Managers
alias update-system-full='~/.bin/apt-upgrade-system'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment