07/21/18 09:30:12 /run/media/erik/storage/My-Websites/docs/bashrc_Manj-architect.rc
   1 
#   Manjaro 17.1.11 Hakoila
   2 
# ~/.bashrc
   3 
#  /root/.bashrc
   4 
 
   5 
[[ $- != *i* ]] && return
   6 
 
   7 
colors() {
   8 
    local fgc bgc vals seq0
   9 
 
  10 
    printf "Color escapes are %s\n" '\e[${value};...;${value}m'
  11 
    printf "Values 30..37 are \e[33mforeground colors\e[m\n"
  12 
    printf "Values 40..47 are \e[43mbackground colors\e[m\n"
  13 
    printf "Value  1 gives a  \e[1mbold-faced look\e[m\n\n"
  14 
 
  15 
    # foreground colors
  16 
    for fgc in {30..37}; do
  17 
        # background colors
  18 
        for bgc in {40..47}; do
  19 
            fgc=${fgc#37} # white
  20 
            bgc=${bgc#40} # black
  21 
 
  22 
            vals="${fgc:+$fgc;}${bgc}"
  23 
            vals=${vals%%;}
  24 
 
  25 
            seq0="${vals:+\e[${vals}m}"
  26 
            printf "  %-9s" "${seq0:-(default)}"
  27 
            printf " ${seq0}TEXT\e[m"
  28 
            printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
  29 
        done
  30 
        echo; echo
  31 
    done
  32 
}
  33 
 
  34 
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
  35 
 
  36 
# Change the window title of X terminals
  37 
case ${TERM} in
  38 
    xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|interix|konsole*)
  39 
        PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\007"'
  40 
        ;;
  41 
    screen*)
  42 
        PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\033\\"'
  43 
        ;;
  44 
esac
  45 
 
  46 
use_color=true
  47 
 
  48 
# Set colorful PS1 only on colorful terminals.
  49 
# dircolors --print-database uses its own built-in database
  50 
# instead of using /etc/DIR_COLORS.  Try to use the external file
  51 
# first to take advantage of user additions.  Use internal bash
  52 
# globbing instead of external grep binary.
  53 
safe_term=${TERM//[^[:alnum:]]/?}   # sanitize TERM
  54 
match_lhs=""
  55 
[[ -f ~/.dir_colors   ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
  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.  Prefer ~/.dir_colors #64489
  64 
    if type -P dircolors >/dev/null ; then
  65 
        if [[ -f ~/.dir_colors ]] ; then
  66 
            eval $(dircolors -b ~/.dir_colors)
  67 
        elif [[ -f /etc/DIR_COLORS ]] ; then
  68 
            eval $(dircolors -b /etc/DIR_COLORS)
  69 
        fi
  70 
    fi
  71 
 
  72 
    if [[ ${EUID} == 0 ]] ; then
  73 
        PS1='\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] '
  74 
    else
  75 
        PS1='\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]\$\[\033[00m\] '
  76 
    fi
  77 
 
  78 
    alias ls='ls --color=auto'
  79 
    alias grep='grep --colour=auto'
  80 
    alias egrep='egrep --colour=auto'
  81 
    alias fgrep='fgrep --colour=auto'
  82 
else
  83 
    if [[ ${EUID} == 0 ]] ; then
  84 
        # show root@ when we don't have colors
  85 
        PS1='\u@\h \W \$ '
  86 
    else
  87 
        PS1='\u@\h \w \$ '
  88 
    fi
  89 
fi
  90 
 
  91 
unset use_color safe_term match_lhs sh
  92 
 
  93 
alias cp="cp -i"                          # confirm before overwriting something
  94 
alias df='df -h'                          # human-readable sizes
  95 
alias free='free -m'                      # show sizes in MB
  96 
alias np='nano -w PKGBUILD'
  97 
alias more=less
  98 
 
  99 
xhost +local:root > /dev/null 2>&1
 100 
 
 101 
complete -cf sudo
 102 
 
 103 
# Bash won't get SIGWINCH if another process is in the foreground.
 104 
# Enable checkwinsize so that bash will check the terminal size when
 105 
# it regains control.  #65623
 106 
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
 107 
shopt -s checkwinsize
 108 
 
 109 
shopt -s expand_aliases
 110 
 
 111 
# export QT_SELECT=4
 112 
 
 113 
# Enable history appending instead of overwriting.  #139609
 114 
shopt -s histappend
 115 
 
 116 
#
 117 
# # ex - archive extractor
 118 
# # usage: ex <file>
 119 
ex ()
 120 
{
 121 
  if [ -f $1 ] ; then
 122 
    case $1 in
 123 
      *.tar.bz2)   tar xjf $1   ;;
 124 
      *.tar.gz)    tar xzf $1   ;;
 125 
      *.bz2)       bunzip2 $1   ;;
 126 
      *.rar)       unrar x $1   ;;
 127 
      *.gz)        gunzip $1    ;;
 128 
      *.tar)       tar xf $1    ;;
 129 
      *.tbz2)      tar xjf $1   ;;
 130 
      *.tgz)       tar xzf $1   ;;
 131 
      *.zip)       unzip $1     ;;
 132 
      *.Z)         uncompress $1;;
 133 
      *.7z)        7z x $1      ;;
 134 
      *)           echo "'$1' cannot be extracted via ex()" ;;
 135 
    esac
 136 
  else
 137 
    echo "'$1' is not a valid file"
 138 
  fi
 139 
}
 140 
 
 141 
# better yaourt colors
 142 
export YAOURT_COLORS="nb=1:pkg=1:ver=1;32:lver=1;45:installed=1;42:grp=1;34:od=1;41;5:votes=1;44:dsc=0:other=1;35"
 143 
 
 144 
#============ Erik's settings ============================
 145 
export PATH="/usr/lib/ccache/bin/:$PATH"
 146 
export MAKEFLAGS="-j13 -l12"
 147 
 
 148 
export HISTCONTROL=ignoredups:erasedups
 149 
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"
 150 
#PROMPT_COMMAND="history -a;history -c;history -r;$PROMPT_COMMAND"
 151 
 
 152 
alias c='clear'
 153 
alias ll='ls -la'