dotfiles

My personal dotfiles 💠️

.bashrc (2667B)

      1 #
      2 # ~/.bashrc
      3 #
      4 
      5 [[ $- != *i* ]] && return
      6 
      7 . $HOME/.local/bin/exports.sh
      8 . $HOME/.local/bin/aliases.sh
      9 
     10 colors() {
     11 	local fgc bgc vals seq0
     12 
     13 	printf "Color escapes are %s\n" '\e[${value};...;${value}m'
     14 	printf "Values 30..37 are \e[33mforeground colors\e[m\n"
     15 	printf "Values 40..47 are \e[43mbackground colors\e[m\n"
     16 	printf "Value  1 gives a  \e[1mbold-faced look\e[m\n\n"
     17 
     18 	# foreground colors
     19 	for fgc in {30..37}; do
     20 		# background colors
     21 		for bgc in {40..47}; do
     22 			fgc=${fgc#37} # white
     23 			bgc=${bgc#40} # black
     24 
     25 			vals="${fgc:+$fgc;}${bgc}"
     26 			vals=${vals%%;}
     27 
     28 			seq0="${vals:+\e[${vals}m}"
     29 			printf "  %-9s" "${seq0:-(default)}"
     30 			printf " ${seq0}TEXT\e[m"
     31 			printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
     32 		done
     33 		echo; echo
     34 	done
     35 }
     36 
     37 [ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
     38 
     39 # Change the window title of X terminals
     40 case ${TERM} in
     41 	xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|interix|konsole*)
     42 		PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\007"'
     43 		;;
     44 	screen*)
     45 		PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\033\\"'
     46 		;;
     47 esac
     48 
     49 use_color=true
     50 
     51 # Set colorful PS1 only on colorful terminals.
     52 # first to take advantage of user additions.  Use internal bash
     53 # globbing instead of external grep binary.
     54 safe_term=${TERM//[^[:alnum:]]/?}   # sanitize TERM
     55 match_lhs=""
     56 [[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
     57 [[ -z ${match_lhs}    ]] \
     58 	&& type -P dircolors >/dev/null \
     59 	&& match_lhs=$(dircolors --print-database)
     60 [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true
     61 
     62 if ${use_color} ; then
     63 	# Enable colors for ls, etc. 
     64 	if type -P dircolors >/dev/null && [[ -f /etc/DIR_COLORS ]] ; then
     65     eval $(dircolors -b /etc/DIR_COLORS)
     66 	fi
     67 
     68 	if [[ ${EUID} == 0 ]] ; then
     69 		PS1='[\[\033[01;32m\]\u@\h\[\033[01;34m\] \W\[\e[00;37m\]]\$\[\033[00m\] '
     70 		PS2='\[\033[01;34m\]\W \[\e[00;37m\]\$\[\033[00m\] '
     71 	else
     72 		PS1='[\[\033[01;32m\]\u@\h\[\033[01;34m\] \W\[\e[00;37m\]]\$\[\033[00m\] '
     73 		PS2='\[\033[01;34m\]\W \[\e[00;37m\]\#\[\033[00m\] '
     74 	fi
     75 else
     76 	if [[ ${EUID} == 0 ]] ; then
     77 		# show root@ when we don't have colors
     78 		PS1='\u@\h \W \# '
     79 	else
     80 		PS1='\u@\h \w \$ '
     81 	fi
     82 fi
     83 
     84 unset use_color safe_term match_lhs sh
     85 
     86 xhost +local:root > /dev/null 2>&1
     87 
     88 # Bash won't get SIGWINCH if another process is in the foreground.
     89 # Enable checkwinsize so that bash will check the terminal size when
     90 # it regains control.  #65623
     91 # http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
     92 shopt -s checkwinsize
     93 
     94 shopt -s expand_aliases
     95 
     96 # Enable history appending instead of overwriting.  #139609
     97 shopt -s histappend
     98