Skip to content

BastienDussap/command_bash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

My Bash Configuration

A collection of customizations for my .bashrc to improve productivity and command-line experience.

History Settings

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

Shell Options

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

Readline Bindings

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

Aliases

File Listing

alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'

Navigation

alias ..='cd ..'
alias ...='cd ../..'
alias c='clear'
alias root='cd ~/Metaflow/Metaflow-datascience'
alias bd='cd "$OLDPWD"'  # Go back to previous directory

System Utilities

alias 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.

Network

alias myip='curl -s ifconfig.me && echo'  # Public IP
alias localip="hostname -I | awk '{print \$1}'"  # Local IP

Safety

alias rm='rm -i'  # Ask before deleting
alias mv='mv -i'  # Ask before overwriting
alias cp='cp -i'  # Ask before overwriting

Git

alias 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.

Custom Functions

mkcd — Create and enter directory

mkcd() { mkdir -p "$1" && cd "$1"; }

extract — Universal archive extraction

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 — Timestamped backup

bak() { cp "$1" "$1".bak."$(date +%Y%m%d%H%M%S)"; }

Creates a backup with format: filename.bak.YYYYMMDDHHmmss

sysinfo — Quick system overview

sysinfo() {
    echo "=== Uptime ===" && uptime
    echo "=== Memory ===" && free -h
    echo "=== Disk ===" && df -h /
}

calc — Quick calculator

calc() { python3 -c "print($*)" ; }

About

Some commands for my .bashrc

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages