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 
  43 shopt -s autocd
  44 shopt -s globstar
  45 
  46 [[ $TERM == xterm* ]] &&
  47 TERM=xterm
  48 
  49 HISTSIZE= HISTFILESIZE=
  50 HISTTIMEFORMAT='[%F %T] '
  51 HISTCONTROL=ignorespace:ignoredups
  52 
  53 PROMPT_COMMAND=precmd
  54 function precmd(){ # {{{
  55     history -a
  56     printf '\e]0;%s@%s: %s\a' $USER $HOSTNAME "${PWD/$HOME/\~}"
  57 } # }}}
  58 
  59 PS1='\n\[\e[`ps1_hc`m\] \w`ps1_vcs` \$\[\e[0m\] '
  60 function ps1_hc(){ # {{{
  61     local c=37 f=~/.hostcolor
  62 
  63     [[ $SSH_TTY && -f $f ]] && c=$(< $f)
  64     [[ $SUDO_USER ]] && c=31
  65 
  66     echo $c
  67 } # }}}
  68 function ps1_vcs(){ # {{{
  69     local s
  70 
  71     [[ -d .hg || -d ../.hg || -d ../../.hg ]] &&
  72     s="hg:$(hg branch) +$(hg status | wc -l)"
  73 
  74     [[ -d .git || -d ../.git || -d ../../.git ]] &&
  75     s="git:$(git name-rev --name-only @) +$(git status -s | wc -l)"
  76 
  77     [[ $s ]] &&
  78     echo " [${s/ +0/}]"
  79 } # }}}
  80 
  81 alias vi='vim -p'
  82 alias rg='ranger'
  83 alias tm='tmux a || tmux'
  84 
  85 alias tt='tree -FlCL 2'
  86 alias ll='ls -Flh --color'
  87 
  88 alias d='cd ~/Desktop'
  89 alias l='cd ~/Projects/lexa.by'
  90 
  91 alias grep='grep -i --color'
  92 alias rsync='rsync -iPvh -rt'
  93 
  94 alias backup='rsync -L --exclude lost+\* /media/Home ~/.Backup'
  95 alias backup-camera='rsync -K /media/*/*/DCIM/Camera ~/.Backup'
  96 
  97 alias mpv-audio='mpv --profile audio'
  98 alias mpv-history='tac ~/.config/mpv/history.log | less'
  99 alias mpv-fan='(read u; mpv $(curl -s $u | grep -ao "http:.*\.mp4")) <<<'
 100 
 101 alias proxy-list='w3m -dump -cols 100 socks-proxy.net | sed "1,37d; 119,\$d"'
 102 
 103 u(){ # {{{
 104     [[ ! $@ ]] &&
 105     cd ~/.dotfiles &&
 106     return
 107 
 108     (u; vi $(for i in "$@"; do
 109         if [[ -f local/$i ]]; then
 110             echo local/$i
 111         elif [[ -f config/$i ]]; then
 112             echo config/$i
 113         else
 114             echo $i
 115         fi
 116     done))
 117 } # }}}
 118 complete -W "$(u; find * -type f | sed 's#^config/##')" u
 119 
 120 eval $(keychain -q --eval)
 121 
 122 [[ -d ~/.local/etc/bash_completion.d ]] &&
 123 source ~/.local/etc/bash_completion.d/*
 124 source /usr/share/bash-completion/bash_completion