-
Notifications
You must be signed in to change notification settings - Fork 1
/
dot_bashrc
658 lines (564 loc) · 20.8 KB
/
dot_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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
# System-wide .bashrc file for interactive bash(1) shells.
# This file is NOT PART of YMMV's MIT LICENSE CONTENT
# as it is modified from versious projects and thus my contributions
# are probably subject to GPL ... so assume this file is GPL covered.
# ensure LC_TYPE is set early.
export LC_CTYPE="${LC_CTYPE:-en_US}"
# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.
if [[ ( `umask` -le 27 ) ]] ; then umask 022 ; fi ;
#===============================================================
#
# FUNCTIONS
#
# Arguably, some functions defined here are quite big.
# If you want to make this file smaller, these functions can
# be converted into scripts and removed from here.
#
# Many functions were taken (almost) straight from the bash-2.04
# examples.
#
#===============================================================
# configure paths
function pathappend() {
for PATH_ARG in "$@" ; do
if [[ -d "$PATH_ARG" ]] && [[ ":$PATH:" != *":$PATH_ARG:"* ]] ; then
PATH="${PATH:+"$PATH:"}$PATH_ARG" ;
export PATH ;
fi
done
unset PATH_ARG 2>/dev/null || true ;
}
function manappend() {
for MAN_ARG in "$@" ; do
if [[ -d "$MAN_ARG" ]] && [[ ":$MANPATH:" != *":$MAN_ARG:"* ]] ; then
MANPATH="${MANPATH:+"$MANPATH:"}$MAN_ARG" ;
export MANPATH ;
fi
done
unset MAN_ARG 2>/dev/null || true ;
}
#-------------------------------------------------------------
# PATH configuration
#-------------------------------------------------------------
# System-wide .bashrc file for interactive bash(1) shells.
if [[ $OSTYPE =~ "darwin" ]] ; then
if [[ ! ${POSIXLY_CORRECT} ]] ; then
# MacOS uses the getconf style
PATH=$(getconf PATH) ;
export DEVELOPER_DIR=${DEVELOPER_DIR:-$(xcode-select -p)} ;
export PATH ;
else
# this seems to be better then the macOS default path (for posix)
export PATH=${PATH:-"/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin:."}
fi
# configure dev mode if needed
DEVELOPER_BIN_DIR=${DEVELOPER_BIN_DIR:-$(find $(xcode-select -p)/usr \( -iname "*bin" -a -type d \) -print | head -n 1 ; wait )} ;
if [[ -d "$DEVELOPER_BIN_DIR" ]] && [[ ":$PATH:" != "${DEVELOPER_BIN_DIR}:"* ]] ; then
PATH="$DEVELOPER_BIN_DIR:${PATH}" ;
export PATH ;
fi
fi
pathappend ${HOME}/homebrew/bin
pathappend ${HOME}/homebrew/sbin
pathappend /usr/local/bin
pathappend /usr/local/sbin
pathappend ${HOME}/bin
pathappend /Applications/Docker.app/Contents/Resources/sbin
pathappend /Applications/Docker.app/Contents/Resources/bin
pathappend /usr/local/MacGPG2/bin
pathappend /opt/local/bin
pathappend /opt/local/sbin
#pathappend ${HOME}/Library/Python/3.4/bin
#pathappend ${HOME}/Library/Python/3.5/bin
#pathappend ${HOME}/Library/Python/3.7/bin
#pathappend ${HOME}/Library/Python/3.8/bin
pathappend ${HOME}/Library/Python/3.12/bin
pathappend ${HOME}/Library/Python/3.11/bin
pathappend ${HOME}/Library/Python/3.10/bin
pathappend ${HOME}/Library/Python/3.9/bin
# Some KNOW what they are doing
# pathappend ${HOME}/Library/Python/2.7/bin
#-------------------------------------------------------------
# Script configuration (if any)
#-------------------------------------------------------------
if [[ ! ${POSIXLY_CORRECT} ]] ; then
# idea from https://rakhesh.com/mac/macos-launchctl-commands/
export XPC_SERVICE_NAME=$(echo -n ""$(head -n 1 <(launchctl list 2>/dev/null | grep -F com.apple.Terminal. 2>/dev/null | tr -s '\t ' ' ' 2>/dev/null | cut -d\ -f 3-3) 2>/dev/null )"$$" )
export TMPDIR=$(getconf DARWIN_USER_TEMP_DIR)
fi
export TMOUT=${TMOUT:-0}
# enable this to force color use
#export CAN_USE_COLOR_IN_ENVIORMENT=1 ;
#-------------------------------------------------------------
# Source global definitions (if any)
#-------------------------------------------------------------
if [[ $( command uname -s ) == "Darwin" ]] ; then
export BASH_SILENCE_DEPRECATION_WARNING=1
fi
if [[ ( ${FORCE_RELOAD_BASH_ENV:-2} -ge 1 ) ]] ; then
if [[ ( -r /etc/environment ) ]] ; then
source /etc/environment ; # --> Read /etc/environment, if present.
export FORCE_RELOAD_BASH_ENV=0;
fi
if [[ ( -z ${PKG_CONFIG_PATH} ) ]] ; then
if [[ $( command uname -s ) == "Darwin" ]] ; then
export PKG_CONFIG_PATH=$( (system_profiler SPFrameworksDataType 2>/dev/null | grep -F "Location: " | cut -d\: -f2- ; wait ;) | xargs -L1 -I{} find {} -iname "*.pc" -print 2>/dev/null ; wait ; ) ;
fi ;
fi
fi
if [[ -d "${HOME}"/.bin/ ]]; then
alias mybin='$HOME/.bin' # --> add my own bin to path,
pathappend "${HOME}"/.bin
else
alias mybin='$HOME/bin' # --> add my own bin to path,
fi
# harden homebrew
export HOMEBREW_NO_ANALYTICS=1 ;
export HOMEBREW_NO_INSECURE_REDIRECT=1 ;
export HOMEBREW_CASK_OPTS=--require-sha ;
#--------------------------------------------------------------
# Automatic setting of $DISPLAY (if not set already).
# This works for me - your mileage may vary. . . .
# The problem is that different types of terminals give
#+ different answers to 'who am i' (rxvt in particular can be
#+ troublesome) - however this code seems to work in a majority
#+ of cases.
#--------------------------------------------------------------
function get_xserver ()
{
case $TERM in
xterm*color)
XSERVER=$(who am i | grep -oE "([12]?[0-9]?[0-9]{1}[\.]{1}){3}([12]?[0-9]?[0-9]{1}){1}" | head -n 1 ) ;
# Ane-Pieter Wieringa suggests the following alternative:
# I_AM=$(who am i)
# SERVER=${I_AM#*(}
# SERVER=${SERVER%*)}
XSERVER=${XSERVER%%:*} ;
CAN_USE_COLOR_IN_ENVIORMENT=1 ;
;;
xterm*)
XSERVER=$(who am i | awk '{print $NF}' | tr -d ')''(' ) ;
# Ane-Pieter Wieringa suggests the following alternative:
# I_AM=$(who am i)
# SERVER=${I_AM#*(}
# SERVER=${SERVER%*)}
XSERVER=${XSERVER%%:*} ;
;;
aterm | rxvt)
# Find some code that works here. ...
;;
esac
}
if [ -z ${DISPLAY:-""} ]; then
get_xserver
if [[ -z ${XSERVER} || ${XSERVER} == $(hostname) || ${XSERVER} == "unix" ]]; then
DISPLAY="${HOSTNAME:-127.0.0.1}:0.0" # Display on local host.
else
DISPLAY=${XSERVER:-127.0.0.1}:0.0 # Display on remote host.
fi
fi
declare USE_COLOR_IN_ENVIORMENT="${USE_COLOR_IN_ENVIORMENT:-${CAN_USE_COLOR_IN_ENVIORMENT:-0}}" ;
export DISPLAY ;
export USE_COLOR_IN_ENVIORMENT ;
export TZ='America/Los_Angeles' ;
#-------------------------------------------------------------
# GPG Setup
#-------------------------------------------------------------
if [[ !( $(shopt -q login_shell) ) ]] ; then
# ensure that the gpg agent is working with bash env
if [[ ( -f "${HOME}/.gpg-agent-info" ) ]] && [[ !( $( \uname -s ) == "Darwin" ) ]] ; then
# load current GPG/SSH helper agents info
source "${HOME}/.gpg-agent-info" ;
# setup the GPG/SSH environment to use helper agents (i.e make sub-shells work too)
export GPG_AGENT_INFO ;
export SSH_AUTH_SOCK ;
export SSH_AGENT_PID ;
# setup the GPG PID to use the current agent (i.e make sub-shells work too)
export GPG_AGENT_PID=$(echo "${GPG_AGENT_INFO}" | cut -d : -f 2 ) ;
else
# close any stale helper agents
# need to add loop while more than one
pkill -15 gpg-agent 2>/dev/null || true ;
pkill -9 ssh-agent 2>/dev/null || true ;
# Launch new helper agent
if [[ $( command uname -s ) == "Darwin" ]] && [[ -x /usr/local/MacGPG2/bin/gpg-agent ]] ; then
eval $(/usr/local/MacGPG2/bin/gpg-agent --enable-ssh-support --ssh-fingerprint-digest SHA256 --homedir=${HOME}/.gnupg/ --daemon -s )
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
else
export SSH_AUTH_SOCK=${SSH_AUTH_SOCK} ;
fi
elif [[ ( -x $(command -v gpg-agent) ) ]] ; then
eval $(gpg-agent -s --enable-ssh-support --daemon --write-env-file )
# if your implementation is missing --write-env-file, and does not create the .gpg-agent-info file uncomment the following
# echo "GPG_AGENT_INFO=${GPG_AGENT_INFO} ; export GPG_AGENT_INFO" > "${HOME}/.gpg-agent-info"
# echo "SSH_AUTH_SOCK=${SSH_AUTH_SOCK} ; export SSH_AUTH_SOCK" >> "${HOME}/.gpg-agent-info"
# echo "SSH_AGENT_PID=${SSH_AGENT_PID} ; export SSH_AGENT_PID" >> "${HOME}/.gpg-agent-info"
# echo "GPG_AGENT_PID=$(echo "${GPG_AGENT_INFO}" | cut -d : -f 2 ) ; export GPG_AGENT_PID" >> "${HOME}/.gpg-agent-info"
fi
export GPG_AGENT_PID=$(pgrep -nf "gpg-agent" | tail -n 1) ;
export SSH_AGENT_PID=${GPG_AGENT_PID:-${SSH_AGENT_PID}} ;
if [[ -e ${HOME}/.gnupg/.S.gpg-agent ]] ; then
export GPG_AGENT_INFO="${HOME}/.gnupg/.S.gpg-agent:${GPG_AGENT_PID}:1" ;
fi
fi
export GPG_TTY=$(tty)
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
#shopt -uo history
# 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
shopt -s histverify
shopt -s extglob # Necessary for programmable completion.
shopt -s hostcomplete
shopt -s interactive_comments
shopt -s huponexit
# Disable options:
shopt -u mailwarn
unset MAILCHECK # Don't want my shell to warn me of incoming mail.
#
# not portable on all systems
export HISTFILE=${HISTFILE:-"${HOME}/.bash_history"}
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoreboth
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If not running interactively, don't do anything
#[[ !( $(shopt -q login_shell) ) ]] && return
[ -z "$PS1" ] && return
umask 027
#-------------------------------------------------------------
# Greeting, motd etc...
#-------------------------------------------------------------
# Define some colors first:
# <=---------- Red ----------=>
declare red=${red:='\e[0;31m'};
declare RED=${RED:='\e[1;31m'};
declare On_Red=${On_Red:='\e[41m'};
# <=--------- Green ---------=>
declare green=${green:='\e[0;32m'};
declare GREEN=${GREEN:='\e[1;32m'};
declare On_Green=${On_Green:='\e[42m'};
# <=-------- Yellow ---------=>
declare yellow=${yellow:='\e[0;33m'};
declare YELLOW=${YELLOW:='\e[1;33m'};
declare On_Yellow=${On_Yellow:='\e[43m'};
# <=--------- Blue ----------=>
declare blue=${blue:='\e[0;34m'};
declare BLUE=${BLUE:='\e[1;34m'};
declare On_Blue=${On_Blue:='\e[44m'};
declare cyan=${cyan:='\e[0;36m'};
declare CYAN=${CYAN:='\e[1;36m'};
declare On_Cyan=${On_Cyan:='\e[46m'};
# <=-------- Megenta --------=>
declare megenta=${megenta:='\e[0;35m'};
declare MEGENTA=${MEGENTA:='\e[1;35m'};
declare On_Megenta=${On_Megenta:='\e[45m'};
# <=----- Black & White -----=>
declare black=${black:='\e[0;30m'};
declare white=${white:='\e[0;37m'};
declare WHITE=${WHITE:='\e[1;37m'};
# Background
declare On_Black=${On_Black:='\e[40m'};
declare On_White=${On_White:='\e[47m'};
# ANSI/VT100 Control sequences for colored error logs.
# ANSI/VT100 Control sequences for colored error logs.
declare -r err_badge="${RED}${On_Black}ERR!${NC}" ;
if [[ -x $(command -pv xxd) ]] ; then
declare -r error_badge=${RED}${On_Black}$(echo -n "e29c98" | xxd -r -pi)${NC} ;
declare -r tick_symbol=${GREEN}$(echo -n "e29c94" | xxd -r -pi)${NC} ;
else
# this is nice but if we have xxd it is better
declare -r error_badge=${RED}${On_Black}"\\xE2\\x9C\\x98"${NC} ;
declare -r tick_symbol=${GREEN}"\\xE2\\x9C\\x94"${NC} ;
fi
declare NC=$'\e[0m' ; # No Color
declare UNDERLINE='\e[4;1m' ; # Underline
# --> Nice. Has the same effect as using "ansi.sys" in DOS.
if [[ $USE_COLOR_IN_ENVIORMENT -ge 1 ]] ; then
export red ;
export RED ;
export On_Red ;
export green ;
export GREEN ;
export On_Green ;
export yellow ;
export YELLOW ;
export On_Yellow ;
export blue ;
export BLUE ;
export On_Blue ;
export cyan ;
export CYAN ;
export On_Cyan ;
export On_White ;
export white ;
export WHITE ;
export On_Black ;
export black ;
export BLACK ;
export NC ;
export error_badge ;
export tick_symbol ;
ALERT="${WHITE}${On_Red}" ; # Bold White on red background
export ALERT ;
function alertMessage() {
printf "${NC}${ALERT} ${@} ${NC}\n" ;
return ;
}
alias grep='grep --color=auto' ;
alias ls='ls -G' ;
alias echo='\echo -e' ;
function _exit() # Function to run upon exit of shell.
{
echo -e "${RED}Goodbye ${LOGNAME}${NC}" ;
}
else
function _exit() # Function to run upon exit of shell.
{
echo "Goodbye ${LOGNAME}" ;
}
fi
# If not running interactively, don't do anything
#[[ !( $(shopt -q login_shell) ) ]] && return
trap _exit EXIT
trap _exit QUIT
if [[ $USE_COLOR_IN_ENVIORMENT -ge 1 ]] ; then
# Test connection type:
if [ -n "${SSH_CONNECTION}" ]; then
CNX=${BLUE} # Connected on remote machine, via ssh (good).
elif [[ "${DISPLAY%%:0*}" != "" ]]; then
CNX=${ALERT} # Connected on remote machine, not via ssh (bad).
else
CNX=${WHITE} # Connected on local machine.
fi
# Test user type:
if [[ ${USER} == "root" ]]; then
SU=${RED} # User is root.
elif [[ ${USER} != $(logname) ]]; then
SU=${yellow} # User is not login user.
else
SU=${NC} # User is normal (well ... most of us are).
fi
NCPU=1
if [[ ( `uname -s` == "Darwin" ) ]] ; then
NCPU=$(sysctl -n hw.ncpu 2>/dev/null)
else
NCPU=$(grep -c 'processor' /proc/cpuinfo 2>/dev/null) # Number of CPUs
fi
SLOAD=$(( 100*${NCPU:-1} )) # Small load
MLOAD=$(( 200*${NCPU:-1} )) # Medium load
XLOAD=$(( 400*${NCPU:-1} )) # Xlarge load
# Returns system load as percentage, i.e., '40' rather than '0.40)'.
function load()
{
if [[ ( `uname -s` == "Darwin" ) ]] ; then
local SYSLOAD=$(uptime | cut -d: -f3-4 | cut -d\ -f2 | tr -d '.' | head -n 1)
# System load of the current host.
echo -n $((10#$SYSLOAD)) # Convert to decimal.
else
local SYSLOAD=$(cut -d\ -f1 /proc/loadavg | tr -d '.')
# System load of the current host.
echo -n $((10#$SYSLOAD)) # Convert to decimal.
fi
}
# Returns a color indicating system load.
function load_color()
{
local SYSLOAD=$(load)
if [ ${SYSLOAD} -gt ${XLOAD} ]; then
echo -en "${ALERT}" ;
elif [ ${SYSLOAD} -gt ${MLOAD} ]; then
echo -en "${red}" ;
elif [ ${SYSLOAD} -gt ${SLOAD} ]; then
echo -en "${RED}" ;
else
echo -en "${green}" ;
fi
}
# Returns a color according to free disk space in $PWD.
function disk_color()
{
if [ ! -w "${PWD}" ] ; then
echo -en "${red}" ;
# No 'write' privilege in the current directory.
elif [ -s "${PWD}" ] ; then
local used=$(command df -P "$PWD" | awk 'END {print $5} {sub(/%/,"")}' | grep -oE "\d+" | tail -n +1 )
if [ ${used} -gt 95 ]; then
echo -en "${ALERT}" ; # Disk almost full (>95%).
elif [ ${used} -gt 90 ]; then
echo -en "${RED}" ; # Free disk space almost gone.
elif [ ${used} -gt 80 ]; then
echo -en "${yellow}" ; # Free disk space rather low.
else
echo -en "${GREEN}" ; # Free disk space is ok.
fi ;
else
echo -en "${green}" ;
# Current directory is size '0' (like /proc, /sys etc).
fi ;
}
# Returns a color according to running/suspended jobs.
function job_color()
{
if [ $(jobs -s | wc -l) -gt "0" ]; then
echo -en "${RED}" ;
elif [ $(jobs -r | wc -l) -gt "0" ] ; then
echo -en "${CYAN}" ;
fi
}
# Adds some text in the terminal frame (if applicable).
# Now we construct the prompt.
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND; }history -a"
case ${TERM} in
*term | *term-*color | rxvt | linux)
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
export HISTTIMEFORMAT="[%y/%m/%d %H:%M:%S] ";
#-------------------------------------------------------------
# Tailoring 'less'
#-------------------------------------------------------------
alias more='less'
export LESSCHARSET='utf-8'
if [[ ( -x /usr/bin/lesspipe.sh ) ]] ; then
export LESSOPEN='|/usr/bin/lesspipe.sh %s 2>&-' ;
# Use this if lesspipe.sh exists.
fi ;
export LESS="-i -w -z-4 -g -h30 -M -X -F -R -P%t?f%f " ;
# LESS man page colors (makes Man pages more readable).
export LESS_TERMCAP_mb=$'\e[01;31m'
export LESS_TERMCAP_md=$'\e[01;31m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;44;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[01;32m'
export PAGER=less
else
alias more='less'
export PAGER=less
export LESSCHARSET='utf-8'
if [[ ( -x /usr/bin/lesspipe.sh ) ]] ; then
export LESSOPEN='|/usr/bin/lesspipe.sh %s 2>&-'
# Use this if lesspipe.sh exists.
fi ;
export LESS='-i -d -w -z-4 -g -h30 -m -X -F -R -P%t?f%f '
PS1="\A \u@\h \W --> " ;
export HISTTIMEFORMAT="[%y/%m/%d %H:%M:%S] " ;
fi
export TIMEFORMAT=$"\nreal %3R\tuser %3U\tsys %3S\tpcpu %P\n" ;
export HISTIGNORE="&:bg:fg:ll:h" ;
# ======================= END =======================
# 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
# set a fancy prompt (non-color, overwrite the one in /etc/profile)
#PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#xterm*|rxvt*)
# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
# ;;
#*)
# ;;
#esac
if [[ ( -r ${HOME}/.bash_aliases ) ]]; then
source ${HOME}/.bash_aliases || true ;
fi
# enable bash completion in interactive shells
if ! shopt -oq posix; then
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
if [ -r ${HOMEBREW_PREFIX:-"${HOME}/homebrew"}/etc/bash_completion ]; then
source ${HOMEBREW_PREFIX:-"${HOME}/homebrew"}/etc/bash_completion
fi
if [ -r ${HOMEBREW_PREFIX:-"${HOME}/homebrew"}/completions/bash/brew ]; then
source ${HOMEBREW_PREFIX:-"${HOME}/homebrew"}/completions/bash/brew
fi
if [ -r ${HOMEBREW_PREFIX:-"${HOME}/homebrew"}/completions/bash/ninja ]; then
source ${HOMEBREW_PREFIX:-"${HOME}/homebrew"}/completions/bash/ninja
fi
if [ -d ${HOMEBREW_PREFIX:-"${HOME}/homebrew"}/share/bash-completion/completions/ ]; then
for _TOOL_NAME in cmake cpack ctest gsettings gapplication gresource gdbus gio ; do
if [[ ( -r ${HOMEBREW_PREFIX:-"${HOME}/homebrew"}/share/bash-completion/completions/${_TOOL_NAME} ) ]]; then
source ${HOMEBREW_PREFIX:-"${HOME}/homebrew"}/share/bash-completion/completions/${_TOOL_NAME}
fi
done
fi
if [ -r ${HOME}/.config/completions/ymmv ]; then
source ${HOME}/.config/completions/ymmv
fi
fi
# set up man page search
manappend /usr/share/man
manappend /usr/local/share/man
manappend ${HOME}/.lib/doc/man
manappend /usr/local/MacGPG2/share/man
manappend ${HOMEBREW_PREFIX:-"${HOME}/homebrew"}/share/man
manappend ${HOMEBREW_PREFIX:-"${HOME}/homebrew"}/manpages
export MANPATH
# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handle {
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not found\n" "$1" >&2
return 127
fi
}
fi
# This file is NOT PART of YMMV's MIT LICENSE CONTENT
# as it is modified from versious projects and thus my contributions
# are probably subject to GPL ... so assume this file is GPL covered.
shopt -s interactive_comments
# this line must be last to avoid history of this file overwriting
shopt -so history