-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bashrc
More file actions
145 lines (117 loc) · 4.06 KB
/
.bashrc
File metadata and controls
145 lines (117 loc) · 4.06 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# ~/.bashrc - sourced for non-login interactive shells
# Exit early if not interactive
case $- in
*i*) ;;
*) return ;;
esac
######################
# History Management #
######################
HISTCONTROL=ignoreboth
shopt -s histappend
HISTSIZE=10000
HISTFILESIZE=20000
#########################
# Window Resize Support #
#########################
shopt -s checkwinsize
#############################
# Lesspipe for non-text I/O #
#############################
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
##################################
# Prompt Customization & Colors #
##################################
# Set chroot name if applicable
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# Minimal git segment for the prompt.
__prompt_git() {
command -v git >/dev/null 2>&1 || return 0
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return 0
local branch
branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null) || return 0
local dirty=""
git diff --quiet --ignore-submodules --cached && git diff --quiet --ignore-submodules || dirty="*"
printf " (%s%s)" "$branch" "$dirty"
}
__prompt_host="${HOSTNAME%%.*}"
__prompt_title() {
case "$TERM" in
xterm*|rxvt*)
local title_path="${PWD/#$HOME/~}"
printf '\033]0;%s\007' "${debian_chroot:+($debian_chroot)}${USER}@${__prompt_host}: ${title_path}"
;;
esac
}
__prompt_set() {
local exit_code=$?
local reset="\[\033[0m\]"
local dim="\[\033[38;2;127;132;156m\]"
local blue="\[\033[38;2;137;180;250m\]"
local green="\[\033[38;2;166;227;161m\]"
local cyan="\[\033[38;2;148;226;213m\]"
local yellow="\[\033[38;2;249;226;175m\]"
local red="\[\033[38;2;243;139;168m\]"
local status_color="$green"
if [ "$exit_code" -ne 0 ]; then
status_color="$red"
fi
local chroot="${debian_chroot:+($debian_chroot) }"
local venv=""
if [ -n "${VIRTUAL_ENV:-}" ]; then
venv=" (${VIRTUAL_ENV##*/})"
fi
local git="$(__prompt_git)"
PS1="${dim}${chroot}[${blue}\u@\h${dim}] [${green}\w${dim}]${cyan}${venv}${yellow}${git}${dim} [${status_color}${exit_code}${dim}]\n${blue}> ${reset}"
}
if [[ "$PROMPT_COMMAND" != *"__prompt_set"* ]]; then
if [[ -n "$PROMPT_COMMAND" ]]; then
PROMPT_COMMAND="__prompt_title; __prompt_set; $PROMPT_COMMAND"
else
PROMPT_COMMAND="__prompt_title; __prompt_set"
fi
fi
#############################
# Color and Useful Aliases #
#############################
if [ -x /usr/bin/dircolors ]; then
eval "$(dircolors -b ~/.dircolors 2>/dev/null || dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
##################################
# Load Personal Aliases & Extras #
##################################
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
[ -f ~/.bash_functions ] && . ~/.bash_functions
#######################################
# Bash Completion (common environments)
#######################################
if ! shopt -oq posix; then
[ -f /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
[ -f /etc/bash_completion ] && . /etc/bash_completion
fi
##################################
# Machine-Specific Customization #
##################################
[ -f ~/.bash_local ] && . ~/.bash_local
# Set TERM for tmux
if [ -n "$TMUX" ]; then
export TERM=tmux-256color
fi
#############################
# Python/ML Optimizations #
#############################
export PYTHONDONTWRITEBYTECODE=1
export PYTHONUNBUFFERED=1
export CUDA_DEVICE_ORDER=PCI_BUS_ID
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[ -f "$HOME/.local/bin/env" ] && . "$HOME/.local/bin/env"
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
export PATH="$HOME/.local/bin:$PATH"