-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bashrc
More file actions
104 lines (89 loc) · 3.41 KB
/
Copy path.bashrc
File metadata and controls
104 lines (89 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# =============================================================================
# .bashrc — Enhanced Bourne-Again Shell Configuration
# Part of the linux-environment dotfiles project
# =============================================================================
# --- Source aliases if present -------------------------------------------------
if [ -f ~/.aliases ]; then
. ~/.aliases
fi
# --- Shell options -------------------------------------------------------------
shopt -s autocd # cd by typing directory name
shopt -s cdspell # auto-correct typos in cd
shopt -s checkwinsize # update LINES/COLUMNS after resize
shopt -s histappend # append to history, don't overwrite
shopt -s no_empty_cmd_completion
shopt -s globstar # ** globbing
# --- History settings ----------------------------------------------------------
HISTSIZE=10000
HISTFILESIZE=20000
HISTCONTROL=ignoreboth:erasedups
HISTTIMEFORMAT="%F %T "
HISTIGNORE="ls:ll:la:cd:exit:pwd:clear:history"
# --- Prompt --------------------------------------------------------------------
# Colors (emerald green palette)
emerald="\[\e[38;5;83m\]"
cyan="\[\e[38;5;81m\]"
white="\[\e[38;5;255m\]"
yellow="\[\e[38;5;228m\]"
red="\[\e[38;5;196m\]"
reset="\[\e[0m\]"
bold="\[\e[1m\]"
# Git branch/status for prompt
__git_ps1() {
local branch=$(git symbolic-ref --short HEAD 2>/dev/null)
if [ -n "$branch" ]; then
local status=$(git status --porcelain 2>/dev/null)
if [ -n "$status" ]; then
echo " ${yellow}(${branch} ✗)${reset}"
else
echo " ${emerald}(${branch} ✓)${reset}"
fi
fi
}
# Exit status coloring
__exit_status() {
if [ $? -eq 0 ]; then
echo -e "${emerald}❯${reset}"
else
echo -e "${red}❯${reset}"
fi
}
# Build PS1
PS1='\n\[${bold}\]${emerald}\u${white}@${emerald}\h ${cyan}\w${reset}$(__git_ps1)\n$(__exit_status) '
# --- Auto-completion -----------------------------------------------------------
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Complete hostnames in known_hosts for ssh/scp
[ -r /etc/ssh/ssh_known_hosts ] && _SSH_HOSTS=($(awk '{print $1}' /etc/ssh/ssh_known_hosts 2>/dev/null))
complete -W "${_SSH_HOSTS[*]}" ssh scp sftp
# --- Misc ----------------------------------------------------------------------
# Set default editor
export EDITOR=vim
export VISUAL=vim
# Better man pages with color
export MANPAGER="less -R"
export LESS_TERMCAP_mb=$'\e[1;31m'
export LESS_TERMCAP_md=$'\e[1;38;5;83m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[1;40;5;7m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[4;38;5;81m'
# --- PATH ----------------------------------------------------------------------
export PATH="$HOME/.local/bin:$HOME/tools:$PATH"
# --- Node.js (if available) ----------------------------------------------------
if [ -d "$HOME/.nvm" ]; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
fi
# --- Rust (if available) -------------------------------------------------------
if [ -f "$HOME/.cargo/env" ]; then
. "$HOME/.cargo/env"
fi
# --- Starship fallback (if installed) ------------------------------------------
if command -v starship &>/dev/null; then
eval "$(starship init bash)"
fi