From e77542ff57bf631b28855a3b29b4a5e33b7783c0 Mon Sep 17 00:00:00 2001 From: alexpolo1 Date: Sun, 9 Mar 2025 15:56:18 +0100 Subject: [PATCH] adding file --- .bashrc | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .bashrc diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..6cf7909 --- /dev/null +++ b/.bashrc @@ -0,0 +1,94 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# ------------------------------------------------------------------------------ +# ✅ Smart Command History Configuration +# ------------------------------------------------------------------------------ +HISTSIZE=100000 # Increase history size +HISTFILESIZE=200000 # Store more commands in history +HISTCONTROL=ignoredups:ignorespace # Ignore duplicate and space-prefixed commands +shopt -s histappend # Append to history instead of overwriting +export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" + +# Enable arrow key history search (search by typing & pressing Up/Down) +bind '"\e[A": history-search-backward' +bind '"\e[B": history-search-forward' + +# ------------------------------------------------------------------------------ +# ✅ Enable Fuzzy Search for Command History (Ctrl+R) +# ------------------------------------------------------------------------------ +if command -v fzf &>/dev/null; then + __fzf_history() { + BUFFER=$(history | fzf --height 40% --reverse | sed 's/^[ ]*[0-9]*[ ]*//') + echo $BUFFER + } + bind -x '"\C-r": __fzf_history' +fi + +# ------------------------------------------------------------------------------ +# ✅ Enable Colorized Command Output +# ------------------------------------------------------------------------------ +alias grep="grep --color=auto" +alias fgrep="fgrep --color=auto" +alias egrep="egrep --color=auto" +alias ping="ping -c 5" # Limit ping output + +# ------------------------------------------------------------------------------ +# ✅ Improved `ls` with `eza` (modern replacement for `ls`) +# ------------------------------------------------------------------------------ +if command -v eza &>/dev/null; then + alias ls="eza --icons --group-directories-first" + alias ll="eza -lh --icons --git" + alias la="eza -lha --icons --git" + alias lt="eza -T --icons" # Tree view +fi + +# ------------------------------------------------------------------------------ +# ✅ Useful Aliases for Faster Navigation and Commands +# ------------------------------------------------------------------------------ +alias ..="cd .." +alias ...="cd ../.." +alias ....="cd ../../.." +alias ~="cd ~" + +alias cpuinfo="lscpu" +alias meminfo="free -h" +alias diskinfo="df -h" + +# Git Aliases +alias gs="git status" +alias ga="git add ." +alias gc="git commit -m" +alias gp="git push" +alias gl="git log --oneline --graph --decorate --all" + +# Reload bashrc quickly +alias reload="source ~/.bashrc && echo 'Bash config reloaded! ✅'" + +# ------------------------------------------------------------------------------ +# ✅ Smart Git Prompt (Loads Only Inside Git Repos) +# ------------------------------------------------------------------------------ +if command -v git &>/dev/null && [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then + GIT_PROMPT_THEME=x-files-time + alias gpchange="bash $HOME/.bash-git-prompt/gpchange.sh" + alias gpthemes="bash $HOME/.bash-git-prompt/gpthemes.sh" + + # Load git prompt only inside git repositories + function __git_ps1_check() { + git rev-parse --is-inside-work-tree &>/dev/null && source "$HOME/.bash-git-prompt/gitprompt.sh" + } + PROMPT_COMMAND="__git_ps1_check;$PROMPT_COMMAND" +fi + +# ------------------------------------------------------------------------------ +# ✅ Fancy Welcome Message +# ------------------------------------------------------------------------------ +echo -e "\nWelcome back, $USER! 🚀" +echo "Today is $(date '+%A, %d %B %Y')." +echo "Uptime: $(uptime -p)" +echo "You are in: $(pwd)" +