dotfiles

Cem's Dotfiles
git clone git://git.ckyln.com/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

.bashrc (5654B)


      1 #
      2 #    ██████╗  █████╗ ███████╗██╗  ██╗██████╗  ██████╗
      3 #    ██╔══██╗██╔══██╗██╔════╝██║  ██║██╔══██╗██╔════╝
      4 #    ██████╔╝███████║███████╗███████║██████╔╝██║
      5 #    ██╔══██╗██╔══██║╚════██║██╔══██║██╔══██╗██║
      6 # ██╗██████╔╝██║  ██║███████║██║  ██║██║  ██║╚██████╗
      7 # ╚═╝╚═════╝ ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝
      8 
      9 
     10 ## Most of this bashrc is from Manjaro
     11 
     12 [[ $- != *i* ]] && return
     13 
     14 colors() {
     15 	local fgc bgc vals seq0
     16 
     17 	printf "Color escapes are %s\n" '\e[${value};...;${value}m'
     18 	printf "Values 30..37 are \e[33mforeground colors\e[m\n"
     19 	printf "Values 40..47 are \e[43mbackground colors\e[m\n"
     20 	printf "Value  1 gives a  \e[1mbold-faced look\e[m\n\n"
     21 
     22 	# foreground colors
     23 	for fgc in {30..37}; do
     24 		# background colors
     25 		for bgc in {40..47}; do
     26 			fgc=${fgc#37} # white
     27 			bgc=${bgc#40} # black
     28 
     29 			vals="${fgc:+$fgc;}${bgc}"
     30 			vals=${vals%%;}
     31 
     32 			seq0="${vals:+\e[${vals}m}"
     33 			printf "  %-9s" "${seq0:-(default)}"
     34 			printf " ${seq0}TEXT\e[m"
     35 			printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
     36 		done
     37 		echo; echo
     38 	done
     39 }
     40 
     41 # Make colorcoding available for everyone 
     42 # (originally from Anarchy Linux but I thought it was nice/effortless so I got it)
     43 
     44 Black='\e[0;30m'        # Black
     45 Red='\e[0;31m'          # Red
     46 Green='\e[0;32m'        # Green
     47 Yellow='\e[0;33m'       # Yellow
     48 Blue='\e[0;34m'         # Blue
     49 Purple='\e[0;35m'       # Purple
     50 Cyan='\e[0;36m'         # Cyan
     51 White='\e[0;37m'        # White
     52 
     53 # Bold
     54 BBlack='\e[1;30m'       # Black
     55 BRed='\e[1;31m'         # Red
     56 BGreen='\e[1;32m'       # Green
     57 BYellow='\e[1;33m'      # Yellow
     58 BBlue='\e[1;34m'        # Blue
     59 BPurple='\e[1;35m'      # Purple
     60 BCyan='\e[1;36m'        # Cyan
     61 BWhite='\e[1;37m'       # White
     62 
     63 # Background
     64 On_Black='\e[40m'       # Black
     65 On_Red='\e[41m'         # Red
     66 On_Green='\e[42m'       # Green
     67 On_Yellow='\e[43m'      # Yellow
     68 On_Blue='\e[44m'        # Blue
     69 On_Purple='\e[45m'      # Purple
     70 On_Cyan='\e[46m'        # Cyan
     71 On_White='\e[47m'       # White
     72 
     73 NC="\e[m"               # Color Reset
     74 
     75 
     76 [ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
     77 
     78 # Change the window title of X terminals
     79 case ${TERM} in
     80 	xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|interix|konsole*)
     81 		PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\007"'
     82 		;;
     83 	screen*)
     84 		PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\033\\"'
     85 		;;
     86 esac
     87 
     88 use_color=true
     89 
     90 # Set colorful PS1 only on colorful terminals.
     91 # dircolors --print-database uses its own built-in database
     92 # instead of using /etc/DIR_COLORS.  Try to use the external file
     93 # first to take advantage of user additions.  Use internal bash
     94 # globbing instead of external grep binary.
     95 safe_term=${TERM//[^[:alnum:]]/?}   # sanitize TERM
     96 match_lhs=""
     97 [[ -f ~/.dir_colors   ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
     98 [[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
     99 [[ -z ${match_lhs}    ]] \
    100 	&& type -P dircolors >/dev/null \
    101 	&& match_lhs=$(dircolors --print-database)
    102 [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true
    103 
    104 if ${use_color} ; then
    105 	# Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
    106 	if type -P dircolors >/dev/null ; then
    107 		if [[ -f ~/.dir_colors ]] ; then
    108 			eval $(dircolors -b ~/.dir_colors)
    109 		elif [[ -f /etc/DIR_COLORS ]] ; then
    110 			eval $(dircolors -b /etc/DIR_COLORS)
    111 		fi
    112 	fi
    113 
    114 	if [[ ${EUID} == 0 ]] ; then
    115 		PS1='\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] '
    116 	else
    117 		PS1="\[\e]2;\u --> \w\a\]\[${BYellow}\]\u\[${BGreen}\]@\[${BCyan}\]\h\[${BWhite}\] \[${BRed}\]\W\[${BWhite}\]\[${BGreen}\] \[${BCyan}\]->\[${NC}\] "
    118 	fi
    119 
    120 	alias ls='ls --color=auto'
    121 	alias ll='ls --color=auto -a'
    122 	alias grep='grep --colour=auto'
    123 	alias egrep='egrep --colour=auto'
    124 	alias fgrep='fgrep --colour=auto'
    125 else
    126 	if [[ ${EUID} == 0 ]] ; then
    127 		# show root@ when we don't have colors
    128 		PS1='\u@\h \W \$ '
    129 	else
    130 		PS1='\u@\h \w \$ '
    131 	fi
    132 fi
    133 
    134 unset use_color safe_term match_lhs sh
    135 
    136 xhost +local:root > /dev/null 2>&1
    137 
    138 complete -cf sudo
    139 
    140 # Bash won't get SIGWINCH if another process is in the foreground.
    141 # Enable checkwinsize so that bash will check the terminal size when
    142 # it regains control.  #65623
    143 # http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
    144 shopt -s checkwinsize
    145 shopt -s autocd
    146 shopt -s expand_aliases
    147 
    148 # export QT_SELECT=4
    149 
    150 # Enable history appending instead of overwriting.  #139609
    151 shopt -s histappend
    152 HISTSIZE=912391291249
    153 HISTFILESIZE=912391291249
    154 #
    155 # # ex - archive extractor
    156 # # usage: ex <file>
    157 ex ()
    158 {
    159   if [ -f $1 ] ; then
    160     case $1 in
    161       *.tar.bz2)   tar xjf $1   ;;
    162       *.tar.gz)    tar xzf $1   ;;
    163       *.bz2)       bunzip2 $1   ;;
    164       *.rar)       unrar x $1     ;;
    165       *.gz)        gunzip $1    ;;
    166       *.tar)       tar xf $1    ;;
    167       *.tbz2)      tar xjf $1   ;;
    168       *.tgz)       tar xzf $1   ;;
    169       *.zip)       unzip $1     ;;
    170       *.Z)         uncompress $1;;
    171       *.7z)        7z x $1      ;;
    172       *.tar.xz)    tar xJf $1   ;;
    173       *)           echo "'$1' cannot be extracted via ex()" ;;
    174     esac
    175   else
    176     echo "'$1' is not a valid file"
    177   fi
    178 }
    179 
    180 # Personal Scripts
    181 set -o vi
    182 
    183 source $HOME/.profile