Created
September 6, 2025 08:48
-
-
Save aaronedev/caef63daf02c3e7ddbed9ff149971238 to your computer and use it in GitHub Desktop.
root bashrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # ━━━━━━━━━━━━━━━━━━━━━ Minimal Root Bashrc ━━━━━━━━━━━━━━━━━━━━━ | |
| # Minimal bash configuration for root based on user setup | |
| # Test for an interactive shell | |
| [[ $- != *i* ]] && return | |
| [[ -z "$PS1" ]] && return | |
| # Source system bashrc | |
| if [[ -f /etc/bashrc ]]; then | |
| source /etc/bashrc | |
| elif [[ -f /etc/bash.bashrc ]]; then | |
| source /etc/bash.bashrc | |
| fi | |
| # Basic colors | |
| RED="\033[38;2;255;26;103m" | |
| GREEN="\033[38;2;66;255;151m" | |
| YELLOW="\033[38;2;124;96;209m" | |
| BLUE="\033[38;2;41;173;255m" | |
| CYAN="\033[38;2;0;168;164m" | |
| BRIGHT_RED="\033[38;2;255;0;75m" | |
| BRIGHT_GREEN="\033[38;2;66;255;173m" | |
| BRIGHT_YELLOW="\033[38;2;253;124;255m" | |
| BRIGHT_BLUE="\033[38;2;199;184;255m" | |
| BRIGHT_CYAN="\033[38;2;0;255;249m" | |
| BRIGHT_WHITE="\033[38;2;231;231;231m" | |
| RESET="\033[0m" | |
| # Basic shell options | |
| shopt -s checkwinsize # Check window size after commands | |
| shopt -s histappend # Append to history file | |
| shopt -s cdspell # Autocorrect typos in path names | |
| shopt -s dirspell # Autocorrect typos in directory names | |
| shopt -s expand_aliases # Expand aliases | |
| # History configuration | |
| export HISTCONTROL=ignoreboth:erasedups | |
| export HISTSIZE=10000 | |
| export HISTFILESIZE=20000 | |
| export HISTIGNORE="ls:cd:pwd:exit:clear" | |
| # Essential aliases | |
| alias ll='ls -alF --color=auto' | |
| alias la='ls -A --color=auto' | |
| alias l='ls -CF --color=auto' | |
| alias ls='ls --color=auto' | |
| alias grep='grep --color=auto' | |
| alias ..='cd ..' | |
| alias ...='cd ../..' | |
| alias ....='cd ../../..' | |
| alias ~='cd ~' | |
| alias -- -='cd -' | |
| # Safety aliases | |
| alias rm='rm -i' | |
| alias cp='cp -i' | |
| alias mv='mv -i' | |
| alias mkdir='mkdir -p' | |
| # System aliases | |
| alias df='df -h' | |
| alias du='du -h' | |
| alias free='free -h' | |
| alias ps='ps aux' | |
| alias top='htop 2>/dev/null || top' | |
| alias mount='mount | column -t' | |
| # Network aliases | |
| alias ports='netstat -tulanp' | |
| alias listening='lsof -i -P -n | grep LISTEN' | |
| # Function to check if command exists | |
| hascommand() { | |
| command -v "$1" &> /dev/null | |
| } | |
| # Enhanced cd function | |
| cd() { | |
| if [[ $# -eq 0 ]]; then | |
| builtin cd "$HOME" | |
| elif [[ -f "$1" ]]; then | |
| builtin cd "$(dirname "$1")" | |
| else | |
| builtin cd "$@" | |
| fi | |
| ls --color=auto 2>/dev/null || ls | |
| } | |
| # Prompt | |
| if [[ $EUID -eq 0 ]]; then | |
| # Root prompt (red) | |
| PS1='\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\# ' | |
| else | |
| # Regular user prompt (green) | |
| PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' | |
| fi | |
| # Enable completion if available | |
| if [[ -f /etc/bash_completion ]] && ! shopt -oq posix; then | |
| source /etc/bash_completion | |
| elif [[ -f /usr/share/bash-completion/bash_completion ]] && ! shopt -oq posix; then | |
| source /usr/share/bash-completion/bash_completion | |
| fi | |
| # Load local customizations if they exist | |
| [[ -f /root/.bashrc.local ]] && source /root/.bashrc.local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment