bashrc

   1 # Colors {{{
   2 
   3 if [[ -d ~/.cache/wal ]]; then
   4     cat ~/.cache/wal/sequences
   5     source ~/.cache/wal/colors-tty.sh
   6 else
   7     printf "\e]11;#222228\a"
   8     printf "\e]10;#d8dade\a"
   9     printf "\e]12;#d8dade\a"
  10 
  11     # printf "\e]4;0;#37373f\a"
  12     printf "\e]4;0;#222228\a"
  13     printf "\e]4;8;#4e4e56\a"
  14 
  15     printf "\e]4;1;#ff5f5f\a"
  16     printf "\e]4;9;#ff5f5f\a"
  17 
  18     printf "\e]4;2;#87af5f\a"
  19     printf "\e]4;10;#87af5f\a"
  20 
  21     printf "\e]4;3;#d7af87\a"
  22     printf "\e]4;11;#ffd75f\a"
  23 
  24     printf "\e]4;4;#5f5fff\a"
  25     printf "\e]4;12;#afafd7\a"
  26 
  27     printf "\e]4;5;#d75fff\a"
  28     printf "\e]4;13;#d75fff\a"
  29 
  30     printf "\e]4;6;#87d7d7\a"
  31     printf "\e]4;14;#87d7d6\a"
  32 
  33     printf "\e]4;7;#a8aaae\a"
  34     printf "\e]4;15;#d8dade\a"
  35 fi
  36 
  37 # }}}
  38 
  39 [[ $- != *i* ]] && return
  40 
  41 stty -ixon
  42 shopt -s autocd
  43 shopt -s globstar
  44 
  45 [[ $TERM == xterm* ]] &&
  46 TERM=xterm
  47 
  48 HISTSIZE= HISTFILESIZE=
  49 HISTTIMEFORMAT='[%F %T] '
  50 HISTCONTROL=ignorespace:ignoredups
  51 
  52 PROMPT_COMMAND=precmd
  53 function precmd(){ # {{{
  54     history -a
  55     printf '\e]0;%s@%s: %s\a' $USER $HOSTNAME "${PWD/$HOME/\~}"
  56 } # }}}
  57 
  58 PS1='\n\[\e[`ps1_hc`m\] \w`ps1_vcs` \$\[\e[0m\] '
  59 function ps1_hc(){ # {{{
  60     local c=37 f=~/.hostcolor
  61 
  62     [[ $SSH_TTY && -f $f ]] && c=$(< $f)
  63     [[ $SUDO_USER ]] && c=31
  64 
  65     echo $c
  66 } # }}}
  67 function ps1_vcs(){ # {{{
  68     local s
  69 
  70     [[ -d .hg || -d ../.hg || -d ../../.hg ]] &&
  71     s="hg:$(hg branch) +$(hg status | wc -l)"
  72 
  73     [[ -d .git || -d ../.git || -d ../../.git ]] &&
  74     s="git:$(git rev-parse --abbrev-ref HEAD) +$(git status -s | wc -l)"
  75 
  76     [[ $s ]] &&
  77     echo " [${s/ +0/}]"
  78 } # }}}
  79 
  80 alias vi='vim -p'
  81 alias rg='ranger'
  82 alias tm='tmux a || tmux'
  83 
  84 alias tt='tree -FlCL 2'
  85 alias ll='ls -Flh --color'
  86 alias lll='ll -A --time-style +"%F %T"'
  87 alias ttt='tt -L 10'
  88 
  89 alias d='cd ~/Desktop'
  90 alias l='cd ~/Projects/lexa.by'
  91 
  92 alias grep='grep -i --color'
  93 alias rsync='rsync -iPvh -rt'
  94 
  95 alias backup='rsync -L --exclude lost+\* /media/Home ~/.Backup'
  96 alias backup-camera='rsync -K /media/*/*/DCIM/Camera ~/.Backup'
  97 
  98 alias mpv-audio='mpv --profile audio'
  99 alias mpv-history='tac ~/.config/mpv/history.log | less'
 100 alias mpv-fan='(read u; mpv $(curl -s $u | grep -ao "http:.*\.mp4")) <<<'
 101 
 102 alias proxy-list='w3m -dump -cols 100 socks-proxy.net | sed "1,37d; 119,\$d"'
 103 
 104 u(){ # {{{
 105     [[ ! $@ ]] &&
 106     cd ~/.dotfiles &&
 107     return
 108 
 109     (u; vi $(for i in "$@"; do
 110         if [[ -f local/$i ]]; then
 111             echo local/$i
 112         elif [[ -f config/$i ]]; then
 113             echo config/$i
 114         else
 115             echo $i
 116         fi
 117     done))
 118 } # }}}
 119 complete -W "$(u; find * -type f | sed 's#^config/##')" u
 120 
 121 eval $(keychain -q --eval)
 122 
 123 [[ -d ~/.local/etc/bash_completion.d ]] &&
 124 source ~/.local/etc/bash_completion.d/*
 125 source /usr/share/bash-completion/bash_completion