From 164afc1c655b5dd53c30952962b6da66eb582b93 Mon Sep 17 00:00:00 2001 From: Lignum Crucis Date: Sat, 29 Aug 2026 01:23:49 -0300 Subject: feat: first commit --- .config/bash/bashrc | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .config/bash/bashrc (limited to '.config/bash/bashrc') diff --git a/.config/bash/bashrc b/.config/bash/bashrc new file mode 100644 index 0000000..26e8ee4 --- /dev/null +++ b/.config/bash/bashrc @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +# ~/.config/bash/bashrc +# Config principal do bash, seguindo XDG (chamado via ~/.bashrc) + +[[ $- != *i* ]] && return # só roda em shell interativo + +source "$HOME/.config/bash/aliases" + +### HISTÓRICO ### +export HISTFILE="$HOME/.local/state/bash/history" +if [ ! -f "$HISTFILE" ]; then mkdir -p "$(dirname "$HISTFILE")"; fi +export HISTSIZE=10000 +export HISTFILESIZE=20000 +export HISTCONTROL=ignoreboth:erasedups # ignora duplicatas e comandos com espaço na frente +shopt -s histappend # append em vez de overwrite entre sessões +shopt -s cmdhist # comandos multi-linha viram uma entrada só + +### NAVEGAÇÃO ### +shopt -s autocd +shopt -s cdspell +shopt -s dirspell +shopt -s globstar + +### COMPLETION NATIVA ### +bind "set completion-ignore-case on" # completion case-insensitive +bind "set show-all-if-ambiguous on" # mostra opções na primeira TAB, sem precisar apertar 2x +bind "set menu-complete-display-prefix on" + +if [ -f /usr/share/bash-completion/bash_completion ]; then + source "/usr/share/bash-completion/bash_completion" +elif [ -f /etc/bash_completion ]; then + source "/etc/bash_completion" +fi + +### CORES BASE (gruvbox-ish) ### +C_RESET="\[\e[0m\]" +C_USER="\[\e[38;5;214m\]" # laranja +C_DIR="\[\e[38;5;109m\]" # azul claro +C_GIT="\[\e[38;5;172m\]" # amarelo/mostarda +C_ERR="\[\e[38;5;167m\]" # vermelho + +### GIT BRANCH NO PROMPT ### +__git_branch() { + local branch + branch=$(git symbolic-ref --short HEAD 2>/dev/null) || \ + branch=$(git rev-parse --short HEAD 2>/dev/null) + [ -n "$branch" ] && printf " (%s)" "$branch" +} + +### MONTA O PROMPT ### +# Formato: [código-erro-se-houver] usuário@host diretório (git-branch) +# $ (usuário comum) ou # (root) +build_prompt() { + local last_exit=$? + PS1="" + if [ $last_exit -ne 0 ]; then + PS1+="${C_ERR}[${last_exit}]${C_RESET} " + fi + PS1+="${C_USER}\u@\h${C_RESET}:${C_DIR}\w${C_RESET}" + PS1+="${C_GIT}\$(__git_branch)${C_RESET}" + if [ "$(id -u)" -eq 0 ]; then + PS1+=" \[\e[1;31m\]#\[\e[0m\] " + else + PS1+=" \[\e[1m\]\$\[\e[0m\] " + fi +} +PROMPT_COMMAND="build_prompt" + +### VARIÁVEIS ÚTEIS ### +export EDITOR=nvim +export VISUAL=nvim +export LESSHISTFILE="$HOME/.local/state/bash/lesshst" + +# reorganize +set bell-style none -- cgit v1.2.3