# ~/.bash_aliases # # Simple command shortcuts. # Keep aliases boring and predictable. # # Rule of thumb: # Use aliases for short, simple substitutions. # Use functions for anything with arguments or logic. # ------------------------------------------------------------ # ls shortcuts # ------------------------------------------------------------ # Long listing, show almost all files, classify file types. alias ll='ls -alF' # Show hidden files except . and .. alias la='ls -A' # Compact listing with file type indicators. alias l='ls -CF' # Human-readable file sizes. alias lh='ls -lah' # ------------------------------------------------------------ # Safer file operations # ------------------------------------------------------------ # Ask before overwriting files. # # Some users like these safety aliases. # Others avoid them because they do not want different behavior # across different machines. # alias cp='cp -i' # alias mv='mv -i' # alias rm='rm -i' # Create parent directories automatically. # Example: # mkdir foo/bar/baz # alias mkdir='mkdir -p' # ------------------------------------------------------------ # Navigation # ------------------------------------------------------------ # Move up directories quickly. alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' alias .....='cd ../../../..' # Return to previous directory. alias -- -='cd -' # ------------------------------------------------------------ # Search # ------------------------------------------------------------ # Enable colored grep output. if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' fi # Common grep pattern: # recursive # line numbers # ignore binary files alias gr='grep -RIn --exclude-dir=.git' # ------------------------------------------------------------ # System information # ------------------------------------------------------------ # Human-readable disk usage. alias df='df -h' alias du='du -h' # Human-readable memory usage. alias free='free -h' # Show listening processes. # This may need sudo depending on the system. alias ports='ss -tulpn' # ------------------------------------------------------------ # History and jobs # ------------------------------------------------------------ # Short history command. alias h='history' # Show jobs with process IDs. alias j='jobs -l' # ------------------------------------------------------------ # Git # ------------------------------------------------------------ # --> set alias the git way, inside .gitconfig # ------------------------------------------------------------ # Convenience # ------------------------------------------------------------ # Print PATH one entry per line. alias path='echo "$PATH" | tr ":" "\n"' # Reload Bash config. # Useful after editing dotfiles. alias reload='source ~/.bashrc' # Clear screen but keep scrollback depending on terminal behavior. alias c='clear' # Add an "alert" alias for long running commands. Use like so: # sleep 10; alert alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'