Every seasoned developer knows the .bashrc file is where terminal magic happens. Customizing it properly can save hundreds of keystrokes per day. Here's my curated collection of time-saving configurations refined over a decade of development work.
# Enhanced ls commands
alias ll='ls -alhF --group-directories-first --color=auto'
alias la='ls -AF'
alias lt='ls -alhtF --time-style=long-iso' # Sorted by modification time
alias lx='ls -lXB' # Sort by extension
alias lr='ls -lR' # Recursive ls
# Disk space analysis
alias diskspace="du -h --max-depth=1 | sort -hr | head -n20"
alias bigfiles="find . -type f -exec du -h {} + | sort -rh | head -n20"
# Process management
alias pstop="ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head"
alias memtop="ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head"
# Git workflow accelerators
alias gs='git status'
alias gd='git diff --color-words'
alias gdc='git diff --cached'
alias gl='git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit'
alias gclean='git branch --merged | grep -v "\*" | xargs -n 1 git branch -d'
# Quick port scanning
alias ports='netstat -tulanp'
# Secure file operations
alias shred='shred -uzn 3' # Secure file deletion
alias http='python3 -m http.server 8000' # Quick HTTP server
# Docker shortcuts
alias dps='docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Status}}\t{{.Ports}}"'
alias dka='docker kill $(docker ps -q)'
# Python environment
alias venv='python3 -m venv ./venv && source ./venv/bin/activate'
alias pyclean='find . -type f -name "*.py[co]" -delete -o -type d -name "__pycache__" -delete'
# Include user binaries and local scripts
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/bin:$PATH"
export PATH="./node_modules/.bin:$PATH" # For npm projects
# Quick directory navigation
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
# System updates simplified (Debian/Ubuntu)
alias update='sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y'
# History control
export HISTSIZE=10000
export HISTFILESIZE=20000
export HISTCONTROL=ignoreboth:erasedups
shopt -s histappend
Remember to source your .bashrc after making changes: source ~/.bashrc
or open a new terminal session. These aliases represent just the beginning - tailor them to your specific workflow for maximum efficiency.
The .bashrc
file is your command-line Swiss Army knife. Every serious developer I know has spent hours fine-tuning theirs. Here are battle-tested configurations that have saved me countless hours over the years.
# Enhanced ls commands
alias ll='ls -alh --group-directories-first --color=auto'
alias la='ls -A --block-size="\'1"'
alias lt='ls -ltrh' # sort by time
alias l.='ls -d .*' # show hidden files
# Find large files quickly
alias findlarge="find . -type f -exec du -sh {} + | sort -rh | head -n 20"
# Disk space visualization
alias diskspace="du -h --max-depth=1 | sort -hr"
alias freespace="df -h | grep -v 'tmpfs'"
# Process management
alias pscpu="ps auxf | sort -nr -k 3 | head -10"
alias psmem="ps auxf | sort -nr -k 4 | head -10"
# One-line git status
alias gs='git status -sb'
alias gd='git diff --color-words'
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
alias gca='git commit --amend --no-edit'
alias gprune="git fetch --prune && git branch -vv | grep ': gone]' | awk '{print \$1}' | xargs git branch -D"
# Quick IP info
alias myip="curl ifconfig.me && echo"
alias ports="netstat -tulanp"
# Download utilities
alias wget='wget -c' # resume by default
alias curljson='curl -s -H "Content-Type: application/json"'
# Python virtualenv
alias venv='source venv/bin/activate'
alias mkvenv='python3 -m venv venv && venv'
# Docker shortcuts
alias dps="docker ps --format \"table {{.ID}}\t{{.Names}}\t{{.Status}}\t{{.Ports}}\""
alias dcu="docker-compose up -d"
alias dcd="docker-compose down"
# Create directory and cd into it
mkcd() { mkdir -p "$1" && cd "$1"; }
# Extract any archive
extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "Unknown archive format" ;;
esac
else
echo "$1 is not a valid file!"
fi
}
# Prevent accidents
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Add confirmation before overwriting files
set -o noclobber
# Colorful man pages
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
# Better history
export HISTSIZE=10000
export HISTFILESIZE=20000
export HISTTIMEFORMAT="%d/%m/%y %T "
shopt -s histappend