d0tfiles

*nix dotfiles for arch linux setup
Log | Files | Refs | README | LICENSE

.bashrc (6897B)


      1 # ~/.bashrc: executed by bash(1) for non-login shells.
      2 # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
      3 # for examples
      4 [[ $- == *i* ]] || return 
      5 case $- in
      6 	*i*) ;;
      7 	  *) return;;
      8 esac
      9 
     10 # Add vim as default editor
     11 export EDITOR=vim
     12 export TERMINAL=urxvt
     13 export BROWSER=firefox
     14 export PROMPT_COMMAND='echo -ne "\033]0;$PWD\007"'
     15 
     16 # don't put duplicate lines or lines starting with space in the history.
     17 # See bash(1) for more options
     18 HISTCONTROL=ignoreboth
     19 
     20 # append to the history file, don't overwrite it
     21 shopt -s histappend
     22 
     23 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
     24 HISTSIZE=1000
     25 HISTFILESIZE=2000
     26 
     27 # set pager
     28 export PAGER=/usr/bin/most
     29 
     30 # check the window size after each command and, if necessary,
     31 # update the values of LINES and COLUMNS.
     32 shopt -s checkwinsize
     33 
     34 # Gtk themes 
     35 export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
     36 
     37 xhost +local:root > /dev/null 2>&1
     38 
     39 complete -cf sudo
     40 complete -cf man
     41 
     42 # Shopt
     43 shopt -s autocd
     44 shopt -s cdspell
     45 shopt -s cmdhist
     46 shopt -s dotglob
     47 shopt -s expand_aliases
     48 shopt -s extglob
     49 shopt -s hostcomplete
     50 shopt -s nocaseglob
     51 
     52 # Colour chart
     53 #!/bin/bash
     54 #
     55 UPDATES=$(aptitude search "~U" | wc -l)
     56 
     57 echo -e "\033[0;36m"
     58 
     59 echo ""
     60 
     61 echo "   ▀▄   ▄▀  "
     62 
     63 echo -e "  ▄█▀███▀█▄  \033[1;31m "$UPDATES"\033[0;36m  Fucks Given"
     64 
     65 echo " █▀███████▀█"
     66 
     67 echo " ▀ ▀▄▄ ▄▄▀ ▀"
     68 
     69 echo ""
     70 
     71 echo -e "\033[m"
     72 # enable color support of ls and also add handy aliases
     73 if [ -x /usr/bin/dircolors ]; then
     74     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
     75     alias ls='ls++'
     76     alias dir='dir --color=auto'
     77     alias vdir='vdir --color=auto'
     78     alias vpn='nordvpn connect'    
     79     alias work='bash /opt/forticlient-sslvpn/forticlientsslvpn.sh'    
     80     alias setup='sh /home/hide4/scripts/./feh.sh'
     81     alias grep='grep --color=auto'
     82     alias fgrep='fgrep --color=auto'
     83     alias egrep='egrep --color=auto'
     84 	alias vim='nvim'
     85 	alias wallpaper='feh --bg-scale ~/Pictures/smileypurp.ong'
     86 fi
     87 
     88 color_prompt=yes
     89 
     90 # Bash Completion
     91 if [ -f /etc/bash_completion ]; then
     92 	    . /etc/bash_completion
     93 fi
     94 
     95 # Alias definitions.
     96 if [ -x ~/.bash_aliases ]; then
     97     . ~/.bash_aliases
     98 fi
     99 
    100 # Function definitions.
    101 if [ -x ~/.bash_functions ]; then
    102     . ~/.bash_functions
    103 fi
    104 
    105 # Prompt definitions.
    106 if [ -x ~/.bash_prompt ]; then
    107     . ~/.bash_prompt
    108 fi
    109 
    110 ## MISC ALIASES ##
    111 alias ls='ls++'
    112 alias ll='ls -l --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F'
    113 alias la='ls -la --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F'
    114 alias grep='grep --color=tty -d skip'
    115 alias cp="cp -i"                          # confirm before overwriting something
    116 alias df='df -h'                          # human-readable sizes
    117 alias free='free -m'                      # show sizes in MB
    118 alias vp='vim PKGBUILD'
    119 
    120 alias update='sudo apt-get update'
    121 alias install='sudo apt-get install '
    122 alias uninstall='sudo pacman -Rs'
    123 alias search='pacman -Ss'
    124 alias show='pacman -Si'
    125 alias need='pacman -Qi'
    126 alias missing='pacman -Qk'
    127 alias trash='pacman -Qdt'
    128 
    129 alias youtube-mp3='youtube-dl --extract-audio --audio-format mp3'
    130 alias speedtest='speedtest-cli'
    131 
    132 
    133 
    134 alias wvdial='sudo wvdial'
    135 
    136 # Color man pages
    137 man() {
    138 	env \
    139 		LESS_TERMCAP_mb=$(printf "\e[1;31m") \
    140 		LESS_TERMCAP_md=$(printf "\e[1;31m") \
    141 		LESS_TERMCAP_me=$(printf "\e[0m") \
    142 		LESS_TERMCAP_se=$(printf "\e[0m") \
    143 		LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
    144 		LESS_TERMCAP_ue=$(printf "\e[0m") \
    145 		LESS_TERMCAP_us=$(printf "\e[1;32m") \
    146 			man "$@"
    147 }
    148 
    149 ## COMPRESSION FUNCTION ##
    150 function compress_() {
    151    # Credit goes to: Daenyth
    152    FILE=$1
    153    shift
    154    case $FILE in
    155       *.tar.bz2) tar cjf $FILE $*  ;;
    156       *.tar.gz)  tar czf $FILE $*  ;;
    157       *.tgz)     tar czf $FILE $*  ;;
    158       *.zip)     zip $FILE $*      ;;
    159       *.rar)     rar $FILE $*      ;;
    160       *)         echo "Filetype not recognized" ;;
    161    esac
    162 }
    163 
    164 ## EXTRACT FUNCTION ##
    165 extract ()
    166 {
    167   if [ -f $1 ] ; then
    168     case $1 in
    169       *.tar.bz2)   tar xjf $1   ;;
    170       *.tar.gz)    tar xzf $1   ;;
    171       *.bz2)       bunzip2 $1   ;;
    172       *.rar)       unrar x $1     ;;
    173       *.gz)        gunzip $1    ;;
    174       *.tar)       tar xf $1    ;;
    175       *.tbz2)      tar xjf $1   ;;
    176       *.tgz)       tar xzf $1   ;;
    177       *.zip)       unzip $1     ;;
    178       *.Z)         uncompress $1;;
    179       *.7z)        7z x $1      ;;
    180       *)           echo "'$1' cannot be extracted via extract()" ;;
    181     esac
    182   else
    183     echo "'$1' is not a valid file"
    184   fi
    185 }
    186 
    187 # test if a file should be opened normally, or as root (edit)
    188 argc () {
    189         count=0;
    190         for arg in "$@"; do
    191                 if [[ ! "$arg" =~ '-' ]]; then count=$(($count+1)); fi;
    192         done;
    193         echo $count;
    194 }
    195 
    196 edit () { if [[ `argc "$@"` > 1 ]]; then vim $@;
    197                 elif [ $1 = '' ]; then vim;
    198                 elif [ ! -f $1 ] || [ -w $1 ]; then vim $@;
    199                 else
    200                         echo -n "File is Read-only. Edit as root? (Y/n): "
    201                         read -n 1 yn; echo;
    202                         if [ "$yn" = 'n' ] || [ "$yn" = 'N' ];
    203                             then vim $*;
    204                             else sudo vim $*;
    205                         fi
    206                 fi
    207             }
    208 
    209 # cd and ls in one
    210 cl() {
    211     dir=$1
    212     if [[ -z "$dir" ]]; then
    213         dir=$HOME
    214     fi
    215     if [[ -d "$dir" ]]; then
    216         cd "$dir"
    217         ls
    218     else
    219         echo "bash: cl: '$dir': Directory not found"
    220     fi
    221 }
    222 
    223 # test encode & decode base64
    224 decode () {
    225   echo "$1" | base64 -d ; echo
    226 }
    227 
    228 encode () {
    229   echo "$1" | base64 - ; echo
    230 }
    231 
    232 # access translate.google.com from terminal
    233 translate () { 
    234  
    235 # adjust to taste
    236 DEFAULT_TARGET_LANG=en
    237  
    238 if [[ $1 = -h || $1 = --help ]]
    239 then
    240     echo "$help"
    241     exit
    242 fi
    243  
    244 if [[ $3 ]]; then
    245     source="$2"
    246     target="$3"
    247 elif [[ $2 ]]; then
    248     source=auto
    249     target="$2"
    250 else
    251     source=auto
    252     target="$DEFAULT_TARGET_LANG"
    253 fi
    254  
    255 echo $i" " $text
    256 result=$(curl -s -i --user-agent "" -d "sl=$source" -d "tl=$target" --data-urlencode "text=$1" http://translate.google.com)
    257 encoding=$(awk '/Content-Type: .* charset=/ {sub(/^.*charset=["'\'']?/,""); sub(/[ "'\''].*$/,""); print}' <<<"$result")
    258 iconv -f $encoding <<<"$result" |  awk 'BEGIN {RS="</div>"};/<span[^>]* id=["'\'']?result_box["'\'']?/' | html2text
    259 }
    260 
    261 # prompt
    262 # Needed for git status in the prompt
    263 #source /usr/share/git/git-prompt.sh 
    264 
    265 
    266 export PS1='\[\e]0;\w\a\]\[\033[31m\][\[\033[0;92m\]\W\[\033[31m\]]\[\033[0;35m\] \[\033[2;33m\]:\[\033[00m\] '
    267 
    268 export NVM_DIR="$HOME/.nvm"
    269 [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    270 [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
    271 
    272 # twilio autocomplete setup
    273 TWILIO_AC_BASH_SETUP_PATH=/home/hide4/.twilio-cli/autocomplete/bash_setup && test -f $TWILIO_AC_BASH_SETUP_PATH && source $TWILIO_AC_BASH_SETUP_PATH;