A collection of customizations for my .bashrc to improve productivity and command-line experience.
HISTSIZE=10000
HISTFILESIZE=20000
HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
HISTIGNORE="&:ls:cd:pwd:exit:fg:bg:history"| Variable | Description |
|---|---|
HISTSIZE |
Number of commands kept in memory (10,000) |
HISTFILESIZE |
Number of commands stored in history file (20,000) |
HISTTIMEFORMAT |
Adds timestamps to history entries |
HISTIGNORE |
Excludes common commands from history to reduce noise |
shopt -s checkwinsize
shopt -s globstar
shopt -s autocd
shopt -s cdspell
shopt -s dirspell| Option | Description |
|---|---|
checkwinsize |
Updates LINES and COLUMNS after each command |
globstar |
Enables ** pattern to match files recursively |
autocd |
Type a directory name to cd into it directly |
cdspell |
Auto-corrects typos in cd commands |
dirspell |
Auto-corrects typos in tab completion |
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
bind 'set completion-ignore-case on'
bind 'set show-all-if-ambiguous on'- Arrow keys: Search history based on current input prefix
- Case-insensitive completion: Tab completion ignores case
- Show all if ambiguous: Display all matches immediately without requiring a second Tab press
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'alias ..='cd ..'
alias ...='cd ../..'
alias c='clear'
alias root='cd ~/Metaflow/Metaflow-datascience'
alias bd='cd "$OLDPWD"' # Go back to previous directoryalias df='df -h'
alias du='du -h'
alias free='free -h'
alias ports='ss -tulanp'
alias dsize='du -sh * | sort -hr'
alias topmem='ps aux --sort=-%mem | head -11'
alias topcpu='ps aux --sort=-%cpu | head -11'All display human-readable sizes by default.
alias myip='curl -s ifconfig.me && echo' # Public IP
alias localip="hostname -I | awk '{print \$1}'" # Local IPalias rm='rm -i' # Ask before deleting
alias mv='mv -i' # Ask before overwriting
alias cp='cp -i' # Ask before overwritingalias gitlog="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'"Pretty graph view of git history with colors and relative dates.
mkcd() { mkdir -p "$1" && cd "$1"; }extract() {
if [ -f "$1" ]; then
case "$1" in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.tar.xz) tar xJf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xf "$1" ;;
*.zip) unzip "$1" ;;
*.7z) 7z x "$1" ;;
*) echo "Format non reconnu: $1" ;;
esac
fi
}Supports: .tar.bz2, .tar.gz, .tar.xz, .bz2, .gz, .tar, .zip, .7z
bak() { cp "$1" "$1".bak."$(date +%Y%m%d%H%M%S)"; }Creates a backup with format: filename.bak.YYYYMMDDHHmmss
sysinfo() {
echo "=== Uptime ===" && uptime
echo "=== Memory ===" && free -h
echo "=== Disk ===" && df -h /
}calc() { python3 -c "print($*)" ; }