dotfiles

My personal dotfiles 💠️

bashrc (2852B)

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