-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
282 lines (248 loc) · 9.52 KB
/
.bashrc
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#!/usr/bin/env bash
# ~/.bashrc: executed by bash(1) for non-login shells.
# =============================================================== #
# PERSONAL $HOME/.bashrc FILE by PMA
# Consolidated from the default lubuntu 20.04 .bashrc and the ff:
# https://tldp.org/LDP/abs/html/sample-bashrc.html
# https://github.com/slomkowski/bash-full-of-colors
# =============================================================== #
#-------------------------------------------------------------
# If not running interactively, don't do anything
#-------------------------------------------------------------
[ -z "$PS1" ] && return
#-------------------------------------------------------------
# Source global definitions (if any)
#-------------------------------------------------------------
if [ -f /etc/bashrc ]; then
. /etc/bashrc # --> Read /etc/bashrc, if present.
fi
#-------------------------------------------------------------
# Import Bash Variables
#-------------------------------------------------------------
if [ -f ~/.bashfns ]; then
. ~/.bashvars
fi
#-------------------------------------------------------------
# don't put duplicate lines in the history.
# See bash(1) for more options
# ... or force ignoredups and ignorespace
#-------------------------------------------------------------
#HISTCONTROL=ignoredups:ignorespace
HISTCONTROL=ignoreboth
#-------------------------------------------------------------
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE
# in bash(1)
HISTSIZE=200
HISTFILESIZE=400
export TIMEFORMAT=$'\nreal %3R\tuser %3U\tsys %3S\tpcpu %P\n'
export HISTIGNORE="&:bg:fg:ll:h"
export HISTTIMEFORMAT="$(echo -e ${BCyan})[%d/%m %H:%M:%S]$(echo -e ${NC}) "
#export HISTCONTROL=ignoredups
#export HOSTFILE=$HOME/.hosts # Put a list of remote hosts in ~/.hosts
#-------------------------------------------------------------
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
#-------------------------------------------------------------
shopt -s checkwinsize
#-------------------------------------------------------------
# make less more friendly for non-text input files,
# see lesspipe(1)
#-------------------------------------------------------------
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
#-------------------------------------------------------------
# set variable identifying the chroot you work in
# (used in the prompt below)
#-------------------------------------------------------------
if [ -z "${debian_chroot}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
#-------------------------------------------------------------
# Some settings
#-------------------------------------------------------------
#set -o nounset # These two options are useful for debugging.
#set -o xtrace
alias debug="set -o nounset; set -o xtrace"
ulimit -S -c 0 # Don't want coredumps.
set -o notify
set -o noclobber
set -o ignoreeof
# Enable options:
shopt -s cdspell
shopt -s cdable_vars
shopt -s checkhash
shopt -s checkwinsize
shopt -s sourcepath
shopt -s no_empty_cmd_completion
shopt -s cmdhist
shopt -s histappend histreedit histverify
shopt -s extglob # Necessary for programmable completion.
# Disable options:
shopt -u mailwarn
unset MAILCHECK # Don't want my shell to warn me of incoming mail.
#-------------------------------------------------------------
# Welcome Greeting
#-------------------------------------------------------------
#echo -e "${BCyan}This is BASH ${BRed}${BASH_VERSION%.*}${BCyan}\
# - DISPLAY on ${BRed}$DISPLAY${NC}\n"
if [ -x "`which neofetch 2>&1`" ]; then
neofetch;
fishlogin;
neofetch;
fi
date
#-------------------------------------------------------------
# Shell Prompt - for many examples, see:
# http://www.debian-administration.org/articles/205
# http://www.askapache.com/linux/bash-power-prompt.html
# http://tldp.org/HOWTO/Bash-Prompt-HOWTO
# https://github.com/nojhan/liquidprompt
#-------------------------------------------------------------
# Current Format: [TIME USER@HOST PWD] >
# TIME:
# Green == machine load is low
# Orange == machine load is medium
# Red == machine load is high
# ALERT == machine load is very high
# USER:
# Cyan == normal user
# Orange == SU to user
# Red == root
# HOST:
# Cyan == local session
# Green == secured remote connection (via ssh)
# Red == unsecured remote connection
# PWD:
# Green == more than 10% free disk space
# Orange == less than 10% free disk space
# ALERT == less than 5% free disk space
# Red == current user does not have write privileges
# Cyan == current filesystem is size zero (like /proc)
# >:
# White == no background or suspended jobs in this shell
# Cyan == at least one background job in this shell
# Orange == at least one suspended job in this shell
#
# Command is added to the history file each time you hit enter,
# so it's available to all shells (using 'history -a').
# Test connection type:
if [ -n "${SSH_CONNECTION}" ]; then
CNX=${Green} # Connected on remote machine, via ssh (good).
elif [[ "${DISPLAY%%:0*}" != "" ]]; then
CNX=${ALERT} # Connected on remote machine, not via ssh (bad).
else
CNX=${BCyan} # Connected on local machine.
fi
# Test user type:
if [[ ${USER} == "root" ]]; then
SU=${Red} # User is root.
elif [[ ${USER} != ${logname} ]]; then
SU=${BRed} # User is not login user.
else
SU=${BCyan} # User is normal (well ... most of us are).
fi
NCPU=$(grep -c 'processor' /proc/cpuinfo) # Number of CPUs
SLOAD=$(( 100*${NCPU} )) # Small load
MLOAD=$(( 200*${NCPU} )) # Medium load
XLOAD=$(( 400*${NCPU} )) # Xlarge load
#-------------------------------------------------------------
# Import Bash Functions
#-------------------------------------------------------------
if [ -f ~/.bashfns ]; then
. ~/.bashfns
fi
#-------------------------------------------------------------
# PROMPT1
#-------------------------------------------------------------
# Now we construct the prompt.
PROMPT_COMMAND="history -a"
case ${TERM} in
*term | rxvt | linux | xterm-256color )
PS1="\[\$(load_color)\][\A\[${NC}\] "
# Time of day (with load info):
PS1="\[\$(load_color)\][\A\[${NC}\] "
# User@Host (with connection type info):
PS1=${PS1}"\[${SU}\]\u\[${NC}\]@\[${CNX}\]\h\[${NC}\] "
# PWD (with 'disk space' info):
PS1=${PS1}"\[\$(disk_color)\]\W]\[${NC}\] "
# Prompt (with 'job' info):
PS1=${PS1}"\[\$(job_color)\]>\[${NC}\] "
# Set title of current xterm:
PS1=${PS1}"\[\e]0;[\u@\h] \w\a\]"
;;
*)
PS1="(\A \u@\h \W) > " # --> PS1="(\A \u@\h \w) > "
# --> Shows full pathname of current dir.
;;
esac
#-------------------------------------------------------------
# PROMPT2
#-------------------------------------------------------------
# case "$TERM" in
# xterm-color|*-256color) color_prompt=yes;;
# esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
# #force_color_prompt=yes
# if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null
# then
# # We have color support; assume it's compliant with Ecma-48
# # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# # a case would tend to support setf rather than setaf.)
# color_prompt=yes
# else
# color_prompt=
# fi
# if [ "$color_prompt" = yes ]; then
# PROMPT_COMMAND=__makePS1
# PS2="\[${BPurple}\]>\[${Color_Off}\] " # continuation prompt
# else
# PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
# fi
# unset color_prompt force_color_prompt
#-------------------------------------------------------------
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
#-------------------------------------------------------------
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
#-------------------------------------------------------------
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -f ~/.bash_local ]; then
. ~/.bash_local
fi
#-------------------------------------------------------------
# See https://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html
#-------------------------------------------------------------
# -- if normal user umask
umask 002
# -- if root umask
# umask 022
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
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
fi
source "$HOME/.cargo/env"